|
-
Feb 25th, 2006, 12:53 PM
#1
Thread Starter
Addicted Member
Design time event
Hi All;
İs there a way for a custom control to add an event running at design time?
for example mouse down or up or move event.
any idea or link acceptable
You can do while you think that you can do
If you think my answer solve your question, please rate it.
-
Feb 25th, 2006, 10:11 PM
#2
Frenzied Member
Re: Design time event
The cutom control click event is reserved for app runtime only.
If you want to add some more options to your custom control then the best and easiest way of doing so is adding a "PropertyPage" to your control. in the Property Page you can add some more options about your control.
Don't forget to go to your control and in the Property Tab on the side click on the "..." button next to the Property Pages and add your Property Page by checking it. (Default:"PropertyPage1")
-
Feb 25th, 2006, 11:34 PM
#3
Re: Design time event
If you can't do it like that, this works fine:
For this example, Add 2 labels to your UserControl and a Timer, make you control something like 4 x 4 centimeters, and make your labels a little wider than the default, so you can see messages there dancing at design mode, so the code for your User Control:
VB Code:
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" _
(ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
Private Declare Function RealChildWindowFromPoint Lib "user32" _
(ByVal hWndParent As Long, _
ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
Private Declare Function ScreenToClient Lib "user32" _
(ByVal hWnd As Long, _
lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private pa As POINTAPI
Public Function GetWindowFromPoint(ByVal X As Long, ByVal Y As Long) As Long
Dim p As POINTAPI, ch As Long, h As Long
ch = WindowFromPoint(X, Y)
Do
h = ch
p.X = X: p.Y = Y
ScreenToClient h, p
ch = RealChildWindowFromPoint(h, p.X, p.Y)
Loop Until ch = h Or ch = 0
GetWindowFromPoint = h
End Function
Private Sub UserControl_Initialize()
Timer1.Interval = 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
GetCursorPos pa
If GetWindowFromPoint(pa.X, pa.Y) = UserControl.hWnd Then
Label1.Caption = "MouseMove in User Control Area!" 'Mousemove message
If CBool(GetAsyncKeyState(vbLeftButton)) Then
Label2.Caption = "MouseDown in User Control Area!" 'MouseDown message
Else
Label2.Caption = ""
End If
Else
Label1.Caption = ""
End If
End Sub
Offcourse, compile it, and add it to you VB project.
It should show in design mode..
MouseMove in User Control Area! and..
MouseDown in User Control Area! (when you press left mouse button over it)
-
Feb 26th, 2006, 08:26 AM
#4
Thread Starter
Addicted Member
Re: Design time event
Dear jcis;
your example really working, but when at design time control is causing flicker the caption of main VB window and also this feature is also running at run time.
The main reason of my question is to make a control which have two label inside and want labels witdh to adjust with a slider (or something similar) at design time. When mouse pointer is located at near beetwen two labels and pushed LMB we could adjust labels witdh when one is widening other must be narrowed as a classic way
is it possible ?
You can do while you think that you can do
If you think my answer solve your question, please rate it.
-
Feb 26th, 2006, 05:07 PM
#5
Re: Design time event
I'm not sure what you're trying to do. What's LMB? Also, the slider will rezise both labels? Could you show an screenshot?
-
Feb 26th, 2006, 05:30 PM
#6
-
Feb 27th, 2006, 02:05 PM
#7
Thread Starter
Addicted Member
Re: Design time event
yes you are right manavo11
LMB is LEFT MOUSE BUTTON every man who deal with PC knows that
dear jcis
what you said "the slider will rezise both labels" is exactly what i want to, i will do much more you want, i attached small VB project and pic.
it maybe show you the main idea that i want
this is a project i started but not finished yet unfortunately.
You can do while you think that you can do
If you think my answer solve your question, please rate it.
-
Mar 2nd, 2006, 02:12 PM
#8
Thread Starter
Addicted Member
Re: Design time event
dear jcis
did you review my small project? I wonder what you will say.
You can do while you think that you can do
If you think my answer solve your question, please rate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|