home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / CONTRIB / WINBOX.ZIP / WINBOX.PRG
Text File  |  1993-05-25  |  4KB  |  101 lines

  1.  
  2. // WinBox() - Draws sunken or raised grey boxes on your windows
  3. // Neat way to highlight buttons, controls, create status bars, etc.
  4. //
  5. // 05/24/93, Hugh A. Lokey
  6. //
  7. // Calling Syntax:
  8. //         hWnd    := handle to window to draw on
  9. //         nX,nY   := Upper left corner of box (column,row)
  10. //         nCX,nCY := Lower right hand corder of box (column,row)
  11. //         nStyle  := 1 = sunken, 2 = raised
  12. //         nBorder := 1 = draw a black border, 2 = no border
  13. //         nPixHD  := number of pixels deep or high
  14. //                    on two or more the lines are staggerd so
  15. //                    you get beveled "picture frame" corners
  16. //
  17. //         nTBbord := Inset from edge for top and bottom of box
  18. //         nLRbord := Inset from edge for left and right sides
  19. //                    nTBord and LRbord are used when you want
  20. //                    to create "status bar" type arrangements
  21. //
  22. // NOTES:  You can easily modify this to allow the selection of
  23. // your own colors - I happen to like simple things like the
  24. // grey background!
  25. //
  26. // You will also have to re-draw the boxes when you get an event_redraw
  27. // for the window they are on.  If you stick buttons or other controls
  28. // within a box you should include WS_CLIPCHILDREN in the window def
  29. // so that Windows will redraw the controls otherwise they will be
  30. // hidden behind your box when you redraw it!
  31.  
  32. FUNCTION WinBox(hWnd,nX,nY,nCX,nCY,nStyle,nBorder,nPixHD,nTBbord,nLRBord)
  33.          LOCAL nLeft, nTop, nRight, nBottom, hOldPen, hTopPen, hBotPen
  34.          LOCAL hDC, hFillPen, hBlackPen, hGreyPen, hWhitePen, nCtr
  35.  
  36.          hDc       := GetDC(hWnd)
  37.          nLeft     := nX
  38.          nTop      := nY
  39.          nRight    := nCX
  40.          nBottom   := nCY
  41.          nStyle    := IIF(nStyle  == NIL, 1 , nStyle)
  42.          nBorder   := IIF(nBorder == NIL, 1 , nBorder)
  43.          nPixHD    := IIF(nPixHD  == NIL, 1 , nPixHD)
  44.  
  45.          hBlackPen := CreatePen(PS_SOLID,1,RGB(0,0,0))
  46.          hGreyPen  := CreatePen(PS_SOLID,1,RGB(128,128,128))
  47.          hWhitePen := CreatePen(PS_SOLID,1,RGB(255,255,255))
  48.          hFillPen  := CreateSolidBrush(RGB(192,192,192))
  49.          hOldPen   := SelectObject(hDC,hBlackPen)
  50.  
  51.          Rectangle(hDC,nLeft,nTop,nRight,nBottom)
  52.          IF nBorder == 1
  53.             FillRect(hDC,nLeft+1,nTop+1,nRight-1,nBottom-1,hFillPen)
  54.             nLeft   += 1
  55.             nTop    += 1
  56.             nRight  -= 2
  57.             nBottom -= 2
  58.          ELSE
  59.             FillRect(hDC,nLeft,nTop,nRight,nBottom,hFillPen)
  60.             ++nLeft
  61.             ++nTop
  62.             --nRight
  63.             --nBottom
  64.          ENDIF
  65.          nLeft   := IIF(nLRBord == NIL,nLeft,nLeft+nLRBord)
  66.          nRight  := IIF(nLRBord == NIL,nRight,nRight-nLRBord)
  67.          nTop    := IIF(nTBBord == NIL,nTop,nTop+nTBBord)
  68.          nBottom := IIF(nTBBord == NIL,nBottom,nBottom-nTBBord)
  69.          IF nStyle == 1
  70.             hTopPen := hGreyPen
  71.             hBotPen := hWhitePen
  72.          ELSE
  73.             hTopPen := hWhitePen
  74.             hBotPen := hGreyPen
  75.          ENDIF
  76.          FOR nCtr := 1 TO nPixHD
  77.              DrawWBox(hDC,hTopPen,hBotPen,nTop,nLeft,nBottom,nRight)
  78.              ++nLeft
  79.              ++nTop
  80.              --nRight
  81.              --nBottom
  82.          NEXT
  83.          SelectObject(hDC,hOldPen)
  84.          ReleaseDC(hWnd,hDC)
  85.          DeleteObject(hFillPen)
  86.          DeleteObject(hBlackPen)
  87.          DeleteObject(hGreyPen)
  88.          DeleteObject(hWhitePen)
  89. RETURN(NIL)
  90.  
  91. STATIC FUNCTION DrawWBox(hDC,hTopPen,hBotPen,nTop,nLeft,nBottom,nRight)
  92.  
  93.        SelectObject(hDC,hTopPen)
  94.        MoveTo(hDC,nLeft,nBottom)
  95.        LineTo(hDC,nLeft,nTop)
  96.        LineTo(hDC,nRight,nTop)
  97.        SelectObject(hDC,hBotPen)
  98.        LineTo(hDC,nRight,nBottom)
  99.        LineTo(hDC,nLeft,nBottom)
  100. RETURN(NIL)
  101.