The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Guenther on January 14, 2012, 02:04:08 PM

Title: Getting the Handle of a (child)-window, that is created with a resource
Post by: Guenther on January 14, 2012, 02:04:08 PM
Hallo!

Maybe this is a silly question, but i don't want to write programs with try and error, i want to understand it:

If i create a window with "CreateWindowEx" in the sourcecode, i get the handle as a return value in eax. But if i create a window with a resource file and "DialogBoxParam", where is the handle?

I am working at tutorial 12 from Iczelion (file input and output), but i would like to create the main window with a resource, because i would like to add some checkboxes and autoradio-buttons later and this is easier, i think, if i write it with a resource. The other option is to write everything in the source code, there is a good example from Bill Cravener how to do this. All right, i will try to write all the checkboxes and autoradio-buttons in the source code now, but i would be happy, if anyone of you can tell me something about handles and windows created with a resource.

Thanks for answers!

Guenther
Title: Re: Getting the Handle of a (child)-window, that is created with a resource
Post by: Vortex on January 14, 2012, 02:09:02 PM
The API function GetDlgItem :

QuoteThe GetDlgItem function retrieves the handle of a control in the specified dialog box.

Title: Re: Getting the Handle of a (child)-window, that is created with a resource
Post by: Vortex on January 14, 2012, 02:23:53 PM
Here is a quick example for you :


.
.
start:

    invoke  GetModuleHandle,0
    invoke  DialogBoxParam,eax,ADDR DlgBox,0,ADDR DlgProc,0
    invoke  ExitProcess,eax

DlgProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

    .IF uMsg==WM_INITDIALOG

        invoke  GetDlgItem,hWnd,IDC_EDIT
        invoke  SetWindowText,eax,ADDR text1
.
.
Title: Re: Getting the Handle of a (child)-window, that is created with a resource
Post by: Guenther on January 14, 2012, 02:50:54 PM
Thanks!
Title: Re: Getting the Handle of a (child)-window, that is created with a resource
Post by: xandaz on January 15, 2012, 01:12:27 AM
   ...and then again if it's the the dialog you mean, it's hWnd memmber. Reffer it in invokes from inside the DialogProc and also remember to:
.if uMsg==WM_INITDIALOG
    push   hWnd
    pop    MyDialogHandle

...just in  case you need the handle from outside the DialogProc.