Todays assignment is to get a red block on the screen of a Win32 program.
Let's assume you're using Win32. Let's assume you're using Visual Studio 6. To draw a colored block, do this:
This should take you to this code position:
case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; |
6) Remove the two lines that starts with "GetClientRect" and with "DrawText" and instead put in:
rt.left = 10; rt.top = 10; rt.right = 30; rt.bottom = 30;
static HBRUSH brRed;
if( !brRed ) brRed = CreateSolidBrush( RGB( 200, 0, 0 ) );
FillRect( hdc, &rt, brRed );
|
7) Press F5, say OK. Watch your red block appear.