home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / CENVIW9.ZIP / GDI.CMM < prev    next >
Text File  |  1994-03-08  |  2KB  |  70 lines

  1. // GDI.cmm - Demonstrate GDI.lib
  2. // ver.1
  3. //
  4. // Contributed in its initial form to the CEnvi library by Jari Karjala.
  5. // Thank you Jari.
  6.  
  7. #include "WinTools.lib"
  8. #include "Window.lib"
  9. #include "gdi.lib"
  10.  
  11. // Create the graphics window and let it run
  12.    if ( MakeWindow(NULL,NULL,"GDIWindowFunction",
  13.                    "Demonstrate CEnvi's GDI.LIB",
  14.                    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  15.                    CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
  16.                    NULL) ) {
  17.  
  18.       while ( DoWindows() )
  19.          ;
  20.    }
  21.  
  22. GDIWindowFunction(hwnd,msg,wparm,lparm)
  23. {
  24.    // This is the Cmm routine called for all windows messages.  Here we're only
  25.    // interested in the PAINT message.  Everything else is handled by the
  26.    // default windows functions.
  27.    #define WM_PAINT 0x0F
  28.    if ( WM_PAINT == msg ) {
  29.       DrawStuff(hwnd);
  30.       return 0;
  31.    }
  32. }
  33.  
  34.  
  35. DrawStuff(hwnd)
  36. {
  37.    // Get size and DC handle
  38.    GetClientRect(hwnd,winbox)
  39.    hdc = BeginPaint(hwnd,PaintStruct);
  40.  
  41.    // Draw some lines
  42.    for (i = 0; i<winbox.bottom; i += 20) {
  43.        MoveTo(hdc, winbox.left, 0);
  44.        LineTo(hdc, winbox.right, i);
  45.        LineTo(hdc, 0, i);
  46.        LineTo(hdc, winbox.right, 0);
  47.    }
  48.  
  49.    // Draw some light gray rectangles
  50.    SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
  51.    for (i = winbox.bottom/2; i>0; i -= 20)
  52.        Rectangle(hdc, 0, 0, i, i);
  53.  
  54.    // Draw some gray rounded rectangles    
  55.    SelectObject(hdc, GetStockObject(WHITE_PEN));
  56.    SelectObject(hdc, GetStockObject(GRAY_BRUSH));
  57.    for (i = 0; i < winbox.bottom/2; i += 20)
  58.        RoundRect(hdc, (winbox.right-winbox.left)/2, winbox.top+i,
  59.                  winbox.right, winbox.bottom-i, 100, 100);
  60.  
  61.    // Draw some transparent ellipses
  62.    SelectObject(hdc, GetStockObject(BLACK_PEN));
  63.    SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
  64.    for (i = winbox.bottom/2; i>0; i -= 20)
  65.        Ellipse(hdc, 0, winbox.bottom-i, i, winbox.bottom);
  66.  
  67.    EndPaint(hwnd,PaintStruct);
  68. }
  69.  
  70.