Blank dates in DatePickers

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Blank dates in DatePickers

Post by Pablo César »

Hi all,

I believe this is a very old and very common demand not only for HMG and for many others languages (Java, VB, CSS, etc.).

At internet we can find many ways to do it but the most it carries some hassles and other could it becomes a serious problem.

By taking an example of C:\hmg.3.4.0\SAMPLES\Controls\DatePicker\DATEPICKER\Demo.prg by adding FORMAT " " (note a space in quoted) you will get this result:
Screen1.png
Screen1.png (8.62 KiB) Viewed 5007 times
In code language... on this example you just do this:
Screen2.png
Screen2.png (71.13 KiB) Viewed 5001 times
I hope to be useful for nice looking in your screen displaying. :P
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Blank dates in DatePickers

Post by danielmaximiliano »

Gracias por el TIP Pablo, para algunos será de mucha ayuda....
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Blank dates in DatePickers

Post by mustafa »

Hola Pablo César
Muy logrado , gracias por el aporte
Mustafa
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Blank dates in DatePickers

Post by serge_girard »

Thanks Pablo, I will try to remember it when I need it!

Serge
There's nothing you can do that can't be done...
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Blank dates in DatePickers

Post by Rathinagiri »

It is nice. But, no keyboard interface available if we use this. ie., we have to compulsorily use mouse to enter data.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
lalacas
Posts: 11
Joined: Fri Sep 19, 2014 8:27 am
Location: Spain

Re: Blank dates in DatePickers

Post by lalacas »

Gracias Pablo Cesar
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Blank dates in DatePickers

Post by luisvasquezcl »

Gracias Pablo por tu aporte.
Saludos cordiales,
Luis Vásquez.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Blank dates in DatePickers

Post by Pablo César »

You're welcome and is good to share knowledges with good friends.
Rathinagiri wrote:It is nice. But, no keyboard interface available if we use this. ie., we have to compulsorily use mouse to enter data.
I do not know Rathi what exactly you're trying to say with that. But I guess the same that I found when used FORMAT " " and seeing is not enough to fix data when is changed. And this occurs due the main reason there is not any format as property when inputed data. I saw it is necessary to re-apply the right format after input data in this control.

By using SetProperty(<cWindowName>, <cControlName>, "FORMAT", "dd/MM/yyyy") it will works very well.

But knowing HMG is used over the world and this format is not used the common usage in each country, we shall know how is Date Format was setted.

In Harbour we can use: cFormat := Set( _SET_DATEFORMAT ) to get current date format. But what we real need is in lpszFormat according doc in msdn ( https://msdn.microsoft.com/en-us/library/aa932380.aspx ) to correctly set it.

In hmgdoc at Controls\Dateicker you will find right use of date format. For example here in Brazil and most of latin american countries we use day/month/year but using Set( _SET_DATEFORMAT ) badly return wrong format like as "DD/MM/YYYY" after been used SET DATE BRITISH and SET CENTURY ON.

So, in this case, there's a internal HMG function to correct this discrepancy by using GetDateFormat() since HMG 3.4.1 version.

In source code words, you can add ON CHANGE event for DatePickers using like this:

ON CHANGE SetProperty ( ThisWindow.Name, This.Name, "FORMAT", GetDateFormat() );

For who wish to see HMG demo in SAMPLES (based on C:\hmg.3.4.0\SAMPLES\Controls\DatePicker\DATEPICKER\Demo.prg), see this:

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"

Function Main
Set Century On
Set Date British

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 600 HEIGHT 400 ;
		TITLE "HMG DatePicker Demo" ;
		MAIN ;
		FONT "Arial" SIZE 10

		@ 10,10 DATEPICKER Date_1 ; 
                VALUE CTOD("  /  /    ") ;
		TOOLTIP "DatePicker Control" ;
		ON CHANGE SetProperty ( ThisWindow.Name, This.Name, "FORMAT", GetDateFormat() );
		FORMAT "  "
		
		@ 10,310 DATEPICKER Date_2 ;
		VALUE CTOD("01/01/2001") ;
		TOOLTIP "DatePicker Control ShowNone RightAlign" ;
		SHOWNONE ;
		RIGHTALIGN ;
		ON CHANGE SetProperty ( ThisWindow.Name, This.Name, "FORMAT", GetDateFormat() );
		FORMAT " "

		@ 230,10 DATEPICKER Date_3 ;
		VALUE CTOD("01/01/2001") ;
		TOOLTIP "DatePicker Control UpDown" ;
		UPDOWN ;
		ON GOTFOCUS SetProperty ( ThisWindow.Name, This.Name, "FORMAT", GetDateFormat() );
		FORMAT " "

		@ 230,310 DATEPICKER Date_4 ;
		VALUE CTOD("01/01/2001") ;
		TOOLTIP "DatePicker Control ShowNone UpDown" ;
		SHOWNONE ;
		UPDOWN ;
		ON GOTFOCUS SetProperty ( ThisWindow.Name, This.Name, "FORMAT", GetDateFormat() );
		FORMAT " "

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil

/* Remove this for comments proposes, in case you need to work with HMG 3.4.1 OLDER versions.
Function GetDateFormat()
Local cRet:=Set( _SET_DATEFORMAT )

Return CharRepl("m",@cRet,"M")*/
I have related this to Harbour's forum and It would be nice to have a solution in Harbour when is used Set( _SET_DATEFORMAT ) but we have no other option, so let's use thru GetDateFormat() at meantimes.

B.Rgds
Keeping informed. :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply