0

i'm learning win32 from: http://www.winprog.org/tutorial/start.html

but tell me(because i ear several persons) is these function correct?

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

the DefWindowProc() is on right place or must be outside of switch?
pleace anyone correct me

2
Contributors
2
Replies
20
Views
3 Years
Discussion Span
Last Post by cambalinho
0

the DefWindowProc() is on right place

Maybe, depending on what you want the program to do after the switch(). Probably in most cases it should be like below. But that won't work if there is more code to add after the switch.

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

Edited by Ancient Dragon

0

i see.. if i need more than that switch, i continue with my code. if not, i can use your code.. .thanks for all
(that tutorial don't explain that)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.