win32_step_15 - 8BitsCoding/RobotMentor GitHub Wiki


LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_PAINT) {
		PAINTSTRUCT ps;
		HDC h_dc = BeginPaint(hWnd, &ps);

		//TextOut(h_dc, 10, 10, L"Hello", 5);

		SetBkMode(h_dc, TRANSPARENT);
		SetTextColor(h_dc, RGB(0, 100, 200));
		wchar_t str[64];
		int len;
		for (int step = 2; step <= 9; step++) {
			for (int i = 1; i <= 9; i++) {
				len = wsprintf(str, L"%d * %d = %d", step, i, step * i);
				TextOut(h_dc, 10 + (step - 1) * 100, 100 + i * 20, str, len);
			}
		}

		HFONT h_font = CreateFont(32, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,
			DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY
		,DEFAULT_PITCH | FF_SWISS, L"굴림체");
		HGDIOBJ h_old_font = SelectObject(h_dc, h_font);
		TextOut(h_dc, 10, 10, L"구구단", 3);

		RECT r = { 10, 10, 830, 70 };
		FillRect(h_dc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
		DrawText(h_dc, L"구구단", 3, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		// 문자열 정렬에 좋음

		SelectObject(h_dc, h_old_font);
		DeleteObject(h_font);
		EndPaint(hWnd, &ps);
		return 0;
	}
	
	else if (uMsg == WM_DESTROY) PostQuitMessage(0);

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}