home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,688 of 10,840   
   Bill McCarthy to Don   
   Re: Get Control IDs more efficiently   
   05 Dec 08 12:10:28   
   
   XPost: microsoft.public.vb.general.discussion, microsoft.public.vb   
   From: Bill@localhost.com   
      
   Hi Don,   
      
   You can use EnumWindows where you provide a callback method in a module, eg:   
      
   Put this method in a module   
      
   Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As   
   Boolean   
      EnumWindowsProc = True ' continues   
   End Function   
      
   Use this decleration:   
      
   Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long,   
   ByVal lParam As Long) As Long   
      
      
   and then invoke it such as :   
      
   Call EnumWindows(AddressOf EnumWindowsProc, someHwnd)   
      
      
   Alternatively you can use FindWindowEx, passing in the last found window as   
   the second parameter each time.   
      
      
      
      
      
   "Don"  wrote in message   
   news:4938467a.6566625@news.west.cox.net...   
   > I'm using the GetDlgItem function to get the text from a specific   
   > control in external apps.  Works fine, but if I don't know the control   
   > ID, I create a loop (e.g. 0 to 100) to test all the control IDs in   
   > that range to find the control.  Problem is that a control can have a   
   > very large number as the ID and I enumerate through all windows and   
   > their child windows so that can create a little more delay than I want   
   > and I would never be sure my loop is a range that covers the highest   
   > control ID number.   
   >   
   > Is there an API function or a way to grab all the control ID numbers   
   > on a window rather than looping through a range of numbers to find a   
   > control that matches that ID number?   
   >   
   > Thanks,   
   > Don   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca