Page 231 - DCAP408_WEB_PROGRAMMING
P. 231
Unit 14: Text and Graphics Output
SetDCPenColor(hdc, RGB(0,0,255)); Notes
// Drawing a rectangle with the current Device Context
Rectangle(hdc,100,300,200,400);
// Changing the color of the brush to Green
SetDCBrushColor(hdc, RGB(0,255,0));
Rectangle(hdc,300,150,500,300);
// Restoring the original object
SelectObject(hdc,original);
// It is not necessary to call DeleteObject to delete stock
objects.
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Self Assessment
Fill in the blank:
10. An application can retrieve the current DC brush color by using the SetDCBrushColor
and the ......................... functions.
14.7 Graphics Output
Graphics is a very important part of visual basic programming as an attractive interface will be
appealing to the users. In the old BASIC, drawing and designing graphics are considered as
difficult jobs, as they have to be programmed line by line in a text-based environment. However,
in Visual Basic, these jobs have been made easy. There are four basic controls in VB that you can
use to draw graphics on your form: the line control, the shape control, the image box and the
picture box
14.7.1 Line and Shape Controls
To draw a straight line, just click on the line control and then use your mouse to draw the line on
the form. After drawing the line, you can then change its color, width and style using the
LOVELY PROFESSIONAL UNIVERSITY 225