티스토리 뷰

프로그래밍/API

API 기본 코드

문정환 2008. 5. 6. 10:30
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("First");
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
                  ,LPSTR lpszCmdParam,int nCmdShow)
{
        HWND hWnd;
        MSG Message;
        WNDCLASS WndClass;
        g_hInst=hInstance;
       
        WndClass.cbClsExtra=0;
        WndClass.cbWndExtra=0;
        WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
        WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
        WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
        WndClass.hInstance=hInstance;
        WndClass.lpfnWndProc=WndProc;
        WndClass.lpszClassName=lpszClass;
        WndClass.lpszMenuName=NULL;
        WndClass.style=CS_HREDRAW | CS_VREDRAW;
        RegisterClass(&WndClass);

        hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,
                CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
                NULL,(HMENU)NULL,hInstance,NULL);
        ShowWindow(hWnd,nCmdShow);
       
        while (GetMessage(&Message,NULL,0,0)) {
                TranslateMessage(&Message);
                DispatchMessage(&Message);
        }
        return (int)Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
        switch (iMessage) {
        case WM_DESTROY:
                PostQuitMessage(0);
                return 0;
        }
        return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함