child win creation in a MDI fails using CreateWindowEx

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

Previous topic - Next topic

baltoro

... Rant,...Continued,...
I always avoided the MDI interface, because the various message loops are so easy code so that they are completely dysfunctional.
So, I would go to great lengths in my programs to display data on the screen with simple graphics functions, like the TextOut Function. It's tedious to code, but, very reliable. Or, write a bunch of diagnostic data to a text file.     
With interdependent message queues, you don't really know what is occurring, unless you have some sort of visible graphic event being fired for every message (and, this is completely impractical). And, I'm assuming that the whole reason Windows has the MDICLIENT window class is just to manage the message loops without programmer interference.
Baltoro

dedndave

well - i got almost everything working
window menu - accelerators - cascade/tile - all that

i am stumped, for the moment on one last item
that is....
when i select a different window in the window list, it does not activate and the list is not updated
i notice that Hutch's example is the same way
the xxControls example works correctly, but i can't figure out why
that thing has owner-drawn menus and a lot of the code is in a LIB
a little more reading should get it going   :P

baltoro

...Welll,...I was wrong about everything else, but,... :eek
I'm absolutely certain that you send a WM_MDIACTIVATE Message to the Client Window.
Once, you've got the structure correct,...the whole MDI thing is message driven.
Here is a list of the standard MDI messages: MDI Messages, MSDN

From the MSDN documentation for Using the Multiple Document Interface:
"When a child window's title is added to the window menu, the system assigns an identifier to the child window. When the user clicks a child window's title, the frame window receives a WM_COMMAND message with the identifier in the wParam parameter. You should specify a value for the idFirstChild member that does not conflict with menu-item identifiers in the frame window's menu."

Hutch's example handles the WM_COMMAND message with a message box instead of activating the child window.
Baltoro

dedndave

#48
i wish i could tell you how right you are   :(

but - alas - the automatic window list works all by itself
the problem was disguised by the nature of IF/ELSEIF/ENDIF blocks
i hate those things - and i kept them in there where i thought it was appropriate
that is a real stretch for me - lol
anyways - when processing the WM_COMMAND message, i always return 0
it's like - if it isn't in my list, it's done
for the MDI frame WndProc, you have to use the default proc for unhandled commands or it won't do the child windows/window list

at any rate, here we go
i added a manifest file, version control block, an icon - all the goodies
with a little scroll and size code (and something to open and paint documents - lol), you have a full-blown app   :U
oh - i did a lot of cleanup - hope i didn't toss out something you liked - lol

by the way - Hutch's MDI example has the same problem i had
i bet it would work right with a simple change   :U

OOPS - left out a couple members of MDICREATESTRUCT

dedndave

got Hutch's example to work   :U

dedndave

i updated Mdi.zip in the post above
i left out a couple members of MDICREATESTRUCT   :red

dedndave

i got this one down to 4.5 Kb   :8)

i could probably get it down to 4.0 Kb by creating the menu in code and reducing the version control block
it's good enough  :P


dedndave


baltoro

Yeah,...Dave !!!
Impressive analytical skills,...
I noticed when reading xandaz's Device Contex thread,...that he and QWORD have a working example of a MDI graphics application here: xandaz_paint
Baltoro

dedndave

yah - xandaz has been working on that for a while
i suppose we could have used it as an example   :P
the one that i finally did learn from was..........


Iczelion #32   :U

but, it could have been anyone's
i just happened to notice the WndProc exit strategy

xandaz

   Hey... can i post my mdi example. Works very well. Thx

dedndave


xandaz

    hey... has anyone ever done menus in MDI Child windows? I just can't figure it out. I've tried set Menu, WM_MDISETMENU but doesn't show the menu bar. Can it be done? Thanks

xandaz

    I think it may not be doable. I read somewhere that windows only supports one menu per application.
http://bytes.com/topic/c-sharp/answers/234060-mdi-child-menu