Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

Comments

  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    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".
    [code]
    case WM_CLOSE:
    SendMessage(hwnd, WM_DESTROY, 0, 0);
    return 0;
    [/code]
    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.

    *EDIT*

    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.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
Sign In or Register to comment.