|
-
Dec 14th, 2001, 04:38 PM
#1
Dialog Resource vs. Window creation
I'm working on some project now, and I'm using dialog-type resources to create the windows for the project.
Besides the fact that I didn't find a way to create MDI windows (or is just the VB term for it?) using the dialog resource, are there any disadvantages in using the resoucre instead of creating the window using CreateWindow*CreateWindowEx?
BTW, can anyone instruct me on how to create MDI windows using Win32 API?
Thanks.
-
Dec 15th, 2001, 07:55 AM
#2
It is not possible to create MDI windows using dialog resources. I'm not sure if there are any general disadvantages of dialogs vs. normal windows. After all, they are windows. So you could maybe even create a MDI window out of a dialog resource, but it would require custom code and would not be easier than just creating it from scratch.
Here's how to create MDI apps, as teached in the Petzold:
You need to register several window classes: one for the main window and one for each child window. You should choose
(HBRUSH)(COLOR_APPWORKSPACE + 1)
as HBRUSH member of the WNDCLASS of the frame window.
You first create the frame window like you would do with any other window. It is important that you specify the WS_CLIPCHILDREN style. In the window's WM_CREATE handler you create a new window of the class "MDICLIENT". It should have the styles WS_CHILD, WS_VISIBLE and WS_CLIPCHILDREN. The position and size do not matter. You must pass the address of a completly filled out CLIENTCREATESTRUCT as lParam.
This window is the key to all MDI business. You send messages to it to control the child windows. The most important is WM_MDICREATE, which tells the client to create another child. You pass the address of a MDICREATESTRUCT as lParam.
These are the main parts of creating a MDI app. For more information, see
Platform SDK -> User Interface Services -> Windowing -> Multiple Document Interface
in MSDN.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 15th, 2001, 08:32 AM
#3
Oh, and I forgot, you also need to change your message loop:
Code:
while(GetMessage(&msg, NULL, 0, 0) > 0)
}
if(!TranslateMDISysAccel(hwndMDIClient, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Also, you don't call DefWindowProc anymore. Call DefFrameProc for the frame window and DefMDIChildProc for the child windows instead. MSDN also lists some messages that must be passed on whether you handle them or not.
Also there are alternatives (necessary ones in multithreaded apps) to the WM_MDICREATE message: CreateMDIWindow and CreateWindowEx with the WS_EX_MDICHILD extended style.
Last edited by CornedBee; Dec 15th, 2001 at 08:42 AM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 15th, 2001, 01:22 PM
#4
Thanks, that's exactly what I needed!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|