nend Posted March 6, 2019 Posted March 6, 2019 (edited) Is it possible to use a input control with a button next to it and when the button is clicked it opens the same calendar as the the GUICtrlCreateDate control (just like a popup).I want to select the date on the calendar and put the date by something like Guictrlsetdata to the input control. I don’t want to use GUICtrlCreateDate because I want to have a possibility to have a empty input field. I don’t have a clue how to make this, I made a small example code where I want this to work. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("", 320, 120) Local $idFile = GUICtrlCreateInput("", 10, 5, 230, 20) Local $idBtn = GUICtrlCreateButton("Calendar", 250, 5, 60, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn ; opens the popup calendar EndSwitch WEnd Edited March 6, 2019 by nend
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 (edited) @nend You could use something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> #include <WindowsConstants.au3> Global $hdlGUI = GUICreate("", 320, 120) Global $idDateTimePicker = _GUICtrlDTP_Create($hdlGUI, 10, 5, 230, 20) ; GUICtrlCreateDate("", 10, 5, 230, 20, $DTS_SHOWNONE) _GUICtrlDTP_SetFormat($idDateTimePicker, " ") Global $idBtn = GUICtrlCreateButton("Calendar", 250, 5, 60, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlDTP_Destroy($idDateTimePicker) ExitLoop Case $idBtn MsgBox($MB_ICONINFORMATION, "", GUICtrlRead($idDateTimePicker)) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR, _ $hdlWindowFrom, _ $intControlID_From, _ $intMessageCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return $hdlWindowFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $intMessageCode = DllStructGetData($tNMHDR, "Code") Switch $hdlWindowFrom Case $idDateTimePicker Switch $intMessageCode Case $DTN_CLOSEUP If GUICtrlRead($idDateTimePicker) <> 0 Then _GUICtrlDTP_SetFormat($idDateTimePicker, "dd/MM/yyyy HH:mm") EndSwitch EndSwitch $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc In few words, using the control create by _GUICtrlDTP_Create() function, you can set the format of the date to " ", in order to display no date (How to set a blank date to a DateTimePicker control). When you open the DateTimePicker control, and set a date, a format is set, so a date is set in the format you want. If you leave the DateTimePicker blank, the format is not set. In this way, you can have a blank (set to 0) DateTimePicker control Edited March 6, 2019 by FrancescoDiMuro Fr33b0w 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Nine Posted March 6, 2019 Posted March 6, 2019 or you may like this popup : GUICreate("Get date", 250, 200, Default, Default, $WS_POPUP) Local $idDate = GUICtrlCreateMonthCal("", 10, 10,Default, Default, $MCS_NOTODAY) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate), 2) Fr33b0w 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
nend Posted March 6, 2019 Author Posted March 6, 2019 @FrancescoDiMuro Thank for you reply, I will study this peache of code and look if it is possible to use it in my script.
nend Posted March 6, 2019 Author Posted March 6, 2019 @Nine Thanks I think that is what I'm looking for, I didn't know there was this function allready in AutoIT.
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