Example: String Display in Client AreaThe Strings1 example uses fg_print() and fg_justify() to display strings in the client area. Strings1 displays the string "FG/Windows" in light blue (color 19) against a solid yellow (color 24) background. The first three calls to fg_print() and fg_justify() display the string left justified, centered, and right justified at the top of the client area. The next three sets of calls display the string in these positions centered vertically, and the last three display in these positions at the bottom of the window. The result is shown here.
The program's WM_CREATE message handler creates a 320x240 virtual buffer and fills it with yellow pixels. In fact, this is the only time Strings1 writes directly to the virtual buffer. Most of the work occurs in the WM_PAINT handler, which first calls fg_vbscale() to display the virtual buffer contents (this fills the client area with yellow pixels). The WM_PAINT handler then displays the nine strings in the desired positions, using a series of fg_move(), fg_justify(), and fg_print() calls for each string. Note how we use the fg_xclient() and fg_yclient() translation functions in the fg_move() calls. These functions translate the x and y coordinates from the 320x240 virtual buffer coordinates to the equivalent client area positions. This allows us to use the same coordinate system when displaying strings in the client area, regardless of its size.
|
 
copyright 2001 Ted Gruber Software, Inc.