home *** CD-ROM | disk | FTP | other *** search
- // GDI.cmm - Demonstrate GDI.lib
- //
- // Contributed in its initial form to the CEnvi library by Jari Karjala.
- // Thank you Jari.
-
- #include "WinUtil.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
- winbox = GetClientRect(hwnd)
- 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);
- }
-