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,695 of 10,840   
   Bill McCarthy to Don   
   Re: Get Control IDs more efficiently   
   07 Dec 08 14:14:33   
   
   XPost: microsoft.public.vb.general.discussion, microsoft.public.vb   
   From: Bill@localhost.com   
      
   Hi Don,   
      
   As others have said, use GetDlgCtrlID :   
      
   Public Declare Function GetDlgCtrlID Lib "user32" Alias "GetDlgCtrlID"   
   (ByVal hwnd As Long) As Long   
      
   Loop through the child windows, get the hwnd then call GetDlgCtrlID  using   
   the control's hwnd.   
      
   Just out of curiosity, why do you want the control ID's ?   
      
      
   "Don"  wrote in message   
   news:493a9d6d.2039234@news.west.cox.net...   
   > Thanks.  That's what I've been doing all along to get all windows,   
   > child windows and so on as deeply nested as necessary.  But to get the   
   > IDs of all the text boxes, etc. on each window required that I run a   
   > loop to test all possible ID numbers in existence.  Looks like the way   
   > I've been doing it is the best I can hope for, then.  Unfortunately,   
   > if I use a loop of 0 to 100, for instance, I won't find an control ID   
   > with a very high number.  If I run a loop with a very high limit then   
   > it may take longer than I want . . . but works.   
   >   
   > Don   
   >   
   > On Sat, 6 Dec 2008 16:21:42 +1100, "Bill McCarthy"   
   >  wrote:   
   >   
   >>Hi Don,   
   >>   
   >>You use those same functions to recurse children of children.  You won't   
   >>get   
   >>all controls, such as labels; only those that have windows.   
   >>   
   >>   
   >>"Don"  wrote in message   
   >>news:49394812.3110859@news.west.cox.net...   
   >>> Regarding the two suggestions offered so far, I see I wasn't clear in   
   >>> my original post..   
   >>>   
   >>> I'm using EnumWindows and EnumChildWindows to get all the window   
   >>> handles and their IDs which works fine.  But it's all the controls   
   >>> inside each window for which I need their IDs (text boxes, command   
   >>> buttons, etc.).  Creating a loop to test all possible ID numbers does   
   >>> work, but it would be much better if there an equivalent of the   
   >>> EnumWindows function that also enumerates all the control IDs inside   
   >>> the window.   
   >>>   
   >>> Don   
   >>>   
   >>> On Thu, 04 Dec 2008 21:07:40 GMT, dsarvas@yahoo.com (Don) wrote:   
   >>>   
   >>>>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