Date Picker

Date Picker

Postby Armando » Sat Oct 29, 2005 2:20 pm

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

Re: Date Picker

Postby Enrico Maria Giordano » Sat Oct 29, 2005 5:13 pm

From FWH samples:

Code: Select all  Expand view
#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  Expand view
#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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Thanks

Postby Armando » Sat Oct 29, 2005 6:52 pm

Enrico:

Thanks a lot, it's very clear

Best Regards
User avatar
Armando
 
Posts: 3209
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Postby don lowenstein » Tue Nov 01, 2005 3:21 pm

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
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Date picker , empty date

Postby Frank Demont » Wed Nov 02, 2005 6:25 am

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

Re: Date picker , empty date

Postby StefanHaupt » Wed Nov 02, 2005 8:46 am

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

Dtepicker

Postby Frank Demont » Wed Nov 02, 2005 9:33 am

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

Postby RAMESHBABU » Wed Aug 09, 2006 12:19 pm

Hi

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

Regards

Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Empty dates?

Postby AlexSchaft » Thu May 22, 2008 10:25 am

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?
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Postby StefanHaupt » Thu May 22, 2008 3:10 pm

Alex,

that´s normal behavior of the windows api.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 69 guests