I am using Windows XP 32-bit, VC++ 2008 with OpenGL and the Windows API.
When I run my program, it seems to work fine, but whenever I click anywhere on the title bar of the window, the program exits. I have no idea where to start to look for the source of this so I cannot post source code at the moment. What could be the cause of this ?
I'm not familiar with OpenGL, but I agree with taking a closer look at WM_SIZE as clicking in the non-client area and moving the mouse does trigger WM_SIZE. Most debuggers will allow you to trap an event based on the contents of register or memory, so catch the entry to WM_SIZE and see if it is triggered and single step to follow its path.
Okay, I looked in my message handler, and when I click on the titlebar, the message '32' is sent to my program, this means WM_SETCURSOR. This is the only message that it sends me before it closes. My handler doesn't handle this so it gets passed to DefWindowProc. What does WM_SETCURSOR mean? I might try and make it handle that message and see what happens.
EDIT: I made it handle that message, and the same thing happens.
I looked and it seems that I overlooked a part of my code. When I click on anywhere in the title bar (not the exit button) it seems that the WM_CLOSE message is being sent to my program for some reason.
>> it seems that the WM_CLOSE message is being sent to my program for some reason.
Your WM_SYSCOMMAND handling needs fixing. As of now, any WM_SYSCOMMAND with wParam not equal to SC_SCREENSAVE or SC_MONITORPOWER falls through to the next case, ending up in a PostQuitMessage (0); call.