PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Paul D. Elliott on May 13, 2005, 03:00:13 PM

Title: DateTimePicker lost focus ?
Post by: Paul D. Elliott on May 13, 2005, 03:00:13 PM
I'm trying to get the text from one DateTimePicker control when the user
tabs to the next control on the form and plug it into another
DateTimePicker control. But am having a problem ( as usual ). I wan to
do this even if the user didn't change the date.

The following code in the first DTP's Custom routine
doesn't seem to do anything. Can someone help?

Thanks.


 Select Case wMsg
       Case %WM_NOTIFY
         Local hdrX As NMDATETIMECHANGE Ptr
         
         Local txt As String
           hdrX = lParam
         
       

           If @hdrX.hdr.code = %NM_KILLFOCUS Then
           
               txt = FF_Control_GetText( HWND_FLAGDELIVERIES_DTPFLAGBATCHDATE)
               FF_Control_SetText HWND_FLAGDELIVERIES_DTPFLAGDELIVERDATE, txt
           End If
   End Select
Title: DateTimePicker lost focus ?
Post by: Paul D. Elliott on May 13, 2005, 07:53:43 PM
Gee, I can see not a lot of people are doing anything with these
controls judging by the responses ( or else they are busy doing
real work   :)  ).

So I put the following code into the DTN_DateTimeChange routine and
it works. But it gets called 3 times. I was hoping to only have to do
it once ( when the control lost focus ) but oh well. I'm still curious to
see if anyone knows why the above code doesn't do anything. For testing
I even did the update to a label control just to see what I was getting but
it never got updated.



Local pst As systemtime
   DateTime_GetSystemtime(HWND_FLAGDELIVERIES_DTPFLAGBATCHDATE, pst)
   DateTime_SetSystemtime(HWND_FLAGDELIVERIES_DTPFLAGDELIVERDATE, %GDT_VALID, pst)
Title: DateTimePicker lost focus ?
Post by: Roger Garstang on May 13, 2005, 10:25:51 PM
I think Kill/SetFocus won't work because there are usually multiple Child Controls in the Common controls and controls like Combos that have an Edit Control Child.  Sometimes the user may click the date too, etc.  Odd why the DateTimeChange is called 3 times though.  It just says it is called on a Change.  You sure there isn't something setting the time and making it loop, kinda like setting text in ENCHANGE of an Edit Box creates an endless loop.  Or maybe the time/date is clicked and it is sent then on losing focus it sends the message again, etc???
Title: DateTimePicker lost focus ?
Post by: Paul D. Elliott on May 14, 2005, 01:59:09 PM
the change function gets called once for the month then again for the
day then the third time for the year. I thought about puttting the
routines in the following field's getfocus but you never can be sure where
the user might click the mouse. as it is, it works. so I'll stick with that
until something better comes along.
Title: DateTimePicker lost focus ?
Post by: Roger Garstang on May 15, 2005, 06:54:15 PM
Ahhh, I see what you mean now.  Only other thing I can think of is maybe somehow using the Notification message or another message to see which piece of the control is losing focus and perhaps 3-4 different functions to handle what type of change was made- Day only, Month only, Year ony, All, etc.