Results 1 to 8 of 8

Thread: Design time event

  1. #1

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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.

  2. #2
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    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")
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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:
    1. Option Explicit
    2.  
    3. Private Type POINTAPI
    4.     X As Long
    5.     Y As Long
    6. End Type
    7.  
    8. Private Declare Function WindowFromPoint Lib "user32" _
    9.     (ByVal xPoint As Long, _
    10.     ByVal yPoint As Long) As Long
    11.  
    12. Private Declare Function RealChildWindowFromPoint Lib "user32" _
    13.     (ByVal hWndParent As Long, _
    14.     ByVal xPoint As Long, _
    15.     ByVal yPoint As Long) As Long
    16.  
    17. Private Declare Function ScreenToClient Lib "user32" _
    18.     (ByVal hWnd As Long, _
    19.     lpPoint As POINTAPI) As Long
    20.    
    21. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    22. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    23.  
    24. Private pa As POINTAPI
    25.  
    26. Public Function GetWindowFromPoint(ByVal X As Long, ByVal Y As Long) As Long
    27.     Dim p As POINTAPI, ch As Long, h As Long
    28.    
    29.     ch = WindowFromPoint(X, Y)
    30.    
    31.     Do
    32.         h = ch
    33.         p.X = X: p.Y = Y
    34.         ScreenToClient h, p
    35.         ch = RealChildWindowFromPoint(h, p.X, p.Y)
    36.     Loop Until ch = h Or ch = 0
    37.    
    38.     GetWindowFromPoint = h
    39. End Function
    40.  
    41. Private Sub UserControl_Initialize()
    42.     Timer1.Interval = 1
    43.     Timer1.Enabled = True
    44. End Sub
    45.  
    46. Private Sub Timer1_Timer()
    47.     GetCursorPos pa
    48.    
    49.     If GetWindowFromPoint(pa.X, pa.Y) = UserControl.hWnd Then
    50.         Label1.Caption = "MouseMove in User Control Area!" 'Mousemove message                                                
    51.         If CBool(GetAsyncKeyState(vbLeftButton)) Then
    52.             Label2.Caption = "MouseDown in User Control Area!" 'MouseDown message
    53.         Else
    54.             Label2.Caption = ""
    55.         End If
    56.     Else
    57.         Label1.Caption = ""
    58.     End If
    59. 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)

  4. #4

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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.

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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?

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Design time event

    Quote Originally Posted by jcis
    What's LMB?
    I'm pretty sure Left Mouse Button.


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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.

  8. #8

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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
  •  



Click Here to Expand Forum to Full Width