Time edit grid column for cCJGrid
From DataFlex Wiki
Author and origin
This example code was written by Raveen Sundram and comes from the following post at the forum:
The need for a cCJGridColumnEdit class
We want to create a cCJGridColumnEdit class that uses the Windows CommonCtrl called 'ICC_DATE_CLASSES' for time based input.
Time based input using the standard forms/columnedits just do not work well.
Example:
1 2 3 4 5 6 7 | Object oCJOpenTimeColumn is a cCJGridColumn Set piWidth to 159 Set psCaption to "Open" Set peDataType to Mask_Time Set psMask to "h:mm tt" Set phcEditClass to (RefClass(cCJGridColumnTimeEdit)) End_Object |
We have been using custom (db)TimeForms courtesy of the cWindowsEx project
Extend cDataTimePick.pkg
Found that cDateTimePick.pkg, from the cWindowsEx project, was missing the following:
1 2 | Set External_Message WM_SETFOCUS to External_SetFocus Set External_Message WM_KILLFOCUS to External_KillFocus |
cCJGridColumnTimeEdit
With that the cCJGridColumnTimeEdit now works.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | Use cCJGridColumnEdit . pkg Use cDateTimePick . pkg // from cWindowEx Project Class cCJGridColumnTimeEdit is a cCJGridColumnEdit Procedure Construct_Object Forward Send Construct_Object Send Define_DateTimePick_Mixin Set pbShowNone to False Set pbUpDown to True Set pbTimeFormat to True Set pbRightAlign to True Set FontWeight to FW_NORMAL End_Procedure // Construct_Object Import_Class_Protocol DateTimePick_Mixin Procedure End_Construct_Object Forward Send End_Construct_Object Send InitCommonControlsEx ICC_DATE_CLASSES End_Procedure // Construct_Object Function Form_Window_Handle Integer iItem Returns Handle Handle hWnd Forward Get Form_Window_Handle iItem to hWnd If (hWnd= 0 ) Get Window_Handle to hWnd Function_Return hWnd End_Function Procedure Set Value Integer iItem String sValue Forward Set value item iItem to sValue Send SetDateTimePickValue sValue End_Procedure Function Value Returns String String sValue Forward Get value to sValue If (Window_Handle( Self )) Get GetDateTimePickValue to sValue Function_Return sValue End_Function Procedure Set Form_Mask Integer iItem String sMask Move (Replace( "ap" ,sMask, "tt" )) to sMask Set psFormMask to sMask End_Procedure Function Form_Mask Integer iItem Returns String String sMask Get psFormMask to sMask Function_Return sMask End_Function Function Status_Help Integer iItem Returns String String sHelp Integer iItm If (Num_Arguments> 0 ) Move iItem to iItm Forward Get Status_Help iItm to sHelp Function_Return sHelp End_Function End_Class |