Win32 API programming problem

I recently started Windows programming after my c++ courses. I bought a book called Programming Windows 5th edition, and started full of confidence and joy. The problem is now that one of the first and easiest examples in the book, that of a basic win32 window which draws a bit of text doesn't work. Well it works, but if i pres F5 to debug it it doesn't paint any text and if I click the X to close the window the window closes but it doesn't unload, i stays in debugging mode, and if i use the release version I can still see it running in processes tab, and it takes a hell lot of processing power (25% on my 3.6GHZ Q6600). I have no idea what the problem is, maybe someone can help me?

P.S. i have Unicode enabled in the project properties


  • SephirothSephiroth Fayetteville, NC, USA
    To handle clicking the X, you must handle the "WM_CLOSE" message. I handle it as pasted below. You do this because in XP and later, the X sends the "WM_CLOSE" message, not "WM_DESTROY".
    case WM_CLOSE:
    SendMessage(hwnd, WM_DESTROY, 0, 0);
    return 0;
    You could also simply call "PostQuitMessage(0)" instead of "SendMessage()". Either way, that will fix the problem of the program staying in memory when you click the X.

    I'll look at the code after Hancock (DVD) and help you with the paint problem.


    Wait, have you tried dragging or sizing the window to see if it paints it? You have to make Windows send the WM_PAINT message or that code never gets called. Try dragging or sizing the window and see if it draws.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion