Time edit grid column for cCJGrid: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
Created page with "=== Author and origin === This example code was written by Raveen Sundram and comes from the following post at the forum: https://support.dataaccess.com/Forums/showthread.ph..."
 
m Fix category Codejock spelling into the expected one
 
(One intermediate revision by the same user not shown)
Line 22: Line 22:
</source>
</source>


We have been using custom (db)TimeForms courtesy of the [https://www.vdf-guidance.com/Projects.asp?Page=CWINDOWSEX cWindowEx project]
We have been using custom (db)TimeForms courtesy of the [https://www.vdf-guidance.com/Projects.asp?Page=CWINDOWSEX cWindowsEx project]


See [[File:TimeForm.png]]


But haven't been successful in mixing the class into a sub-classes cCJGridColumnEdit.


== Extend cDataTimePick.pkg ==


Found that cDateTimePick.pkg, from the cWindowsEx project, was missing the following:


<source lang="dataflex">
        Set External_Message WM_SETFOCUS        to External_SetFocus
        Set External_Message WM_KILLFOCUS      to External_KillFocus
</source>


[[Category:CodeJock]]
== cCJGridColumnTimeEdit ==
With that the cCJGridColumnTimeEdit now works.
 
<source lang="dataflex">
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
</source>
 
 
[[Category:Codejock]]

Latest revision as of 01:33, 2 March 2019

Author and origin

This example code was written by Raveen Sundram and comes from the following post at the forum:

https://support.dataaccess.com/Forums/showthread.php?63897-cCJGridColumnTimeEdit-anyone&p=341600#post341600

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:

    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

See


Extend cDataTimePick.pkg

Found that cDateTimePick.pkg, from the cWindowsEx project, was missing the following:

        Set External_Message WM_SETFOCUS        to External_SetFocus
        Set External_Message WM_KILLFOCUS       to External_KillFocus

cCJGridColumnTimeEdit

With that the cCJGridColumnTimeEdit now works.

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