Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding a control from its hwnd (VB6)

    Hi all,

    Simply put, how do I find a control from its hwnd value? Is the only way to loop each loaded form, then loop the controls on each form until the hwnd value is matched? If so, how much of an overhead would this cause?

    Complex explanation:
    You know the layout of SQL with the list of elements down the left and the pane on the right changes depending what you've clicked on? I'm trying to replicate that. Different use but same methods.

    Currently I have a pane control to split my form up. On the left pane is a Treeview control as its only ever going to be a treeview control there.
    However, the right pane can display various controls, so I have put a PictureBox on it and planned to use SetParent to display the necessary control in that pane. However, i'm having trouble resizing whatever is being displayed in the picturebox, hence the need to find out a control from its hwnd.

    If anyone can either help with my current problem or suggest a better method of doing this, it would be much apprecaited.

    Regards,
    Phil

    p.s. I searched first but only found a previous question from me along the same lines. I thought i'd ask again in case anyone had found the answer since march.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a control from its hwnd (VB6)

    So do you want to identify a control by name, given its handle? I'm thinking you might be able to use the EnumChildWindows API function which will supply all child handles for a specified parent hWnd. Then getting the window Class Name for each hWnd using the GetClassName API function, you might be able to zero in on the target control. Perhaps ANALYZER will reveal something from a running instance.

    Alan

  4. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a control from its hwnd (VB6)

    Thanks Alan, found quite a bit of info on EnumChildWindows so I should be able to pick out what I need from that. That Analyzer program should come in quite handy too!

    Thanks again, regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •