Sign in to follow this  
Followers 0
dpaynebrown

Trapping changes in a Date Picker control

3 posts in this topic

The situation:

I need to have two GUICtrlCreateDate-type controls on a form. One is used to input a starting date while the other is for an ending date. This of course, gives me a date range for reports. Furthermore, I need to make sure that the starting date is less than the ending date within the range.

The problem:

Other types of control notifications are easily handled by the GUIRegisterMsg function and the $WM_COMMAND constant. For example an Edit-type control has the $EN_SETFOCUS, $EN_KILLFOCUS, and $EN_CHANGE notifications. And each of them work spot-on.

But I've been unable to find similar solutions for the GUICtrlCreateDate control. How, for example, do I trap a date change prior to the control losing focus so it can be tested for a proper value? Same question for setting or losing focus. How is it done?

I've looked into the $DTN_DATETIMECHANGE, $NM_SETFOCUS, and $NM_KILLFOCUS notifications, but I cannot seem to get them to work. I intended to use them in the same manner as those mentioned for the Edit-type control, but have been unable to do so.

What am I missing?

- DPayneBrown

Share this post


Link to post
Share on other sites



The situation:

I need to have two GUICtrlCreateDate-type controls on a form. One is used to input a starting date while the other is for an ending date. This of course, gives me a date range for reports. Furthermore, I need to make sure that the starting date is less than the ending date within the range.

The problem:

Other types of control notifications are easily handled by the GUIRegisterMsg function and the $WM_COMMAND constant. For example an Edit-type control has the $EN_SETFOCUS, $EN_KILLFOCUS, and $EN_CHANGE notifications. And each of them work spot-on.

But I've been unable to find similar solutions for the GUICtrlCreateDate control. How, for example, do I trap a date change prior to the control losing focus so it can be tested for a proper value? Same question for setting or losing focus. How is it done?

I've looked into the $DTN_DATETIMECHANGE, $NM_SETFOCUS, and $NM_KILLFOCUS notifications, but I cannot seem to get them to work. I intended to use them in the same manner as those mentioned for the Edit-type control, but have been unable to do so.

What am I missing?

- DPayneBrown

Here is a rather hastily made example of the onchange bit

======================================================

;triggered in response to the control sending a wm_Notify message with

;the dtn_DateTimeChange notification code.

#include <GUIConstants.au3>

Global Const $DTN_FIRST = - 760

Global Const $DTN_DATETIMECHANGE = $DTN_FIRST + 1

Global Const $WM_NOTIFY = 0x004E

GUICreate ( "My GUI get date", 200,200,800,200)

$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

GUISetState ()

GUIRegisterMsg($WM_NOTIFY,"WM_Notify_Events")

; Run the GUI until the dialog is closed

Do

$msg = GUIGetMsg()

Until $msg = $GUI_EVENT_CLOSE

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)

#forceref $hWndGUI, $MsgID, $wParam

Local $tagNMHDR, $event

$tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)

If @error Then Return

$event = DllStructGetData($tagNMHDR, 3)

Select

Case $event = $DTN_DATETIMECHANGE

ConsoleWrite('changed' & @CRLF)

EndSelect

$tagNMHDR = 0

$event = 0

$lParam = 0

EndFunc;

#cs

DTN_FIRST = (0 - 760),

+ DTN_DATETIMECHANGE = (DTN_FIRST + 1),

+ DTN_USERSTRINGA = (DTN_FIRST + 2),

+ DTN_WMKEYDOWNA = (DTN_FIRST + 3),

+ DTN_FORMATA = (DTN_FIRST + 4),

+ DTN_FORMATQUERYA = (DTN_FIRST + 5),

+ DTN_DROPDOWN = (DTN_FIRST + 6),

+ DTN_CLOSEUP = (DTN_FIRST + 7),

+ DTN_USERSTRINGW = (DTN_FIRST + 15),

+ DTN_WMKEYDOWNW = (DTN_FIRST + 16),

+ DTN_FORMATW = (DTN_FIRST + 17),

+ DTN_FORMATQUERYW = (DTN_FIRST + 18)

#ce

===================================================


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks Martin!

Thanks to your reply I was able to not only test for a change in the date, but also to determine which control was changed.

DPayneBrown

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