유돌이

calendar

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

Notice

2009. 1. 2. 17:55 C/C++/MFC
출처 왜목마을(臥木) | 체키럽
원문 http://blog.naver.com/pbk7318/9119084
#include <windows.h>

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

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)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,0,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(iMessage) {
case WM_CREATE:
CreateWindow("button","버튼1",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20,20,100,23,hWnd,(HMENU)0,g_hInst,NULL);
CreateWindow("button","버튼2",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20,50,70,23,hWnd,(HMENU)1,g_hInst,NULL);
CreateWindow("button","버튼3",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20,80,150,33,hWnd,(HMENU)2,g_hInst,NULL);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case 0:
MessageBox(hWnd,"첫번째 버튼을 누질렀습니다","Button",MB_OK);
break;
case 1:
MessageBox(hWnd,"두번째 버튼을 누질렀습니다","Button",MB_OK);
break;
case 2:
MessageBox(hWnd,"세번째 버튼을 누질렀습니다","Button",MB_OK);
break;
}

case WM_PAINT:
hdc=BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));

'C/C++/MFC' 카테고리의 다른 글

포인터 사용법  (0) 2009.01.05
MFC를 사용하여 웹 브라우저 만들기  (0) 2009.01.02
Invalidate() , OnDraw(CDC* pDC)  (0) 2009.01.02
MFC (디바이스 컨텍스트와 관련 클래스)  (0) 2008.12.30
윈도우즈와 메시지  (0) 2008.12.30
posted by 유돌이