Child Window
I know how to make two windows for and app, but how do you make one of the windows a child to another? Do you use the same windows class?
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).
This is what I got:
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
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 WINDOWif(!(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
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).
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement