home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP6.ZIP / PAINTRCT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.6 KB  |  61 lines

  1. /*
  2.     PAINTRCT.C -- Demonstrates PaintRect
  3.  
  4.     From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.  
  7.     Build using: WINIOBC PAINTRCT (for Borland C++ v3.00)
  8.                  WINIOMS PAINTRCT (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h> 
  12. #include "wmhandlr.h" 
  13. #include "winio.h" 
  14.  
  15. /* undocumented function */ 
  16. extern void FAR PASCAL PaintRect(HWND hwndParent, HWND hwnd,
  17.                         HDC hDC, HANDLE hBrush, LPRECT lpRect);
  18. #include "checkord.c"
  19.  
  20.  
  21. long dblclk(HWND hwnd, WORD wMsg, WORD wParam, DWORD lParam)
  22.     {
  23.     RECT rect;
  24.     HDC hDC = GetDC(hwnd);
  25.     
  26.     GetClientRect(hwnd, (LPRECT) &rect);
  27.     rect.left += 20;
  28.     rect.right -= 20;
  29.     rect.top += 10;
  30.     rect.bottom -= 10;
  31.     PaintRect(NULL, hwnd, hDC,
  32.                 GetStockObject(DKGRAY_BRUSH), (LPRECT) &rect);
  33.     ReleaseDC(hwnd, hDC);
  34.     puts("A rectangle in the window should now be dark gray");
  35.     puts("Double click on a text line to do it again");
  36.     return 1;
  37.     }
  38.  
  39.  
  40. int main() 
  41.     {
  42.     // Ord/name check
  43.     if (! CheckOrdName("PaintRect", "USER", 325))
  44.         return 0;
  45.  
  46.     winio_about("PAINTRCT"
  47.         "\nDemonstrates PaintRect"
  48.         "\n\nFrom Chapter 6 of"
  49.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  50.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  51.         );
  52.  
  53.     wmhandler_set(winio_current(),
  54.                     WM_LBUTTONDBLCLK, (WMHANDLER) dblclk);
  55.  
  56.     puts("Double click on a text line to paint a dark gray rectangle");
  57.     puts("Close the window to exit");
  58.     
  59.     return 0;
  60.     }
  61.