I'm having a bit of difficulty getting a handle on a concept I'm working on.
First let me preface by saying that I'm experienced at C programming (not C++). Mainly Console Mode (not GUI) programming. So, when it comes to Windows GUI programming I'm a complete novice.
What I would like to do is a bit different from the usual Windows GUI app, where to open a window you have a WinMain() followed up by a WinProc() for that window to handle callbacks.
The usual one for one, if you will, (one WinMain -> one window -> one WinProc).
What I'd like to do is have a generic "WinMain" type of function for registering a single WNDCLASS and a generic "WinProc" template for handling callbacks for subsequent windows opened using the already registered WNDCLASS.
I can register a WNDCLASS and using the same lpszClassName parameter and open multiple windows, using different MenuNames.
followed by:Code:wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndClass.lpfnWndProc = WndProc; wndClass.hInstance = hInstance; wndClass.hCursor = LoadCursor(hInstance, IDC_ARROW); wndClass.hIcon = LoadIcon(hInstance, IDI_APPLICATION); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndClass.lpszClassName = szAppName; RegisterClass(&wndClass)
and later, followed by:Code:hwnd1 = CreateWindow(szAppName, "MyWindow1", ...,);
This displays two windows.Code:hwnd2 = CreateWindow(szAppName, "MyWindow2", ...,);
However, when I close either one of the windows, it closes both windows.
Clearly I'm missing something here.
The Platform SDK suggests (or at least that's my impression) that it can be done, but, I haven't found the right example to understand how to make it work.
Maybe someone here understands how to do this.Each window class has an associated window procedure shared by all windows of the same class. The window procedure processes messages for all windows of that class and therefore controls their behavior and appearance.