Original Post
🔒 Locked
Child Windows
Advertisement
Im not sure if I know what you want to do, but if you want this:>
Then you should just create one main window and two child windows. And the child windows you just place next to eachother. And in the main window procedure, you wait for the WM_SIZE message, and when it comes you resize the child windows...
[edited by - pag on May 11, 2003 11:11:47 AM]
[edited by - pag on May 11, 2003 11:20:06 AM]
-------------------- -----------------------
| | | | |
| | | | |
| Main Window | look like this:> | Win1 | Win2 |
| | | | |
| | | split-> | |
| | | | |
-------------------- -----------------------
Then you should just create one main window and two child windows. And the child windows you just place next to eachother. And in the main window procedure, you wait for the WM_SIZE message, and when it comes you resize the child windows...
HWND mainWnd;
HWND childWnd1;
HWND childWnd2;
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
{
case WM_SIZE:
int width = LOWORD(lParam);
int height = HIWORD(lParam);
SetWindowPos(childWnd1, NULL, 0, 0, width/2, height, 0);
SetWindowPos(childWnd2, NULL, width/2, 0, width, height, 0);
break;
}
return DefWindowProc(hWnd, uiMsg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// You should replace these and just register the classes
RegisterMainWindowClass();
RegisterChildWindowClass();
// create the main window
mainWnd = CreateWindow( lpszMainWndClass,
"My Game Editor",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
GetModuleHandle(NULL),
NULL );
if(!mainWnd) return 0;
// create the child windows
childWnd1 = CreateWindow( lpszChildWndClass,
NULL,
WS_CHILD | WS_VISIBLE,
0,
0,
640/2,
480,
mainWnd,
NULL,
GetModuleHandle(NULL),
NULL );
// and do the above again for the next window...
// ....blalbllal
ShowWindow(mainWnd, SW_SHOWNORMAL);
UpdateWindow(mainWnd);
// handle messages>
MSG msg;
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
[edited by - pag on May 11, 2003 11:11:47 AM]
[edited by - pag on May 11, 2003 11:20:06 AM]
I have to register the child class also? doesn''t this mean that the child class has to have its own WinProc? Does the child window also have to have its own hInstance? I thought that the child window would just inherit all the functionality of the main window. If so, wouldn''t a call to CreateWindow just simply create the child window?
And what is the function ''GetModuleHandle'' for?
Thanks again.
And what is the function ''GetModuleHandle'' for?
Thanks again.
quote:
doesn''t this mean that the child class has to have its own WinProc?
yes
quote:
Does the child window also have to have its own hInstance?
no, you only get 1 hInstance when you create the program.
doh, nuts. Mmmm... donuts
My website
quote:
And what is the function 'GetModuleHandle' for?
This function returns a HINSTANCE, the same HINSTANCE that is passed by the WinMain function. A HINSTANCE is what you could say is a handle or an id of the application. If you open five instances of your application, each one of them would have a unique HINSTANCE.
I simply used this function instead of taking the HINSTANCE from the WinMain paramters. It's an old habbit as I usually dont create my windows in the WinMain function and don't like passing a HINSTANCE parameter to the functions that does...
You should get the "Win32 Reference" and look up these things yourself, as it's a great way learning things...
[edited by - pag on May 11, 2003 9:40:17 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement