Can anybody tell me -exactly- how can I get the handle of the Main Window ?
I mean:

I have a process that creates a Window (Yeah, a classic Win Proggy). Now, that window creates a Dialog Box and that DIalog creates another one.
Ok, how can I get the Handle of the Main Window from the last dialog ?
Maybe you'll tell me ... OK, use the GetParent API... Hmmm didn't work and I dunno why, I pass the handle of the DialogBox as the argument and it always returns zero.
I also used the GetAncestor but again, didn't work for me...
Anyone have any idea ?

Thanx a lot for you guys. :alright:


-MagicMac.
Posted on 2001-10-17 23:37:12 by magicmac
My friend!!
Still haven't gone to bed?
Ok..
You can store the handle to the main window in a global variable, when processing the WM_CREATE message in the WndProc of the same main window.
ie:



DlgProc PROC USES ESI EDI EBX hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

CMP uMsg,WM_CREATE
JZ _create

(..sarazas..)

_create:
MOV EAX,hWnd
MOV MyGlobalVariable,EAX
RET



from then on, you can access that global variable which holds the main window's handle from any point in your code.
Hope that helps :)

See you next wednesday and let's hope the waitress gives me her bloody number..hehe
Or at least una tirada de goma :)


LatexX
Posted on 2001-10-18 00:22:55 by latigo
Thanks my Friend, but that wasn't what I was looking for, I wanna know how to get it. Actually I'm using what you said ovah there, but I have to know the other way with WinApi.
Posted on 2001-10-18 09:51:39 by magicmac
Obviously GetParent is the ideal way, but I suppose you could try FindWindow(Ex).
Posted on 2001-10-18 10:02:49 by lackluster
Are you setting the hwndParent/hwndOwner argument to the parent/owner window, when you create the dialog boxes?
Posted on 2001-10-18 22:21:47 by tank
Yeah, I'm passing that parameters ... I don't know what madafa s**t is happening ... Grrr...
Posted on 2001-10-19 08:47:29 by magicmac