News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Retrieving a DlgCtrlID

Started by brixton, June 04, 2006, 04:03:00 PM

Previous topic - Next topic

brixton

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
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

KSS

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.

brixton

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
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

brixton

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!
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

KSS

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!