Date Picker

Post Reply
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Date Picker

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Date Picker

Post 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
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Thanks

Post by Armando »

Enrico:

Thanks a lot, it's very clear

Best Regards
User avatar
don lowenstein
Posts: 196
Joined: Mon Oct 17, 2005 9:09 pm
Contact:

Post 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.
Don Lowenstein
www.laapc.com
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Date picker , empty date

Post 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
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Date picker , empty date

Post 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
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Dtepicker

Post 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
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Hi

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

Regards

Ramesh Babu P
User avatar
AlexSchaft
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Empty dates?

Post 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?
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Alex,

that´s normal behavior of the windows api.
kind regards
Stefan
Post Reply