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,696 of 10,840    |
|    Don to Bill@localhost.com    |
|    Re: Get Control IDs more efficiently    |
|    07 Dec 08 16:33:04    |
      XPost: microsoft.public.vb.general.discussion, microsoft.public.vb       From: dsarvas@yahoo.com              The program I wrote monitors all windows running at a users       workstation, frequently testing those windows for text boxes, list       boxes, etc. for a specific string of characters that might contain       names of clients. Any number of programs might be run at the user's       workstation that might contain such info. If that string is found, my       program reacts by searching our own databases, documents, etc. for all       info pertaining to that client as an alert to the user of specific       procedures that must not be missed should they forget to check       themselves.              It works, but using the windows handle for each window found by       enumerating through the windows using EnumWindowProc() and       EnumChildProc() I still need to loop through each of those windows to       find the ID of the text boxes, etc. using the following code which       will find the text I'm searching in the variable strWindowsText below:              For lngCtrlId = 1 to 100        lngCtrlHWND = GetDlgItem(hWnd, lngCtrlId)        strWindowText = String(80, Chr(0))        SendMessage lngCtrlHWND, WM_GETTEXT, 100, ByVal strWindowText       Next lngCtrlId              As an example, if you open Notepad and type "Test" in Notepad's edit       screen, my program will find the string "Text" since I already know       that the ID of Notepad's edit screen is 15. But if I didn't know the       ID is 15, I would need to loop through all possible values until I       reached 15 and my program would then find the text. But an ID can be       as high as the maximum number for the ID data type, and to run a loop       to such a high number for all windows running may cause enough of a       delay to be ineffective.              I've already tried using GetDlgID() as you and others suggested, but       using the Notepad example, it doesn't seem to return a value of 15 as       the ID for the Notepad edit screen.              I'm going on the assumption I'm missing something here so I still plan       to play around with these suggestions. Maybe I'm just not using these       functions properly or perhaps the method I've been using is the only       way?              Ideally, I would like to get a list of all control IDs from all       windows and then use the ID and the hwnd values to grab the text from       each using SendMessage.              Don       On Sun, 7 Dec 2008 14:14:33 +1100, "Bill McCarthy"        |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca