VBFindID Documentation Introduction: Visual Basic provides no way to determine or define the IDs of Controls in VB forms. There are several API calls that require that the ID of a child control be supplied, for example SendDlgItemMessage, SetDlgItemInt, DlrDirList, etc. The IDs of controls can be determined during run time by going through a series of SetFocus and API calls, e.g. aControl.SetFocus id_aControl = GetDlgCtrlID(GetFocus()) bControl.SetFocus id_bControl = GetDlgCtrlID(GetFocus()) Even though this method will determine the ID of a control it can only be implemented once a form is shown (or during Form_Paint) and will not work with VB Labels since SetFocus flags these. There are many instances when knowing the ID of a label can be useful, e.g. with API's DlgDirList function. VBFindID is a small WinApp I wrote in Turbo Pascal for Windows (for compactness). It can be used to determine the IDs of VB Controls (including Labels) during development of your VB Apps. Knowing the IDs before hand saves you from having to determine control IDs during run-time and allows you the flexibility to use several API calls during the Form_Load procedure without having to show the form and go through a series of SetFocus statements. Also, it's the only way I know of to get the IDs of VB labels. Using VBFindID: I've installed VBFindID as a Program Item under the Languages Group. This way I can quickly start it whenever I need to use it with a VB project. Even though VBFindID was written as a VB utility, it will find the IDs of any legitimate Windows control. Additionally, it reports the current hWnd handle of the control (useful only for debugging since this changes all the time), the Class Name of the control, and finally the control's caption. After you start VBFindID, click on the "Find ID" button to start the search. VBFindID loads its own cursor which looks like a frame. The center of the frame is the cursor's hot spot. Move the VBFindID custom cursor over the control whose ID you wish to determine so that the center of the cursor is over a portion of the control. You'll notice VBFindID updates its report label as you move the frame cursor around. If you want to find the ID of a button, place the frame cursor over the button on the window you are researching. If you want to find the ID of a Label place the cursor over the Label. Do the same for listboxes, combo boxes, option buttons, etc. Make a note of the IDs you're planning on using in your App and press the right mouse button (or Escape) to stop the search. To end the VBFindID session, click on Quit. Visual Basic and Control IDs: VB assigns IDs to controls during design time. The first control is assigned ID: 1, and the IDs are incremented with each control added to the form (the second control's ID will be 2, the third's 3, etc). If this ID order was always the case, there would be very little need for VBFindID since you could make a note of which control you created first, second, third, and so forth, and immediately know the ID order of your controls. Running VBFindID in design mode this seems to be the case, but when you choose "Run" to run your form and inspect the IDs with VBFindID you'll discover that VB reorders the IDs in a left to right, top to bottom order. So, if your first control was placed at the bottom left corner it may have an ID of 1 during design time but an ID of 5 during run time. You may be wondering: if this is the case then it's hopeless to be able to accurately determine IDs without the SetFocus/GetFocus routines. There's good news: Once you design your form to your satisfaction, save the form. When the form is saved the IDs are set for good. Now, load the form and "Run" it along with VBFindID. Make a note of the IDs of the controls you need and you're all set. If you add or delete controls during development then simply go through the same steps to determine the correct ID assignments. About the ID demos: IDDEMO.MAK is the Shell for two demos: IDOPEN and IDOTHER. IDOPEN is a simple Win3 style File Open dialog without an Edit control. It uses DlgDirList and DlgDirSelect as examples of using IDs with VB forms. IDOTHER demos using SetDlgItemInt, SetDlgItemText, SendDlgItemMessage, GetDlgItemInt, GetDlgItemText, and GetDlgItem. Questions/Comments: If you have questions or comments you may reach me via CIS mail at 73667,1755 or on the MSBASIC forum. Distribution: If you'd like to share VBFINDID with your friends and colleagues or upload it to a BBS you may do so only in the form of the original ZIP archive containing VBFINDID.EXE, VBFINDID.TXT, IDDEMO.MAK, IDDEMO.FRM, IDOPEN.FRM, and IDOTHER.FRM. Of course, don't charge anything for VBFINDID or the docs and demo files. Enjoy, Costas Kitsos October 1991