Results 1 to 4 of 4

Thread: Show my usercontrol "On top"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Show my usercontrol "On top"

    Hi,
    I've used the following code to keep a form "On top" without problem.

    I made a control similar to MSDatePicker and I'd like to keep it on top when
    the date picker is open (right now when the date picker is placed at the
    bottom of the form and opened there it will only be displayed up to the
    bottom edge of the form).

    Problem is that the UserControl doesn't have the .hWnd property.What can I do?

    VB Code:
    1. ' Top most stuff in a module
    2. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    3. Private Const HWND_TOPMOST = -1
    4. Private Const HWND_NOTOPMOST = -2
    5. Private Const SWP_NOMOVE = 2
    6. Private Const SWP_NOSIZE = 1
    7. Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    8.  
    9. ' Usage:
    10. SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
    Thanks

    Tomexx.

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Show my usercontrol "On top"

    Have you tried using the .zOrder property of it?

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

    Re: Show my usercontrol "On top"

    If you add this to your Usercontrol code..
    VB Code:
    1. Public Property Get hWnd() As Long
    2.     hWnd = UserControl.hWnd
    3. End Property
    ..then the hWnd should be accessible in code from the form (I think)

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Re: Show my usercontrol "On top"

    zOrder didn't work.

    I did add hWnd property but still my control doesn't drop the bottom of my form.
    Thanks

    Tomexx.

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