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,706 of 10,840    |
|    Don to Don    |
|    Re: Get Control IDs more efficiently    |
|    09 Dec 08 09:08:54    |
      XPost: microsoft.public.vb.general.discussion, microsoft.public.vb       From: dsarvas@yahoo.com              WOW! Thanks to ALL of you, I now have just what I was looking for.              It took a little of EVERYTHING you all had to offer.              Although I still have to grab the control IDs to find all text on all       controls, it now works nearly instantaneously now that I don't have to       loop through a long range of numbers just to be sure I didn't miss a       control. I still can't figure out how to get the text without the       IDs, but now that I can do so instantaneously using all the functions       you've pointed out, it's a moot point . . . for me, anyway.              Although before starting this thread I was already using       EnumWindowProc() and EnumChildProc() to get all the windows' handles,       I just couldn't seem to get to that level where I could scoop up all       the text from all the controls in an efficient manner. Now I can.              The following is the code I ended up placing in the enum functions as       a test. I'm still open to suggestions if anyone thinks this is not       the proper way to get this done, but I'm happy with the results.              And Bill, as you suggested, I gave GetDlgCtrlID() another try since       you were getting a return of 15 for Notepad's edit screen and I       wasn't. Now I do get that value. Not sure what happened the first       time I tried so thanks for the push.              Don              lastHandle = 0       lastHandle = FindWindowEx(hwnd, lastHandle, vbNullString,       vbNullString)       Test = GetDlgCtrlID(lastHandle)       lngCtrlHWND = GetDlgItem(hwnd, Test)       strWindowText = String(80, Chr(0))       SendMessage lngCtrlHWND, WM_GETTEXT, 100, ByVal strWindowText       strName = TrimNull(strWindowText)       If Len(strName) > 0 Then        Here's where I collect the text from all the controls that I can.       End If                            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