So, I figured by TeaTreeTim's reply that I probably should do the test to see if both windows are closed inside the WM_DESTROY case. So here is just both of my WindowProc's.
LRESULT CALLBACK WindowProc0(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT ps; // used in WM_PAINT
HDC hdc; // handle to a device context
// what is the message
switch(msg)
{
case WM_CREATE:
{
// do initialization stuff here
// return success
return(0);
}
break;
case WM_PAINT:
{
// simply validate the window
hdc = BeginPaint(hwnd,&ps);
// you would do all your painting here
EndPaint(hwnd,&ps);
//return success
return(0);
}
break;
case WM_CLOSE:
{
hwnd0Closed = true;
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
{
// test if both windows are closed
// if so program closes.
if (hwnd0Closed && hwnd1Closed)
{
PostQuitMessage(0);
return(0);
}
}
break;
default:break;
} // end of switch
// process any messages that we didn't take care of
return(DefWindowProc(hwnd, msg, wparam, lparam));
} // end of WinProc
LRESULT CALLBACK WindowProc1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT ps; // used in WM_PAINT
HDC hdc; // handle to a device context
// what is the message
switch (msg)
{
case WM_CREATE:
{
// do initialization stuff here
// return success
return(0);
}
break;
case WM_PAINT:
{
// simply validate the window
hdc = BeginPaint(hwnd, &ps);
// you would do all your painting here
EndPaint(hwnd, &ps);
//return success
return(0);
}
break;
case WM_CLOSE:
{
hwnd1Closed = true;
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
{
// test if both windows are closed
// if so program closes.
if (hwnd0Closed && hwnd1Closed)
{
PostQuitMessage(0);
return(0);
}
}
break;
default:break;
} // end of switch
// process any messages that we didn't take care of
return(DefWindowProc(hwnd, msg, wparam, lparam));
} // end of WinProc
This works like I want it to now. The program does not close until both windows are closed.