Results 1 to 10 of 10

Thread: FindWindowEx - Multiple controls with same class name

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Grand Rapids, MI.
    Posts
    74

    FindWindowEx - Multiple controls with same class name

    I'm trying to send text to a text box within another application, with the class name "Edit." Normally, this wouldn't be a problem, but there are 3 other boxes with the same class name in the same hwnd. How can I access them individually?

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: FindWindowEx - Multiple controls with same class name

    Did you try thease.

    1. You can manupulate it windowRect for diffrence.
    2. you can panipulate the text (GetWindowText) of the controlls for diffrents.
    Last edited by Fazi; Aug 13th, 2007 at 04:23 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Grand Rapids, MI.
    Posts
    74

    Re: FindWindowEx - Multiple controls with same class name

    Yeah, that would tell me if the current box that I am accessing is the right or wrong one.. but if it's the wrong one, how do I tell my program to move on to the next?

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: FindWindowEx - Multiple controls with same class name

    neomulemi6,

    You can rtrive the WindowRect & hwnd of all the controlls and store in an array(). then sort the arry. Within the array, you find the one you want. then reffer to its handle and do the rest.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Grand Rapids, MI.
    Posts
    74

    Re: FindWindowEx - Multiple controls with same class name

    I'm not sure how to access a window by handle... only by class or title.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: FindWindowEx - Multiple controls with same class name

    You can use the GetWindow API with the GW_HWNDNEXT argument constant or you can use the GetDlgCtrlID to retrieve the window control id number and match it with its known number to be able to identify if its the correct window.
    .
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: FindWindowEx - Multiple controls with same class name

    Quote Originally Posted by neomulemi6
    I'm not sure how to access a window by handle... only by class or title.
    Most of the window related API have an argument like 'hWnd as long'.
    hWnd is a long number that uniquly identifies a window by the OS. If you use FindWindowEx, the returned value is the handle of the window you find.
    Last edited by Fazi; Aug 13th, 2007 at 04:52 AM.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Grand Rapids, MI.
    Posts
    74

    Re: FindWindowEx - Multiple controls with same class name

    Isn't there a way to do this using the EnumWindows function, or something similar?

  9. #9
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: FindWindowEx - Multiple controls with same class name

    If you want to retrive a perticuler window, you can use FindWindow / FindWindowEx. (Please referrer to the MSDN For detail of earch.)

    If you want to enumurate all the windows in the sysem, you can use EnumWindows and EnumChildWindows.

    OK.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: FindWindowEx - Multiple controls with same class name

    GetWindow with the GWL_HWNDNEXT is similar to enumerating hte windows but at the level that you have drilled down to. Check out my Find Window by Partial Window Caption for an example.

    http://vbforums.com/showthread.php?t=316924
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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