-
msg loop/child window
Just starting learning the win32 API last night and I was wondering if I wanted to create a child window... like the one you'd get if you went to Help->About if I need to create a new class style. That would only be if I wanted to new class style traits for it right? I should be able to use the global variable which has the class name right?
Basically, what I think I need to do is create a new window, and a new WinProc for that window but I can still use the old window class? If I do that will my message loop in WinMain get the messages coming from that window too?
-
you are right, you only should need a separate class for windows that require different class styles n such, not window styles. However for simple windows like about boxes, you can use a modal dialog box to save a lot of extra code. If using msvs the dialog editor makes it a simple process ).
DialogBox Function
-
Ok, well I'm trying to create a child window without using .rc just to get to know somethings a bit better. MSDN says
HWND WINAPI CreateDialog(
__in_opt HINSTANCE hInstance,
__in LPCTSTR lpTemplate,
__in_opt HWND hWndParent,
__in_opt DLGPROC lpDialogFunc
);
Now, if using .rc I could MAKEINTRESOURCE(ID_HABOUT) my the lpTemplate parameter.
My question is can I create my template some other way? I found structs called DLGTEMPLATE and DLGITEMTEMPLATE but my problem is how to pass them in as LPCTSTR after filling them out.
Also how do I handle the messages in my message loop?
After some googling I found
IsDialogMessage(HWND,MSG)
Is that all I need to check for in my message loop?
Does DialogBox() handle the message loop automatically?
-
the message loop is provided by the DialogBox function, if you use CreateDialog ( modeless ) you will be using your own message loop. yes you can create a memory block and put a DLGTEMPLATE first then DLGITEMTEMPLATE members all in one contigious block, then pass the pointer of the block into the template paramater as
Code:
CreateDialog( myinst, ( LPDLGTEMPLATE ) myalloc, hwnd, dlgproc );
Creating a non-resource template has its own advantages, but a waste of time for simple dialogs. an unfinished resource can quickly be loaded, then in the WM_INITDIALOG message, creation of variable controls can be done with a few CreateWindow calls