The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: brixton on June 04, 2006, 04:03:00 PM

Title: Retrieving a DlgCtrlID
Post by: brixton on June 04, 2006, 04:03:00 PM
Hey all,

I have a need to retrieve the ID of a control in a dialog box.  I have the dialog window handle and I know the text in the control that I need the ID of.
I used Spy++ and saw the ID changes each launch, which I didn't know happened.  Wondered if there was an API I overlooked that can help me find this button's ID.

Thanks in advance!

-brixton
Title: Re: Retrieving a DlgCtrlID
Post by: KSS on June 04, 2006, 06:27:44 PM
Hey, Brixton! :bg
You can use this:
1. FindWindowEx() — The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search.
2. GetDlgCtrlID() — The GetDlgCtrlID function retrieves the identifier of the specified control.
Title: Re: Retrieving a DlgCtrlID
Post by: brixton on June 04, 2006, 06:37:34 PM
Hey KSS and thanks for the reply!

QuoteYou can use this:
1. FindWindowEx() — The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search.

Can I use FindWindowEx for a control?  Cool!

Thanks, I'll give it a go,

-brixton
Title: Re: Retrieving a DlgCtrlID
Post by: brixton on June 04, 2006, 11:40:04 PM
Hey thanks, I have it now working completely fully!  There is a window and when I CreateProcess it, I needed to get the window handle of its child which is always sitting 'on top' of it, and then find a specific button and send a click to it.  So I produced the following which works:

...
mov handle, eax
  push 3
  push handle
call GetWindow
mov handle, eax
  push OFFSET lpszWindow
  push OFFSET classname
  push NULL
  push handle
  call FindWindowEx
  push eax
  call GetDlgCtrlID
  push NULL
  push NULL
  push 0F5h
  push eax
  push handle
  call SendDlgItemMessage
...


Thanks for the help!
Title: Re: Retrieving a DlgCtrlID
Post by: KSS on June 05, 2006, 07:15:17 AM
QuoteCan I use FindWindowEx for a control?  Cool!
Any control (buttons, edits, etc.) is a WINDOW, but subclassed by Windows (It not really true, but for simplest understand it true)

SDK for Windows are such as Bible for people!