home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
BOXES1.ZIP
/
BOXES1.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-27
|
4KB
|
104 lines
/*----------------------------------------------------------------------
BOXES1.C -- OS/2 PM program that draws nested boxes in client window
(c) 1988, Ziff Communications Company
PC Magazine * Charles Petzold, 4/88 and 11/88
----------------------------------------------------------------------*/
#define INCL_WIN
#include <os2.h>
#define NUMBOXES 50 /* number of boxes to draw */
#define INCREMENT 20 /* rotate each 1/20th of side */
MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
int main (void)
{
static CHAR szClientClass [] = "Boxes1" ;
static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
FCF_SIZEBORDER | FCF_MINMAX |
FCF_SHELLPOSITION | FCF_TASKLIST ;
HAB hab ;
HMQ hmq ;
HWND hwndFrame, hwndClient ;
QMSG qmsg ;
hab = WinInitialize (0) ;
hmq = WinCreateMsgQueue (hab, 0) ;
WinRegisterClass (
hab, /* Anchor block handle */
szClientClass, /* Name of class being registered */
ClientWndProc, /* Window procedure for class */
CS_SIZEREDRAW, /* Class style */
0) ; /* Extra bytes to reserve */
hwndFrame = WinCreateStdWindow (
HWND_DESKTOP, /* Parent window handle */
WS_VISIBLE, /* Style of frame window */
&flFrameFlags, /* Frame creation flags */
szClientClass, /* Client window class name */
NULL, /* Title bar text */
0L, /* Style of client window */
NULL, /* Module handle for resources */
0, /* ID of resources */
&hwndClient) ; /* Pointer to client window handle */
while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
WinDispatchMsg (hab, &qmsg) ;
WinDestroyWindow (hwndFrame) ;
WinDestroyMsgQueue (hmq) ;
WinTerminate (hab) ;
return 0 ;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static SHORT xClient, yClient ;
HPS hps;
POINTL aptl[5] ;
SHORT sRep, sSide ;
switch (msg)
{
case WM_SIZE:
xClient = SHORT1FROMMP (mp2) ;
yClient = SHORT2FROMMP (mp2) ;
return 0 ;
case WM_ERASEBACKGROUND:
return TRUE ;
case WM_PAINT:
hps = WinBeginPaint (hwnd, NULL, NULL) ;
aptl[0].x = aptl[1].x = 0 ;
aptl[2].x = aptl[3].x = xClient - 1 ;
aptl[0].y = aptl[3].y = 0 ;
aptl[1].y = aptl[2].y = yClient - 1 ;
for (sRep = 0 ; sRep < NUMBOXES ; sRep ++)
{
aptl[4] = aptl[0] ;
GpiMove (hps, aptl) ;
GpiPolyLine (hps, 4L, aptl + 1) ;
for (sSide = 0 ; sSide < 4 ; sSide++)
{
aptl[sSide].x = ((INCREMENT - 1) * aptl[sSide].x +
aptl[sSide + 1].x +
INCREMENT / 2) / INCREMENT ;
aptl[sSide].y = ((INCREMENT - 1) * aptl[sSide].y +
aptl[sSide + 1].y +
INCREMENT / 2) / INCREMENT ;
}
}
WinEndPaint (hps) ;
return 0 ;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
}