News:

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

child win creation in a MDI fails using CreateWindowEx

Started by Rainstorm, August 03, 2011, 11:31:05 PM

Previous topic - Next topic

Rainstorm

Hi,

Am trying to create a child window in a MDI using CreateWindowEx but i get a '1400' error 'invalid window handle'.
The handle supplied to the child window is the client win handle, & I've tested the return on the clientwindow & it seems to return a valid handle
the code displays the client win handle & the error code after the childwin creation call

Thanks.
~

dedndave

http://msdn.microsoft.com/en-us/library/ms644923%28v=vs.85%29.aspx

i think the problem may be related to using MDIS_ALLCHILDSTYLES with CreateWindowEx

you should be able to create it with CreateWindowEx
but, you have to thoroughly review the docs for WNDCLASSEX and CreateWindowEx   :P
you may be missing a flag somewhere

dedndave

if you google around a bit, you can find a zip called "xxControls"
lots of cool stuff in there

they have an example of an MDI...

main window
    invoke CreateWindowEx, NULL, ADDR szClassMain,
                          ADDR szDisplayName,
                          WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN,
                          CW_USEDEFAULT,0,CW_USEDEFAULT,0,
                          NULL,hMenu,
                          hInstance,NULL

child...
    invoke CreateWindowEx,WS_EX_CLIENTEDGE,
                          ADDR szClassMDI,NULL,
                          WS_CHILD or WS_CLIPCHILDREN or WS_VISIBLE,
                          0, 0, 0, 0,
                          hWin,0,
                          hInstance,ADDR ccs

baltoro

Baltoro

Rainstorm

hi.

Quotehttp://msdn.microsoft.com/en-us/library/ms644923%28v=vs.85%29.aspx

i think the problem may be related to using MDIS_ALLCHILDSTYLES with CreateWindowEx

you should be able to create it with CreateWindowEx
but, you have to thoroughly review the docs for WNDCLASSEX and CreateWindowEx   Tongue
you may be missing a flag somewhere

just tried it without MDIS_ALLCHILDSTYLES, still the same thing. its not like its a hack either, since the SDK mentions using CreateWindowEx
microsoft says to use the WS_EX_MDICHILD when creating the child window with CreateWindowEx. and in the code you posted they use WS_EX_CLIENTEDGE.
I tried it though with WS_EX_CLIENTEDGE (& without WS_EX_MDICHILD).. but still the same problem. error code 1400 ....invalid windowhandle

also the code you posted as being the child win creation is probably the client window, cause in the last argument the pointer should be to a MDICREATESTRUCT & ccs seems to be the CLIENTCREATESTRUCT

Thanks~


baltoro

RAINSTORM,   
I was looking through an old MDI project that I did in C++, which I ran on Windows XP.   
Much of the code is similar, except that when I called CreateWindowEx to create my Client Window (as you did), I didn't use the MDIS_ALLCHILDSTYLES flag in my Window Styles, I or'd together: WS_CHILD, WS_CLIPCHILDREN, and WS_VISIBLE flags instead. Also, I zeroed out all the fields of the CLIENTCREATESTRUCT before setting the Menu ID and First Child ID. I don't know how MDIS_ALLCHILDSTYLES is defined. Where did you find the definition ???

UPDATE:
I had several different types of child windows: a Listbox and a DirectX device display. When I called CreateWindowEx for the Listbox, I passed the Window Handle of the Frame Window (NOT the Client Window, and I didn't use a MDICREATESTRUCT at all),...and, the Listbox displays OK in the client area of the Frame Window when the user makes a menu selection from the Client Window (the original Frame Window does not have a menu). The situation with the DirectX display was very different,...I passed the Window handle of the CLIENT Window to the initialiization routine (but, didn't use a MDICREATESTRUCT here either,...DirectX uses the CreateDevice call, to which I passed the Window Handle for the Client Window).
Baltoro

MichaelW

From WinUser.h in the PSDK:

/*
* MDI client style bits
*/
#define MDIS_ALLCHILDSTYLES    0x0001


And there is an explanation of what it does here:

http://msdn.microsoft.com/en-us/library/ms644910(VS.85).aspx

eschew obfuscation

dedndave

\masm32\examples\exampl02\mdidemo

i'll be damned   :bg
    invoke CreateWindowEx,WS_EX_MDICHILD,
                          ADDR cName,
                          ADDR mdiTitle,
                          MDIS_ALLCHILDSTYLES,
                          10,10,Rct.right,Rct.bottom,
                          hClient,NULL,hInstance,NULL


it looks like you're missing WS_EX_MDICHILD

from my original post....
Quoteyou should be able to create it with CreateWindowEx
but, you have to thoroughly review the docs for WNDCLASSEX and CreateWindowEx   :P
you may be missing a flag somewhere

ToutEnMasm

the class must be registered
Quote
;Frame      FRAME_DATA <>
   invoke Register_Frame      ;
;   -----------------------
   mov Frame.extstyles,WS_EX_LEFT
   mov Frame.styles,WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN

   invoke   CreateWindowEx,Frame.extstyles, ADDR Frame.Class, ADDR Frame.Titre, \
            Frame.styles , CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
            NULL,Frame.Hmenu,hInstance,NULL
   invoke   GetWindow,Frame.Hwnd, GW_CHILD
   mov   Frame.Hcliente,eax


Rainstorm

dedndave...
Quoteit looks like you're missing WS_EX_MDICHILD..
No, the WS_EX_MDICHILD style is in my code too.

QuoteI don't know how MDIS_ALLCHILDSTYLES is defined. Where did you find the definition ???
baltoro, the MDIS_ALLCHILDSTYLES, is supposed to enable additional window styles so that they can be used in a MDI


Rainstorm

ToutenAsm, just dloadd'ed your code & looking through it, it runs properly..... am looking to create the first child window on startup though.
can yuo say whats wrong with my code ?.. why its not working ?

ty

ps: nice demo : )

ToutEnMasm


I have made this code with an old sample that i have updated with the new method given by MSDN.
I have just seen in your code that you haven't call the register_mdi,what is a new thing.
There is other new things in the source,study it and you will find what is wrong.

Rainstorm

ToutenAsm,
i've been mainly reading from the sdk on my hard disk.. which is not the latest..
i've registered these two classes in my code

invoke RegisterClassEx, addr frame_wcl                 ; register the frame class
invoke RegisterClassEx, addr defchild_wcl                    ; register the default child window class


thx

EDIT:: just looked through the online docs too & it seems, stillgotta register just the frame & child classes, (the client class is a system class)

dedndave

Rainsrorm,
maybe you missed this one.....

click on the left button to create new mdi children

Rainstorm

looking through your code, not sure what am missing
are you able to create it on startup ?.. like without a button

ty