Programming Language/Windows API
					
						
					
				
			keyboard[1]
1. 키보드 입력 시 동작
void inirect(RECT *rect) {
	rect->left = 200;
	rect->top = 200;
	rect->right = 400;
	rect->bottom = 400;
}
void myini(HDC hdc, RECT *rect) {
	TCHAR tmp[80];
	_stprintf_s(tmp, _T("아무키나 입력하세요. "));
	TextOut(hdc, 100, 10, tmp, _tcslen(tmp));
	//DrawText(hdc, tmp, _tcslen(tmp), rect, DT_LEFT);
}
void myinput(HDC hdc, RECT *rect) {
	TCHAR tmp[80];
	_stprintf_s(tmp, _T("짜잔!!!                            "));
	TextOut(hdc, 100, 10, tmp, _tcslen(tmp));
	//DrawText(hdc, str, _tcslen(str), rect, DT_CENTER);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		PAINTSTRUCT ps;
		HDC hdc;
		RECT rect;
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		// 메뉴 선택을 구문 분석합니다.
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
	}
	break;
	case WM_CREATE:
	{
		inirect(&rect);
	}
	break;
	case WM_CHAR:
	{
		hdc = GetDC(hWnd);
		myinput(hdc, &rect);
		ReleaseDC(hWnd, hdc);
	}
	break;
	case WM_PAINT:
	{
		hdc = BeginPaint(hWnd, &ps);
		inirect(&rect);
		myini(hdc, &rect);
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
[실행화면]
  ->  
'Programming Language > Windows API' 카테고리의 다른 글
| keyboard[3] (0) | 2018.08.27 | 
|---|---|
| keyboard[2] (0) | 2018.08.27 | 
| 키보드 메세지 처리 (0) | 2018.08.26 | 
| TextOut(), DrawText() (0) | 2018.08.26 | 
| 기본구조 상세설명 (0) | 2018.08.25 | 
 
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		
		
		
		
		
		
		
	
댓글