1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
...
HDC hdc; // This was the original position of the declaration
PAINTSTRUCT ps;
...
HPEN hPen = NULL,
hPenS1Blue = CreatePen(PS_SOLID, 1, RGB(0, 0, 255)),
hPenD5Red = CreatePen(PS_DOT, 5, RGB(255, 0, 0));
...
switch (message){
// ______________________ WM_PAINT ______________________
case WM_PAINT:{
HDC hdc; // New position
PAINTSTRUCT ps;
...
HPEN hPen = NULL,
hPenS1Blue = CreatePen(PS_SOLID, 1, RGB(0, 0, 255)),
hPenD5Red = CreatePen(PS_DOT, 5, RGB(255, 0, 0));
...
hdc = BeginPaint(hwnd, &ps);
...
hPen = (HPEN)SelectObject(hdc, hPenS1Blue);
Rectangle(hdc, 50, 100, 100, 250);
SelectObject(hdc, hPen);
hPen = (HPEN)SelectObject(hdc, hPenD5Red);
Ellipse(hdc, 120, 100, 170, 250);
SelectObject(hdc, hPen);
...
EndPaint(hwnd, &ps);
DeleteObject(hPenS1Blue);
DeleteObject(hPenD5Red);
DeleteObject(hPen);
break;}
...
return 0;
}
|