Never check for messages in the message loop; ALWAYS check in the window procedure. The window procedure's mission in life is to respond to messages; this is where messages should be handled, without exception.
Originally posted by Hunter2
Oh shoot, I hate it when I do this sort of thing :rolleyes: Everything works fine and as expected if I check for WM_COMMAND and WM_CLOSE in the dialog procedure, although for some reason it doesn't work when I check in the message loop. The reason I checked in the message loop was to avoid using yet another global variable, but in this case I can't see how to avoid it :( Any ideas, or should I just get on with my life and leave the global variable there?