Page 230 - DCAP408_WEB_PROGRAMMING
P. 230
Windows Programming
Notes break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
// Initializing original object
HGDIOBJ original = NULL;
// Saving the original object
original = SelectObject(hdc,GetStockObject(DC_PEN));
// Rectangle function is defined as...
// BOOL Rectangle(hdc, xLeft, yTop, yRight, yBottom);
// Drawing a rectangle with just a black pen
// The black pen object is selected and sent to the current
device context
// The default brush is WHITE_BRUSH
SelectObject(hdc, GetStockObject(BLACK_PEN));
Rectangle(hdc,0,0,200,200);
// Select DC_PEN so you can change the color of the pen with
// COLORREF SetDCPenColor(HDC hdc, COLORREF color)
SelectObject(hdc, GetStockObject(DC_PEN));
// Select DC_BRUSH so you can change the brush color from the
// default WHITE_BRUSH to any other color
SelectObject(hdc, GetStockObject(DC_BRUSH));
// Set the DC Brush to Red
// The RGB macro is declared in “Windowsx.h”
SetDCBrushColor(hdc, RGB(255,0,0));
// Set the Pen to Blue
224 LOVELY PROFESSIONAL UNIVERSITY