소스
출력결과



#includeLRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); HINSTANCE g_hlnst; LPCTSTR lpszClass=TEXT("TextOut"); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevlnstance, LPSTR lpszCmdParam, int nCmdShow) { HWND hWnd; MSG Message; WNDCLASS WndClass; g_hlnst = hInstance; //1. 윈도우 속성값 등록 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); //주소에 write //2. 윈도우 생성 hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW, 300, 300, 300, 300, NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hWnd, nCmdShow); //화면에 윈도우를 띄움 //3. 메시지 처리(무한반복) 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) { HDC hdc; PAINTSTRUCT ps; static TCHAR str[256]; int len; switch(iMessage){ case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONDOWN: MessageBox(hWnd, TEXT("마우스 왼쪽 버튼을 눌렀습니다."), TEXT("메시지 박스"), MB_OK); return 0; case WM_RBUTTONDOWN: if(MessageBox(hWnd, TEXT("마우스 오른쪽 버튼을 눌렀습니까?"), TEXT("메시지 박스"), MB_YESNO) == IDYES) { MessageBox(hWnd, TEXT("똑똑한 놈이군.."), TEXT("메시지 박스"), MB_OK); }else{ MessageBox(hWnd, TEXT("빙신 지가 먼키를 눌렀는지도 몰라~"), TEXT("메시지 박스"), MB_OK); } 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, lParam)); }
출력결과
'WIN_API' 카테고리의 다른 글
| 타이머 문제 - 산수 문제 출력 (0) | 2009/06/18 |
|---|---|
| 타이머를 이용한 기초 애니메이션 (0) | 2009/06/18 |
| 메세지 박스 출력하기 (1) | 2009/06/18 |
| 마우스 입력 (0) | 2009/06/16 |
| 그래픽 출력 (0) | 2009/06/16 |
| 문자열의 출력 (0) | 2009/06/16 |


