FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Date Picker
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Date Picker
Posted: Sat Oct 29, 2005 02: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

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Date Picker
Posted: Sat Oct 29, 2005 05:13 PM
From FWH samples:

#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


#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
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Thanks
Posted: Sat Oct 29, 2005 06:52 PM

Enrico:

Thanks a lot, it's very clear

Best Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Date Picker
Posted: Tue Nov 01, 2005 03: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
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Date picker , empty date
Posted: Wed Nov 02, 2005 06: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

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Date picker , empty date
Posted: Wed Nov 02, 2005 08: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

kind regards

Stefan
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Dtepicker
Posted: Wed Nov 02, 2005 09: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

Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Date Picker
Posted: Wed Aug 09, 2006 12:19 PM

Hi

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

Regards

Ramesh Babu P

Posts: 172
Joined: Fri Oct 07, 2005 01:29 PM
Empty dates?
Posted: 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?

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Date Picker
Posted: Thu May 22, 2008 03:10 PM

Alex,

that´s normal behavior of the windows api.

kind regards

Stefan

Continue the discussion