The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: drjr on July 19, 2007, 12:58:15 PM

Title: control handle
Post by: drjr on July 19, 2007, 12:58:15 PM
I have a ie: combobox, or static in a form and I want to know its handle. How can I do that.

   I have the following code

   invoke SendMessage,hWin,WM_SETTEXT,0,ADDR Mytext

Here hWin is the handle´s ie: textbox, but I don`t know how to get that hWin value.

    regards.

Title: Re: control handle
Post by: ragdog on July 19, 2007, 01:06:18 PM
hi drjr

you can get the handle from a window or any form with a spy tool
i like spy++ from visual studio or windowshack

greets
ragdog

[attachment deleted by admin]
Title: Re: control handle
Post by: SideSwipe on July 19, 2007, 02:20:53 PM
Hello:

To get the handle to any control on a dialog box form you must know its ID number. Then use the GetDlgItem API function to retrieve the handle like this:

.const
COMBOBOX1 equ 1000 ; this is the combobox control ID

.data?
hCB  dd  ? ; storage variable for the combobox handle that you wish to get

.data
Mytest db "this is a test",0

invoke GetDlgItem,hWin,COMBOBOX1 ; get the handle to the combobox, hWin in this case is the handle of the dialog box or form that houses the combobox control.
mov hCB,eax  ; save the handle for later use.

invoke SendMessage,hCB,WM_SETTEXT,0,ADDR Mytext

Regards,
SS

Title: Re: control handle
Post by: Jackal on July 19, 2007, 10:07:52 PM
if your using CreateWindowEx or CreateWindow you would do it like this.


      invoke CreateWindowEx,NULL,ADDR Static, NULL,WS_CHILD+WS_VISIBLE, 5, 110, 242, 15,hWnd,2,hInstance,NULL
      mov hStatic,eax