Getting the Handle of a (child)-window, that is created with a resource

Started by Guenther, January 14, 2012, 02:04:08 PM

Previous topic - Next topic

Guenther

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

Vortex

The API function GetDlgItem :

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


Vortex

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
.
.


xandaz

   ...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.