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

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);
}

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.