Use Windows.pkg Use DFClient.pkg Use cReportControlGrid.pkg Use Ddvaltbl.pkg // tWinRect // -------- Struct tWinRect DWord left DWord top DWord right DWord bottom End_Struct // DrawText Format Values: Define DT_TOP for |CI$00000000 Define DT_LEFT for |CI$00000000 Define DT_CENTER for |CI$00000001 Define DT_RIGHT for |CI$00000002 Define DT_VCENTER for |CI$00000004 Define DT_BOTTOM for |CI$00000008 Define DT_WORDBREAK for |CI$00000010 Define DT_SINGLELINE for |CI$00000020 Define DT_EXPANDTABS for |CI$00000040 Define DT_TABSTOP for |CI$00000080 Define DT_NOCLIP for |CI$00000100 Define DT_EXTERNALLEADING for |CI$00000200 Define DT_CALCRECT for |CI$00000400 Define DT_NOPREFIX for |CI$00000800 Define DT_INTERNAL for |CI$00001000 Define DT_EDITCONTROL for |CI$00002000 Define DT_PATH_ELLIPSIS for |CI$00004000 Define DT_END_ELLIPSIS for |CI$00008000 Define DT_MODIFYSTRING for |CI$00010000 Define DT_RTLREADING for |CI$00020000 Define DT_WORD_ELLIPSIS for |CI$00040000 Define DT_NOFULLWIDTHCHARBREAK for |CI$00080000 Define DT_HIDEPREFIX for |CI$00100000 Define DT_PREFIXONLY for |CI$00200000 Deferred_View Activate_oTableEditor for ; Object oTableEditor is a dbView Set Border_Style to Border_Thick Set Size to 200 300 Set Location to 2 2 Set Label to "Table Editor" Object oTypeOptions is a ValidationTable Procedure Fill_List Forward Send Fill_List Send Add_Table_Value "int" Send Add_Table_Value "char" Send Add_Table_Value "datetime" Send Add_Table_Value "numeric" End_Procedure // Fill_List End_Object // oTypeOptions Object oTableEditor_grd is a cReportControlGrid Set Size to 192 291 Set Location to 4 4 Set peAnchors to anAll Set pbAllowMoveRow to False Set pbAutoColumnSizing to True Set pbDrawSortTriangleAlways to False Set pbAllowAllColumnSort to False Set pbAllowColumnReorder to False Set pbFixedRowHeight to True Set pbInvertColumnOnClick to False Set BorderStyle to OLExtpBorderFlat Set HighlightRowState to False Set peGridLineColor to cl3DLight Set piCustomDraw to OLExtpCustomDrawItem Set piHeaderStyle to OLExtpColumnExplorer // AddColumns: Procedure AddColumns Handle hColumn Get AddColumn "" to hColumn Set HeaderWidth hColumn to 14 Set ColumnResizable hColumn to False Set ColumnShadowState hColumn to True Get AddColumn "Name" to hColumn Get AddColumn "Type" to hColumn Set HeaderWidth hColumn to 50 Set ColumnComboState hColumn to True Set ColumnComboListObject hColumn to oTypeOptions Get AddColumn "Size" to hColumn Set HeaderWidth hColumn to 25 Get AddColumn "Main Index" to hColumn Set HeaderWidth hColumn to 50 End_Procedure // AddColumns // AddIcons: Procedure AddIcons Integer iRetval Get AddImage "CurrentRow.ico" RC_ImageCurrentRow to iRetval End_Procedure // AddIcons // FillGrid: Procedure FillGrid Handle hItem Send Cursor_Wait of Cursor_Control // Row 1: Get AddItem "" to hItem Set ComIcon of hItem to RC_ImageCurrentRow Get AddItem "Order_Num" to hItem Get AddItem "int" to hItem Get AddItem "6" to hItem Get AddItem "Index.1" to hItem // Row 2: Get AddItem "" to hItem Get AddItem "Date" to hItem Get AddItem "datetime" to hItem Get AddItem "" to hItem Get AddItem "" to hItem // 3rd Row: Get AddItem "" to hItem Get AddItem "SalesID" to hItem Get AddItem "int" to hItem Get AddItem "6" to hItem Get AddItem "Index.2" to hItem // 4th Row: Get AddItem "" to hItem Get AddItem "CustomerID" to hItem Get AddItem "int" to hItem Get AddItem "6" to hItem Get AddItem "Index.3" to hItem // 5th Row: Get AddItem "" to hItem Get AddItem "City" to hItem Get AddItem "char" to hItem Get AddItem "15" to hItem Get AddItem "" to hItem // 6th Row: Get AddItem "" to hItem Get AddItem "Country" to hItem Get AddItem "char" to hItem Get AddItem "20" to hItem Get AddItem "" to hItem Send Cursor_Ready of Cursor_Control Send Populate End_Procedure // FillGrid // OnComDrawItem: // ~~~~~~~~~~~~~~ // Augmented to draw an elegangt focus rectangle around the selected cell. Procedure OnComDrawItem Variant llRow Variant llColumn Variant llItem ; OLE_HANDLE hDC Integer llleft Integer lltop ; Integer llright Integer llbottom Boolean ByRef llDoDefault Variant vFocusedColumn vFocusedRow Boolean bVoid bEditable Integer iVoid Handle hPen hPenOld tWinRect ARect Variant vText String sText Pointer lpRect lpText Handle hoItem hoColumn // Determine if there is a current item.... Get Create U_cComReportRecordItem to hoItem Set pvComObject of hoItem to llItem If (IsComObjectCreated(hoItem)) Begin // Focused Cell // ~~~~~~~~~~~~ // Determine if we are in the focused cell.... Get ComFocusedColumn to vFocusedColumn Get ComFocusedRow to vFocusedRow If (IsSameComObject(llRow, vFocusedRow) and IsSameComObject(llColumn, vFocusedColumn)) Begin // Test if the cells in this column are editable.... Get Create U_cComReportColumn to hoColumn Set pvComObject of hoColumn to llColumn Get ComEditable of hoColumn to bEditable If (bEditable) Begin // Draw a fancy focus rectangle.... Move (CreatePen(PS_SOLID, 1, 13138532)) to hPen Move (SelectObject(hDC, hPen)) to hPenOld Move (RoundRect(hDC, llleft, lltop, llright-1, llbottom-1, 2, 2)) to bVoid Move (SelectObject(hDC, hPenOld)) to iVoid Move (DeleteObject(hPen)) to iVoid // Get the item text.... Get ComValue of hoItem to sText Move (sText + Character(0)) to sText // Draw the text.... Move (lltop + 1) to ARect.top Move (llleft + 2) to ARect.left Move (llbottom - 1) to ARect.bottom Move (llright - 1) to ARect.right Move (AddressOf(ARect)) to lpRect Move (AddressOf(sText)) to lpText Move (DrawText(hDC, lpText, -1, lpRect, DT_VCENTER + DT_LEFT)) to iVoid // Turn off default drawing.... Move False to llDoDefault End Send Destroy to hoColumn End End Send Destroy to hoItem End_Procedure // OnComDrawItem // OnComFocusChanging: // This event is triggered just before a user makes a selection of a cell. Procedure OnComFocusChanging Variant llNewRow Variant llNewColumn Variant llNewItem Boolean ByRef llCancel Variant vFocusedRow vFirstColumn Handle hoItem Forward Send OnComFocusChanging llNewRow llNewColumn llNewItem (&llCancel) If (not(llCancel) and not(IsNullComObject(llNewRow))) Begin // Test if we have changed rows.... Get ComFocusedRow to vFocusedRow If (not(IsSameComObject(llNewRow, vFocusedRow))) Begin // Remove the current row indicator icon from the old row.... Get ColumnComObjectFromColumnNumber 0 to vFirstColumn Get ItemProxyObjectFromRowAndColumn vFocusedRow vFirstColumn to hoItem If (hoItem <> 0) Begin Set ComIcon of hoItem to 0 End // Paint the current row indicator in the new row.... Get ItemProxyObjectFromRowAndColumn llNewRow vFirstColumn to hoItem If (hoItem <> 0) Begin Set ComIcon of hoItem to RC_ImageCurrentRow End End End End_Procedure // OnComFocusChanging // OnComSelectionChanged: // Occurs when a row is clicked by a mouse button or when a row is selected by moving // the Up and Down arrow keys. The onComFocusChanging event occurs right _before_ the selection // has changed. Procedure OnComSelectionChanged Variant vRow Handle hRow End_Procedure // OnComSelectionChanged // OnCreateGrid: Procedure OnCreateGrid Integer iColor Handle hoPaintManager // Set the shadowed column color to match the caption background color.... Get phoPaintManager to hoPaintManager Get ComCaptionBackColor of hoPaintManager to iColor Set piColumnShadowStateColor to iColor Send AddIcons Send AddColumns Send FillGrid End_Procedure // OnCreateGrid End_Object Cd_End_Object