home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
CENVIW9.ZIP
/
GDI.CMM
< prev
next >
Wrap
Text File
|
1994-03-08
|
2KB
|
70 lines
// GDI.cmm - Demonstrate GDI.lib
// ver.1
//
// Contributed in its initial form to the CEnvi library by Jari Karjala.
// Thank you Jari.
#include "WinTools.lib"
#include "Window.lib"
#include "gdi.lib"
// Create the graphics window and let it run
if ( MakeWindow(NULL,NULL,"GDIWindowFunction",
"Demonstrate CEnvi's GDI.LIB",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL) ) {
while ( DoWindows() )
;
}
GDIWindowFunction(hwnd,msg,wparm,lparm)
{
// This is the Cmm routine called for all windows messages. Here we're only
// interested in the PAINT message. Everything else is handled by the
// default windows functions.
#define WM_PAINT 0x0F
if ( WM_PAINT == msg ) {
DrawStuff(hwnd);
return 0;
}
}
DrawStuff(hwnd)
{
// Get size and DC handle
GetClientRect(hwnd,winbox)
hdc = BeginPaint(hwnd,PaintStruct);
// Draw some lines
for (i = 0; i<winbox.bottom; i += 20) {
MoveTo(hdc, winbox.left, 0);
LineTo(hdc, winbox.right, i);
LineTo(hdc, 0, i);
LineTo(hdc, winbox.right, 0);
}
// Draw some light gray rectangles
SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
for (i = winbox.bottom/2; i>0; i -= 20)
Rectangle(hdc, 0, 0, i, i);
// Draw some gray rounded rectangles
SelectObject(hdc, GetStockObject(WHITE_PEN));
SelectObject(hdc, GetStockObject(GRAY_BRUSH));
for (i = 0; i < winbox.bottom/2; i += 20)
RoundRect(hdc, (winbox.right-winbox.left)/2, winbox.top+i,
winbox.right, winbox.bottom-i, 100, 100);
// Draw some transparent ellipses
SelectObject(hdc, GetStockObject(BLACK_PEN));
SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
for (i = winbox.bottom/2; i>0; i -= 20)
Ellipse(hdc, 0, winbox.bottom-i, i, winbox.bottom);
EndPaint(hwnd,PaintStruct);
}