win32_step_9 - 8BitsCoding/RobotMentor GitHub Wiki
ํด๋ฆญ ์ ํ๋๋ค๋ชจ ์ถ๋ ฅ
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_DESTROY) PostQuitMessage(0);
else if (uMsg == WM_LBUTTONDOWN) {
HDC h_dc = GetDC(hWnd);
HBRUSH h_brush = CreateSolidBrush(RGB(0, 0, 255));
HGDIOBJ h_old_brush = SelectObject(h_dc, h_brush);
Rectangle(h_dc, 50, 50, 100, 100);
SelectObject(h_dc, h_old_brush);
ReleaseDC(hWnd, h_dc);
DeleteObject(h_brush);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_DESTROY) PostQuitMessage(0);
else if (uMsg == WM_LBUTTONDOWN) {
HDC h_dc = GetDC(hWnd);
HPEN h_pen;
const char * p_style_string[6] = { "PS_SOLID", "PS_DASH", "PS_DOT", "PS_DASHDOT", "PS_DASHDOTDOT", "PS_NULL" };
int pen_style[6] = { PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL };
SetBkMode(h_dc, TRANSPARENT);
HGDIOBJ h_old_pen = GetCurrentObject(h_dc, OBJ_PEN);
for (int i = 0; i < 6; i++) {
TextOutA(h_dc, 10, 10 + i * 20, p_style_string[i], strlen(p_style_string[i]));
h_pen = CreatePen(pen_style[i], 1, RGB(0, 0, 255));
SelectObject(h_dc, h_pen);
MoveToEx(h_dc, 200, 15 + i * 20, NULL);
LineTo(h_dc, 400, 15 + i * 20);
DeleteObject(h_pen);
}
SelectObject(h_dc, h_old_pen);
ReleaseDC(hWnd, h_dc);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}