ale1981 Posted November 6, 2014 Posted November 6, 2014 I am having a problem with updating a DTP control with the correct date once the script has ran, can somebody try this code for me; Turn your PC date back one day, run the code below, turn your PC date back to today and click the Update button, shouldn't the DTP update to the current date (@MDAY) or am I doing this wrong? The @MDAY is correct when written to the console. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> #include <WindowsConstants.au3> Global $g_hDTP Example() Func Example() Local $hGUI ; Create GUI $hGUI = GUICreate("(UDF Created) DateTimePick Create", 400, 300) $g_hDTP = _GUICtrlDTP_Create($hGUI, 2, 6, 190) $btnTest = GUICtrlCreateButton( "Update", 200, 6, 100, 20 ) GUISetState(@SW_SHOW) ; Loop until the user exits. ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btnTest btnTest() EndSwitch WEnd EndFunc Func btnTest() Local $sDate[7] = [ False, @YEAR, @MON, @MDAY, 0, 0, 0 ] _GUICtrlDTP_SetSystemTime( GUICtrlGetHandle($g_hDTP), $sDate ) ConsoleWrite( "MDAY: " & @MDAY & @CRLF ) EndFunc Thanks
bogQ Posted November 6, 2014 Posted November 6, 2014 (edited) _GUICtrlDTP_SetSystemTime( $g_hDTP, $sDate ) not _GUICtrlDTP_SetSystemTime( GUICtrlGetHandle($g_hDTP), $sDate ) when creating DTP with _GUICtrlDTP_Create it already returned a handle: Success: the handle to the DTP control. You cant get handle of a handle with GUICtrlGetHandle() , you need control ID in GUICtrlGetHandle() to get a handle , aldo you already have handle that you need, dont you? Edited November 6, 2014 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
ale1981 Posted November 6, 2014 Author Posted November 6, 2014 _GUICtrlDTP_SetSystemTime( $g_hDTP, $sDate ) not _GUICtrlDTP_SetSystemTime( GUICtrlGetHandle($g_hDTP), $sDate ) when creating DTP with _GUICtrlDTP_Create it already returned a handle: You cant get handle of a handle with GUICtrlGetHandle() , you need control ID in GUICtrlGetHandle() to get a handle , aldo you already have handle that you need, dont you? Thanks, this was correct in my example, but I am even more embarrassed to say why my actual script wasn't working! I had set the range of the DTP in my GUI code to the current date so no date could be selected past today, now when the next day arrived it wasn't updating because the range was still set to yesterday! I have now changed that so whenever I change the DTP it updates the range to the current day! I thought I would reply to help others but hopefully nobody else is stupid enough to make the same mistake as me!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now