home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / COLOUR2.PRG < prev    next >
Text File  |  1995-07-09  |  998b  |  45 lines

  1. ////////////////////////////
  2. //
  3. //    Clip-4-Win colour demo  (same as colour.prg, but using commands)
  4. //
  5. //    Copyright (C) 1992 Skelton Software, Kendal Cottage, Hillam, Leeds, UK.
  6. //    All Rights Reserved.
  7. //
  8. //    To build:    c4wbuild colour2
  9. //
  10. ////////////////////////////
  11.  
  12. #define    WIN_WANT_ALL
  13. #include "windows.ch"
  14. #define    NO_C4WCLASS
  15. #include "commands.ch"
  16.  
  17.  
  18. function main()
  19. local    oApp, oWnd
  20.  
  21. CREATE APPLICATION oApp  WINDOW oWND  TITLE "Clip-4-Win colour demo"    ;
  22.     ON WM_PAINT    OnPaint(oWnd)                    ;
  23.     ON WM_KEYDOWN    OnKey(oWnd)
  24.  
  25. return nil
  26.  
  27.  
  28. static function OnPaint(hWnd)
  29. SetPos(0, 0)
  30. ? ; ? "  Press a key to choose a colour (or 'color')..."
  31. return nil
  32.  
  33.  
  34. static function OnKey(hWnd)
  35. local    nColour := ChooseColor(), hDC, hBrush
  36.  
  37. if nColour >= 0        // else user chose cancel/close or hit Esc
  38.     hDC = GetDC(hWnd)
  39.     hBrush = CreateHatchBrush(HS_DIAGCROSS, nColour)
  40.     FillRect(hDC, 100, 100, 500, 300, hBrush)
  41.     DeleteObject(hBrush)
  42.     ReleaseDC(hWnd, hDC)
  43. endif
  44. return nil
  45.