Page 1 of 1

Date Picker

Posted: Sat Oct 29, 2005 2:20 pm
by Armando
Could somebody send to me a small example to define in resources and to use in PRG file the DATE PICKER control ?

Regards

Re: Date Picker

Posted: Sat Oct 29, 2005 5:13 pm
by Enrico Maria Giordano
From FWH samples:

Code: Select all

#include "FiveWin.ch"
#include "dtpicker.ch"

FUNCTION Main()

   local oWnd, oSay
   local dDate := Date()

   DEFINE WINDOW oWnd TITLE "DTPicker from code ...."

   @ 2, 2 DTPICKER dDate OF oWnd ON CHANGE oSay:Refresh()

   @ 3, 30 SAY oSay PROMPT "Date: "+ Dtoc( dDate ) OF oWnd SIZE 200, 20

   @ 6, 2 BUTTON "From resources ..." OF oWnd ACTION FromRes( oWnd ) SIZE 150, 30

   ACTIVATE WINDOW oWnd

return nil

FUNCTION FromRes( oWnd )

   local oDlg, oSay
   local dDate := Date()

   DEFINE DIALOG oDlg RESOURCE "DTPTEST"

   REDEFINE DTPICKER dDate ID 101 OF oDlg ;
      ON CHANGE oSay:Refresh()

   REDEFINE SAY oSay PROMPT "Date: "+ Dtoc(dDate) ID 102 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return nil

procedure AppSys  // Xbase++ requirement

return

Code: Select all

#include "..\include\WinApi.ch"

DTPTEST DIALOG 6, 15, 207, 56
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "DTPicker test from resources ..."
FONT 8, "MS Sans Serif"
{
 DEFPUSHBUTTON "Close", IDOK, 148, 6, 50, 14
 CONTROL "", 101, "SysDateTimePick32", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 16, 13, 81, 11
 EDITTEXT 102, 16, 33, 81, 11
}
EMG

Thanks

Posted: Sat Oct 29, 2005 6:52 pm
by Armando
Enrico:

Thanks a lot, it's very clear

Best Regards

Posted: Tue Nov 01, 2005 3:21 pm
by don lowenstein
This is great - I've been looking for this for a long time.

Question - I am using your example in my application and have discovered that empty date variables will default to the current date, using the current TDatePick class.

How can I preserve the "empty date" in using this class?

One other question - if I want the users to "tab" through the entire field should it be coded within the KeyChar method within the class?

Thanks for any help with this. I'm exicted to finally find this functionality.

Date picker , empty date

Posted: Wed Nov 02, 2005 6:25 am
by Frank Demont
In the first versions from dtepicker , there was no possibility to have a empty date

I think that in fw 2.5 , there was a possibilty to have a checkbox that indicates that the date is empty (not sure)

For me : i have two problems with dtepicker :

1) Can not have empty date
2) When the user go to the calendar , on returning there is no visible focus , have to press the tab

So , i try now to use btnget , it seems to work well

Frank

Re: Date picker , empty date

Posted: Wed Nov 02, 2005 8:46 am
by StefanHaupt
Frank,

this code from Roberto Chiaiese may help you:

-----------------------------------------------
For those who are interested:

Using the class TDatePicker is possible to return an empty date only
using the DTS_SHOWNONE style.
Unchecking the flag it will return the empty date.
But if you pass an empty date as starting value then the datepicker
shows the today date and the checkbox is ON.
In this way if you have an editing window with a datepicker the user can
modify an empty date to today date without being aware of it.

below is the solution I found:
(using FWH 2.5)

#define DTS_SHOWNONE 2 // r.c. add: 05/09/2005
#define DTM_FIRST 0x1000 //
#define DTM_GETSYSTEMTIME (DTM_FIRST + 1) //
#define DTM_SETSYSTEMTIME (DTM_FIRST + 2) //
#define GDT_VALID 0 //
#define GDT_NONE 1 //

/* r.c. mod: 05/09/2005
METHOD SetDate( dDate ) INLINE SetDatePick( ::hWnd, Year( dDate ),;
Month( dDate ), Day( dDate ) )
*/
METHOD SetDate( dDate ) INLINE if( empty(dDate), ::SetNull(),;
SetDatePick( ::hWnd, Year( dDate ), Month( dDate ),;
Day( dDate )) )

METHOD SetNull() INLINE SendMessage(::hWnd,;
DTM_SETSYSTEMTIME, GDT_NONE )

(don't forget the following in the new() method:)

// r.c. add: DTS_SHOWNONE
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP,;
DTS_SHOWNONE,;
If( lDesign, WS_CLIPSIBLINGS, 0 ) )
-------------------------------------------------------------

best regards
Stefan

Dtepicker

Posted: Wed Nov 02, 2005 9:33 am
by Frank Demont
Stefan,

Yes, i know this.

But it seems that i have not the same dtepicker (fw2.5 on release)

I think that there be made changes afterwards

Frank

Posted: Wed Aug 09, 2006 12:19 pm
by RAMESHBABU
Hi

How to get the date in DD/MM/YYYY format from dtepicker ?

Regards

Ramesh Babu P

Empty dates?

Posted: Thu May 22, 2008 10:25 am
by AlexSchaft
Hi,

I have used these changes on fwh 7.12 date picker, but as soon as I specify the DTS_SHOWNONE style, I get a checkbox inside my control.

Is there a reason anybody knows why this is happening?

Posted: Thu May 22, 2008 3:10 pm
by StefanHaupt
Alex,

that´s normal behavior of the windows api.