#include #include #include #include #include #include #include dim $FieldNames = "" dim $adOpenStatic = 3 dim $adLockOptimistic = 3 dim $adLockReadOnly = 1 dim $adOpenKeySet = 1 Global $Listview, $rowData, $y, $retcode, $msg, $handle, $i Global $rowarray[4] ;For handling dates Global $YY,$MM,$DD,$HH,$MI,$SS,$FullDate Global $fieldCount = 4 Global $FieldArray[$fieldCount] Global $attr, $length $rowarray[0] = 3 $rowarray[1] = "item1" $rowarray[2] = "20220202083000" $rowarray[3] = "20220202093000" $FieldArray[0] = 3 $FieldArray[1] = "col1" $FieldArray[2] = "Date1" $FieldArray[3] = "Date2" createEdit() Func createEdit() Local $hGUI1 = GUICreate("Edit Record", 500, 700, 450, 100) Local $bInsert = GUICtrlCreateButton("Commit", 100, 10, 100, 25) Global $bGetDate = GUICtrlCreateButton("Get Date", 300, 10, 100, 25) GUICtrlSetState($bGetDate, $GUI_DISABLE) Global $InputMsg1 = GUICtrlCreateLabel("",100,300,200,25) Global $InputMsg2 = GUICtrlCreateLabel("",100,400,200,25) Global $InputMsg3 = GUICtrlCreateLabel("",100,500,200,25) Global $OAInput[4][3] ; _arraydisplay($rowarray) for $i = 1 to 3 GUISetFont(10, 600, -1, "Tahoma") GUICtrlCreateLabel($FieldArray[$i], 10, $i*40, 200) GUICtrlSetColor(-1, 0xFF0000) ; Red if $i <> 1 then $YY = stringmid($rowarray[$i],1,4) $MM = stringmid($rowarray[$i],5,2) $DD = stringmid($rowarray[$i],7,2) $HH = stringmid($rowarray[$i],9,2) $MI = stringmid($rowarray[$i],11,2) $SS = "00" $FullDate = $YY&"/"&$MM&"/"&$DD&" "&$HH&":"&$MI&":"&$SS $OAInput[$i][0] = GUICtrlCreateInput($FullDate, 10, $i*40+15, 300, 25) $OAInput[$i][1] = GUICtrlGetHandle($OAInput[$i][0]) else $OAInput[$i][0] = GUICtrlCreateInput($rowarray[$i], 10, $i*40+15, 300, 25) $OAInput[$i][1] = GUICtrlGetHandle($OAInput[$i][0]) $OAInput[$i][2] = "" endif next GUISetState(@SW_SHOW, $hGUI1) GUIRegisterMsg($WM_COMMAND, "Which_Input") While 1 Switch GUIGetMsg() $msg = GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ;GUIDelete($hGUI1) ;Return Case $bInsert GUICtrlSetState($bGetDate, $GUI_DISABLE) Case $bGetDate GetDate() EndSwitch WEnd EndFunc ;==>gui2 Func Which_Input($hWnd, $Msg, $wParam, $lParam) Local $iCode = BitShift($wParam, 16) Local $iIDFrom = BitAND($wParam, 0xFFFF) Local $NewInput, $OldInput, $Lost_Focus_Count = 0 ; Switch $lParam for $i = 0 to ubound($OAInput)-1 Switch $lParam Case GUICtrlGetHandle($OAInput[$i][0]) ;********************************************************* ; Check if in Date Field - If so then enable date button** ;********************************************************* if $i = 2 or $i = 3 then GUICtrlSetState($bGetDate, $GUI_ENABLE) else GUICtrlSetState($bGetDate, $GUI_DISABLE) endif Switch $iCode Case $EN_KILLFOCUS $OldInput = GUICtrlRead($OAInput[$i][0]) GUICtrlSetData($InputMsg1, $OldInput&" lost Focus") Case $EN_SETFOCUS $NewInput = GUICtrlRead($OAInput[$i][0]) GUICtrlSetData($InputMsg2, $NewInput&" has Focus") EndSwitch ; Switch $iIDFrom ; Case $bEdit ; GUICtrlSetData($InputMsg3, "Commit has Focus") ; EndSwitch EndSwitch Next Return $GUI_RUNDEFMSG EndFunc ;==>ED_WM_COMMAND Func GetDate() $hPopUP = GUICreate("Get date", 250, 200, Default, Default, $WS_POPUP) $idDate1 = GUICtrlCreateMonthCal("", 10, 10,Default, Default, $MCS_NOTODAY) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idDate1 ;MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate1), 2) $DatePick = GUICtrlRead($idDate1) GUIDelete($hPopUP) Return EndSwitch WEnd EndFunc