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
Has thanked: 100 times
Been thanked: 182 times

Blank dates in DatePickers

Post by Pablo César » Thu Jun 18, 2015 1:15 pm

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 2979 times
In code language... on this example you just do this:
Screen2.png
Screen2.png (71.13 KiB) Viewed 2973 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: 2150
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 162 times
Been thanked: 26 times
Contact:

Post by danielmaximiliano » Thu Jun 18, 2015 1:16 pm

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

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
mustafa
Posts: 839
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 120 times
Contact:

Post by mustafa » Thu Jun 18, 2015 3:30 pm

Hola Pablo César
Muy logrado , gracias por el aporte
Mustafa

User avatar
serge_girard
Posts: 2345
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 589 times
Been thanked: 124 times
Contact:

Post by serge_girard » Thu Jun 18, 2015 5:47 pm

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

Serge

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Mon Jun 22, 2015 8:19 am

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

Post by lalacas » Mon Jun 22, 2015 8:45 am

Gracias Pablo Cesar

User avatar
luisvasquezcl
Posts: 1142
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 14 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Mon Jun 22, 2015 12:21 pm

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
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Mon Jul 06, 2015 6:50 pm

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