Page 229 - DCAP408_WEB_PROGRAMMING
P. 229
Unit 14: Text and Graphics Output
Self Assessment Notes
Fill in the blank:
9. ......................... changes the settings of the default display device to the specified graphics
mode.
14.6 Device Context Settings
14.6.1 Setting and Retrieving the Device Context Brush Color Value
The following example shows how an application can retrieve the current DC brush color by
using the SetDCBrushColor and the GetDCBrushColor functions
Example:
SelectObject(hdc,GetStockObject(DC_BRUSH));
SetDCBrushColor(hdc, RGB(00,0xff;00);
PatBlt(0,0,200,200,PATCOPY)
SetDCBrushColor(hdc,RGB(00,00,0xff);
PatBlt(0,0,200,200,PATCOPY);
14.6.2 Setting the Pen or Brush Color
The following example shows how an application can change the DC pen color by using the
GetStockObject function or SetDCPenColor and the SetDCBrushColorfunctions.
Example:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
LOVELY PROFESSIONAL UNIVERSITY 223