Results 1 to 3 of 3

Thread: [VB6] - how catch the hwnd from a form with usercontrol(for 1 test)

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    [VB6] - how catch the hwnd from a form with usercontrol(for 1 test)

    i have these line:
    Code:
    UserControl.ParentControls(0).hwnd
    but the vb6 tell me that don't support\have that property\method...
    how can i catch the hwnd property from a form control?(i'm trying do 1 little test)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] - how catch the hwnd from a form with usercontrol(for 1 test)

    All usercontrols have a ContainerHwnd. You can get that, then in a loop use GetParent API until it returns zero. The last hWnd that API returned should be the main-level window.

    Also not sure when that line of code is run. If it is run before the control is "sited", it very well may not be supported. I'd wait for the Show event to fire if possible.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Re: [VB6] - how catch the hwnd from a form with usercontrol(for 1 test)

    Quote Originally Posted by LaVolpe View Post
    All usercontrols have a ContainerHwnd. You can get that, then in a loop use GetParent API until it returns zero. The last hWnd that API returned should be the main-level window.

    Also not sure when that line of code is run. If it is run before the control is "sited", it very well may not be supported. I'd wait for the Show event to fire if possible.
    thanks for that... i will try it
    VB6 2D Sprite control

    To live is difficult, but we do 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