티스토리 뷰

#include <windows.h>
#include "resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass = "Menu";

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(hInstance, MAKEINTRESOURCE(IDI_ICON1);
    WndClass.hInstance = hInstance;
    WndClass.lpfnWndProc = WndProc;
    WndClass.lpszClassName = lpszClass;
    WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
    WndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    RegisterClass(&WndClass);

    hWnd = CreateWindow(lpszClass, TEXT("메뉴"),WS_OVERLAPPEDWINDOW,
         CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
         NULL, (HMENU)NULL, hInstance, NULL);
    ShowWindow(hWnd, nCmdShow);

    HACCEL hAccel;
    hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
    while(GetMessage(&Message, NULL,0,0))
    {
      if(!TranslateAccelerator(hWnd, hAccel, &Message))
       {
           TranslateMessage(&Message);
           DispatchMessage(&Message);
       }
    }
    return (int)Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
//    HDC hdc;
//    PAINTSTRUCT ps;

   switch(iMessage) {
   case WM_CREATE:
       
       return 0;
   case WM_COMMAND:
       switch(LOWORD(wParam))
       {
           case ID_FILE_EXIT:
               DestroyWindow(hWnd);
               break;
           case ID_MSG_ERROR1:
               MessageBox(hWnd,"ERROR1","MESSAGE",MB_OK);
               break;
           case ID_MSG_ERROR2:
               MessageBox(hWnd,"ERROR2","MESSAGE",MB_OK);
               break;
       }
       return 0;
   case WM_DESTROY:
       PostQuitMessage(0);
       return 0;
   }
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
댓글
안내
궁금한 점을 댓글로 남겨주시면 답변해 드립니다.