WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: JTaylor on March 14, 2021, 02:16:52 PM

Title: @dchWnd Back to Control Name or Number
Post by: JTaylor on March 14, 2021, 02:16:52 PM
If I have the Windows Handle of a control is there a way back to the Control Name or Number?   This seems like I am missing the obvious but that is what I excel at so thought I would ask.

Jim
Title: Re: @dchWnd Back to Control Name or Number
Post by: td on March 14, 2021, 03:48:27 PM
The question begs for another question but ignoring the urge.  You could do something like the following in a Dialog Callback:

Code (winbatch) Select
            nCtlNum = DllCall('User32.dll',long:'GetDlgCtrlID', long:hWnd) - 99
            strCtlName = dialogProcOptions(MyDialog_Handle, @dpoCtlName, nCtlNum)
            Message('Control Name', strCtlName)
Title: Re: @dchWnd Back to Control Name or Number
Post by: JTaylor on March 14, 2021, 05:22:24 PM
If my latest crazy idea works out I am guessing your question will be answered at some point in the near future  :)

That's right...should have thought of this.   Thanks. 

Jim
Title: Re: @dchWnd Back to Control Name or Number
Post by: td on March 15, 2021, 09:31:19 AM
The above 3 lines are not guaranteed to work.  Dialog templates that have GroupBoxes or have tab orders that do not match the order of the control in the dialog template can cause control IDs to differ from control numbers.
Title: Re: @dchWnd Back to Control Name or Number
Post by: JTaylor on March 15, 2021, 10:07:57 AM
Understood.  Thanks again for the reminder.   I knew this at one point but had been awhile since I had used this method and it had slipped my mind.

Jim