【Win32】Windows

时间:2014-05-01 05:08:48   收藏:0   阅读:477
mamicode.com,码迷
#include <windows.h>

LRESULT CALLBACK WindowProc(
    HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

int CALLBACK WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
{
    static TCHAR lpClassName[] = TEXT("Susake");

    HWND hwnd;
    MSG msg;
    WNDCLASSEX wincl;

    wincl.cbSize = sizeof(WNDCLASSEX);
    wincl.style = NULL;
    wincl.lpfnWndProc = WindowProc;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hInstance = hInstance;
    wincl.hIcon = NULL;
    wincl.hCursor = NULL;
    wincl.hbrBackground = NULL;
    wincl.lpszMenuName = NULL;
    wincl.lpszClassName = lpClassName;
    wincl.hIconSm = NULL;

    RegisterClassEx(&wincl);

    hwnd = CreateWindowEx(0,
        lpClassName,
        TEXT("Susake"),
        WS_OVERLAPPEDWINDOW,
        0, 0,
        800, 600,
        HWND_DESKTOP,
        NULL,
        hInstance,
        NULL);

    ShowWindow(hwnd, nCmdShow);

    UpdateWindow(hwnd);

    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    UnregisterClass(lpClassName, wincl.hInstance);
    return msg.wParam;
}
mamicode.com,码迷

 

【Win32】Windows,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!