fSCREENGRAPHICS


Quick Data

Header file:screengraphics.h
Object name:fSCREENGRAPHICS
Object index:1 of 1 Object

General Description

There isn't a whole lot to this class. It's just an interface between the screen and the _GRAPHICSBASE class. It just adds the few things that you need to be able to draw onto the screen - or actually a window.

This component is derived from _GRAPHICSBASE, and inherits the properties from that.


Methods


Prototype Description

void Setup(HWND Handle); This function is used early on to setup this component. After you have created a window, just call this function with it's handle, and then this class will store that away. Now what this means is that when you are ready to draw on the window, the class knows what window to draw on, and it will.
void ValidateWindow(void); This function 'validates' a window. You may have noticed, when intercepting a WM_PAINT message for a window, that Windows will keep sending the message again and again for some strange reason. It's usually because you have not validated the window (validation being required to tell Windows that the window is again alright, and does not need to be repainted). You can call this function to validate that window after you've intercepted a WM_PAINT and drawn onto the window.

Sample Code

The following snippet gives a basic idea of how to use this component.


//Create an instance of the screengraphics class...
fSCREENGRAPHICS Graphics;

//Now I'll assume that you've already created your window...
Graphics.Setup(Window.GetHandle());

//Now just draw with the usual _GRAPHICSBASE functions...
Graphics.Text(0, 0, "A simple test...");
Graphics.Line(10, 10, 100, 100);

//A good idea to optimize things (make them faster)
//would be to call StartDrawing() before and StopDrawing() afterwards.
//ie.
Graphics.StartDrawing();
... //Do your graphics stuff
Graphics.StopDrawing();

//Now, about that ValidateWindow() function...
//Say you intercept a WM_PAINT message...
case WM_PAINT:
     //Got WM_PAINT!
     Graphics.StartDrawing();
     ... // Do Graphics stuff
     Graphics.StopDrawing();
     Graphics.ValidateWindow(); //Must call this! Otherwise Windows
                                //continually sends WM_PAINT messages!
     break;

//And there you go. No cleanup afterwards!

Back to indexThe FreeFoote Foundation Classes Documentation