Use the window functions to create or remove a graphical window that you can display information in.
Available functions:
OpenWin
: Open a window
CloseWin
: Close a window, recovering the memory associated with it
WinText
: Output text in a window, relative to its client area.
SEE ALSO: OpenWin CloseWin Window Styles PALWIN Structure WinText
OpenWin
OpenWin opens a window at a certain screen position, with
a size, border style and title you specify. #include "pal.h"
PALWIN *OpenWin(WORD Style, int x1, int y1, int x2, int y2,
char *Caption); Style - see the entry on window styles below.
x1 - x position of upper left corner (including frame)
y1 - y position of upper left corner (including frame)
x2 - x position of lower right corner, including frame
but not shadow.
y2 - y position of lower right corner, including frame
but not shadow.
Caption - The title for your window - use NULL if you
don't want a title. OpenWin returns a pointer to a PALWIN structure (described
in another entry) or NULL on failure. PALWIN *pWin;
pWin = OpenWin(WS_HP200, 10, 10, 100, 100, " Hello PAL ");
GetKey();
CloseWin(pWin);CloseWin
Closes a window opened by OpenWin.
#include "pal.h"
void CloseWin(PALWIN *pWin); pWin - the pointer to the PALWIN structure returned by
OpenWin CloseWin will only restore the background of the window if
it got opened with the WS_SAVEBG style. PALWIN *pWin;
pWin = OpenWin(WS_HP200, 10, 10, 100, 100, " Hello PAL ");
GetKey();
CloseWin(pWin);WinText
Output a text string at position (x,y) in client area of a window
given by a pointer to a PALWIN descriptor. The currently selected
font is used. #include "pal.h"
void WinText(PALWIN *pWin, int OffsetX, int OffsetY, char *Txt); pWin - the pointer to the PALWIN structure returned by
OpenWin
OffsetX - X coordinate where text should appear - relative to the
upper left corner of the window, not the screen.
OffsetY - Y coordinate where text should appear - relative to the
upper left corner of the window, not the screen.
Txt - the text to be output. PALWIN *pWin;
pWin = OpenWin(WS_HP200, 10, 10, 100, 100, " Hello PAL ");
WinText(pWin, 5, 5, "WinText test");
GetKey();
CloseWin(pWin); Here are the definitions of the predefined styles from
PAL.H:
#define WS_MENU (WS_BORDER|WS_SHADOW|WS_SAVEBG)
#define WS_HP100 (WS_BORDER|WS_SHADOW|WS_SMLFONT|WS_SAVEBG)
#define WS_HP200 (WS_DBORDER|WS_SHADOW|WS_SAVEBG)
#define WS_HELP (WS_FRAME|WS_SMLFONT|WS_SAVEBG)
For a window with a 7 pixel border, no shadow and a small
font, you could use:
#define MY_STYLE (7 | WS_SMLFONT | WS_SAVEBG) The first four bits of the style are the border size -
this makes it easy to just 'or' in the size as shown in
the sample above.
Note that you cannot exceed 15 pixels border size. Don't
forget to include WS_SAVEBG unless you are sure that you
don't need it.