$APPTYPE GUI
$ESCAPECHARS ON
$TYPECHECK ON
$INCLUDE "RAPIDQ.INC"
DECLARE SUB DemoDrawCell (Col%, Row%, State%, Rect AS QRECT, Sender AS QSTRINGGRID)
DECLARE SUB DemoSelectCell (Col%, Row%, CanSelect%, Sender AS QSTRINGGRID)
DECLARE SUB DeleteSelection (Sender AS QSTRINGGRID)
SUB frmWindProc
END SUB
CREATE frmTestGrid AS QFORM
Width = Screen.Width - 50
Height = Screen.Height - 50
autoscroll = false
COLOR = &HB3D1C0
CAPTION = "Test Selected Grid Coloring"
wndproc = frmWindProc
END CREATE
CREATE gridDemo AS QSTRINGGRID
Font.COLOR = &HFF0000
PARENT = frmTestGrid
Left = 4
Top = 4
Font.Size = 8
Font.Name = "MS sans serif"
AddOptions (goEditing)
FixedRows = 1
FixedCols = 1
ColCount = 10
RowCount = 10
DefaultRowHeight = 16
DefaultColWidth = 80
Width = gridDemo.ColCount * (1 + gridDemo.DefaultColWidth) + 5
Height = gridDemo.RowCount * (1 + gridDemo.DefaultRowHeight) + 5
FixedColor = &HFFD5C0
COLOR = &HC0FFFF
ScrollBars = ssNone
OnDrawCell = demoDrawCell
OnSelectCell = demoSelectCell
END CREATE
frmTestGrid.Height = 5 + gridDemo.Height + 35
frmTestGrid.Width = 5 + gridDemo.Width + 10
DIM gridDemoColor (0 TO gridDemo.ColCount, 0 TO gridDemo.RowCount) AS LONG
DEFINT R, C
FOR R = 1 TO gridDemo.RowCount - 1
FOR C = 1 TO gridDemo.ColCount -1
gridDemo.Cell(C, R) = Format$("%3.4f", RND /100)
NEXT C
NEXT R
gridDemo.Cell(1,1) = "UNSELECT"
DEFINT cellFontColor, cellBGColor
cellFontColor = &H800000
cellBGColor = &HC0C0FF
frmTestGrid.SHOWMODAL
SUB DemoDrawCell (Col%, Row%, State%, Rect AS QRECT, Sender AS QSTRINGGRID)
IF gridDemoColor (Col% , Row% ) THEN
Sender.TextOut (Rect.left, Rect.Top, (Sender.Cell(Col%, Row%) - " ") _
& " " , cellFontColor, cellBGColor )
END IF
END SUB
SUB DemoSelectCell (Col%, Row%, CanSelect%, Sender AS QSTRINGGRID)
IF Col% = 1 AND Row% = 1 THEN
DeleteSelection (Sender)
EXIT SUB
END IF
IF Col% > 0 AND Row% > 0 THEN
gridDemoColor (Col%, Row%) = NOT(gridDemoColor (Col%, Row%))
END IF
Sender.Repaint
END SUB
SUB DeleteSelection (Sender AS QSTRINGGRID)
DEFINT R, C
FOR R = 0 TO gridDemo.RowCount
FOR C = 0 TO gridDemo.ColCount
gridDemoColor (C, R) = 0
NEXT C
NEXT R
Sender.Repaint
END SUB
|