Archived

This topic is now archived and is closed to further replies.

Squeejee

Child Window

Recommended Posts

Guest Anonymous Poster
In the call to CreateWindow/CreateWindowEx one of the parameters specify the HWND of the new window''s parent-window. Also, take a look at the WS_CHILD, WS_CLIPCHILDREN and WS_CLIPSIBLINGS window styles (probably a few more, but those are all I can think of right now).

Share this post


Link to post
Share on other sites
This is what I got:

    
WNDCLASSEX winclass;
HWND hwnd;
HWND hwndc;
MSG msg;

winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = "WINCLASS1";
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

RegisterClassEx(&winclass);

//CREATE WINDOW

if(!(hwnd = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"Enchiten",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
640, 480,
NULL,
hwndc, <---------------- ERROR
hinstance,
NULL)))
return 0;

if(!(hwndc = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"EnchitenChild",
WS_OVERLAPPED | WS_VISIBLE | WS_CHILD | WS_CHILDWINDOW | WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
300, 150,
hwnd,
NULL,
hinstance,
NULL)))
return 0;


It gives me this error:
error C2664: 'CreateWindowExA' : cannot convert parameter 10 from 'struct HWND__ *' to 'struct HMENU__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Edited by - Squeejee on November 4, 2001 3:09:21 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Umm... You seem to be a little confused as to how it''s supposed to work. In your call to create ''hwnd'' you specify that ''hwndc'' is to be it''s menu. This is clearly not right (it wouldn''t be correct do specify it as a child either because ''hwndc'' isn''t created yet).

What you want to do is:

1. Create window1
2. Create window2 passing window1 as the ''parent-parameter''

That''s the basics of it. You don''t need to do anything special when creating window1 (though you might want to set the WS_CLIP_CHILDREN and/or set WS_CLIPSIBLINGS for the child window).

Share this post


Link to post
Share on other sites