The GetDlgCtrlID API, when passed a valid hWnd, returns a value that directly corresponds to the Index property of the Controls collection:
Private Declare Function GetDlgCtrlID Lib "user32" _ (ByVal hWnd As Long) As LongPrivate Sub Form_Load() Dim i As Long On Error Resume Next For i = 0 To Controls.Count - 1 Debug.Print Controls(i).Name, Debug.Print Controls(GetDlgCtrlID(Controls(i).hWnd) _ - 1).Name Next iEnd Sub
This loop, located in the Form_Load event of a form with a number of controls on it, loops through all the controls and prints the name of each windowed control twice, demonstrating that it has correctly located the control without looping through the control collection.
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
Related Posts
- Tupperware considers shutdown amid financial crisis
- New Flexera Software App Portal Release Adds Support for Cloud & Apple?? Mac Apps, and ROI Dashboard – Extending Enterprise App Store Leadership
- DeltaXML Merge Version 4.1 brings richer functionality and improved usability to enhanced authoring and reviewing
- The Big Data Illusion
- Building Javadocs from the Command Line























