LuvSea
Message Box 본문
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("first");
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevlnstance, 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 IParam)
{
HDC hdc;
PAINTSTRUCT ps;
char str[256];
int len;
switch(iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_LBUTTONDOWN:
if(MessageBox(hWnd,TEXT("hello world!"),TEXT("메세지박스"),MB_YESNO)==IDYES){
MessageBoxA(hWnd,"똑바로 해 이것들아!!",TEXT("메세지박스"),MB_OK);
return 0;
}
else
return 0;
case WM_RBUTTONDOWN:
if(MessageBox(hWnd,TEXT("hello world!"),TEXT("메세지박스"),MB_YESNO)==IDYES){
MessageBoxA(hWnd,"똑바로 해 이것들아!!",TEXT("메세지박스"),MB_OK);
return 0;
}
else
return 0;
case WM_CHAR:
len= lstrlen(str);
str[len]=(TCHAR)WParam;
str[len+1]=0;
InvalidateRect(hWnd,NULL,FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
TextOut(hdc,100,100,str,lstrlen(str));
EndPaint(hWnd,&ps);
return 0;
}
return(DefWindowProc(hWnd,iMessage,WParam,IParam));
}
'sTudy' 카테고리의 다른 글
타이머를 이용한 시계 (0) | 2009.07.06 |
---|---|
키 입력과 무효 영역 (0) | 2009.07.06 |
직선, 원, 사각형 그리기 (0) | 2009.07.06 |
API 기본 출력 소스 (0) | 2009.07.06 |
텍스트형 LCD 모듈 응용 프로그램을 이용한 사용자 정의문자 출력 (1) | 2009.06.04 |