Hey,
I'm not sure if I put my stuff correctly in the message loop(Render()): while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
becouse when I close the window I get an error from the MessageBox function above. Probably becouse when I'm handling messages before rendering the window is firstly destroyed and then DirectX doesn't have a window to draw on. When I put my Render() function above translating and dispatching messages I don't get the error, but mostly people advise to handle messages before doing anything else?This is how I'm handling messages to close window:
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_CLOSE:
DestroyWindow( hwnd );
break;
So for normal (for example Ms Paint, Word) programs, the message loop should use GetMessage() function in order to pick messages? And where should be done rendering in such message loop?
Most "normal" programs redraw the client area in their WM_PAINT handler, since this message is sent to notify the app that a portion of the client area needs to be redrawn for some reason (for instance, if a portion of the client area was obscured by another window but is now visible).
A good portion of apps won't even explicitly draw anything manually...they'll just use common controls (buttons, scrollbars, listview's, etc.) that can handle drawing themselves.