Sign in to follow this  
Followers 0
Yaerox

No way to change Time in a DateControl?

5 posts in this topic

#1 ·  Posted (edited)

Hey guys,

I wrote a little Testscript to show my Problem.

I want to set the Date-Control to e.g. "11:30:00" but i dont get this running:

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
Opt("GUIOnEventMode", 1)
Local $hGUI = GUICreate("", 160, 30)
Local $hDate = GUICtrlCreateDate($hGUI, 5, 5, 100, 20, $DTS_TIMEFORMAT)
Local $hButton = GUICtrlCreateButton("OK", 110, 5, 45, 20)

GUICtrlSetOnEvent($hButton, "_SetData")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI)

GUISetState(@SW_SHOW, $hGUI)

While 1
Sleep(100)
WEnd

Func _SetData()
GUICtrlSetData($hDate, "11:30:00")
If @error <> 1 Then MsgBox(0,"",@error)
EndFunc

Func _Exit()
Exit
EndFunc

I read the HelpFiles of GUICtrlSetData, GUICtrlSendMsg, GUICtrlCreateDate and some UDF HelpFiles but I dont get this :/

Regards

Edited by MikeWenzel

Share this post


Link to post
Share on other sites



Two bugs in your script:

  • Parameter 1 for GUICtrlCreateDate isn't the handle of the GUI but the start date/time. When set to "" the current date/time is used.
  • GUICtrlSetData needs the full date/time. You just display the time but the control is for date and time. So use GUICtrlSetData($hDate, "2013/02/22 11:30:00")to set the time

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Well yeah also tried the UDF DTP therefore the $hGUI ... my mistake.

"GUICtrlSetData($hDate, "2013/02/22 11:30:00") to set the time" facepalm "-.-

Thanks alot.

Share this post


Link to post
Share on other sites

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Maybe you trigger an error in the future

GUICtrlCreateDate
returns a ControlID of the resprective Date Control, its an integer not a handle

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0