Demo99 TrueGrid Chess! Form15 Table1 TgDemo WhitePiece wwwwwwwwwwp wwwwwwwwwwp WhitePiece wwwwwwwwwwp wwwwwwwwwwp WhitePiece wwwwwwwwwwp wwwwwwwwwwp WhitePiece wwwwwwwwwwp wwwwwwwwwwp WhitePiece wwwwwwwwwwp wwwwwwwwwwp WhitePiece wwwwwwwwwwp wwwwwwwwwwp BlackPiece wwwwwwwwwwp wwwwwwwwwwp BlackPiece wwwwwwwwwwp wwwwwwwwwwp wwwwww wwwwww BlackPiece wwwwwwwwwwp wwwwwwwwwwp wpwwp BlackPiece wwwwwwwwwwp wwwwwwwwwwp BlackPiece wwwwwwwwwwp wwwwwwwwwwp wwwwwp BlackPiece wwwwwwwwwwp wwwwwwwwwwp wwwwwp wwwwww ppwppw @ Form_Loadq Pieces QUEEN BISHOP KNIGHT ROOK} Table1_Click> Table1_Fetchk Value Table1 Picture WhitePieceN BlackPiece Table1_FetchAttributes StatusS Splitv FgColor BgColor0 FontStyleF DK_BLUE' ColumnCellAttrs Table1_DragCellj dragRow dragColw MarqueeStyle` GMQ_HIGHCELL DRAG_BEGIN BEGIN_DRAGV Table1_DragOver" Source Control State LEAVE GMQ_NONE ENTER PointX PointY dragToRow RowAtPoint dragToCol ColumnAtPoint Table1_DragDrop dragToCell6 RefreshColZ RefreshColumn RowIndex ColumnIndexP dragging WhitePiece_Click Index| SendMessagem wParam lParam GRM_REFRESHCELL RefreshCell TgDemo ignore subIf Form_Unload Cancel QuitCurrentDemoB Pieces contains the piece index numbers. 0 if empty square.R i% is used as a work variable Information about pieces in transit Piece indices: must match Index of WhitePiece and BlackPiece controls These two definitions are used by the RefreshCell routine. Form_Load Fixed number of rows ... 8n Set all columns so that cell colors are queried each time they are needed.l *** Set up the chess board ***o First, position the pawns. Position the black pieces Position the white pieces. Form_Unload RefreshCell This is a "trick" to refresh a cell within TrueGrid. It uses an undocumented TrueGrid message (I thought this was OK since this is one of the more frivolous demos). However, thiss technique will work with all versions of TrueGrid tot refresh only the specified cell.s Table1_DragCell Only start dragging if there is a piece at this location. Set drag parameters so other events know we'res dragging. Start drag Table1_DragDrop Drop only if there's a valid cell under the cursor. Overwrite the current piece with the new piece. Clear the old piece if we didn't drop on top of ourselves.o Refresh the old and new cells so that Fetch isf call to redisplay them. Table1_DragOver When dragging, we always update the dragToRow and dragToCol so other events know where we are.w reentry ... turn dragging on againr exiting while dragging ... suspend drag calculate the cell which the cursor isg now pointing to.l Refresh the old current cell and the new current cell to change the highlighting. Table1_Fetch Fetch a piece. Pieces contains the index into an array of pictures (WhitePiece/BlackPiece) that contain the actual pictures of the pieces.e Postive values are white, negatives are black.h Table1_FetchAttributes If dragging, then always highlight the currenth cell by letting the background color show through. This code sets BgColor to obtain a checkerboard effect.