Page 1 of 1

Blank dates in DatePickers

Posted: Thu Jun 18, 2015 1:15 pm
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 5026 times
In code language... on this example you just do this:
Screen2.png
Screen2.png (71.13 KiB) Viewed 5020 times
I hope to be useful for nice looking in your screen displaying. :P

Re: Blank dates in DatePickers

Posted: Thu Jun 18, 2015 1:16 pm
by danielmaximiliano
Gracias por el TIP Pablo, para algunos será de mucha ayuda....

Re: Blank dates in DatePickers

Posted: Thu Jun 18, 2015 3:30 pm
by mustafa
Hola Pablo César
Muy logrado , gracias por el aporte
Mustafa

Re: Blank dates in DatePickers

Posted: Thu Jun 18, 2015 5:47 pm
by serge_girard
Thanks Pablo, I will try to remember it when I need it!

Serge

Re: Blank dates in DatePickers

Posted: Mon Jun 22, 2015 8:19 am
by Rathinagiri
It is nice. But, no keyboard interface available if we use this. ie., we have to compulsorily use mouse to enter data.

Re: Blank dates in DatePickers

Posted: Mon Jun 22, 2015 8:45 am
by lalacas
Gracias Pablo Cesar

Re: Blank dates in DatePickers

Posted: Mon Jun 22, 2015 12:21 pm
by luisvasquezcl
Gracias Pablo por tu aporte.
Saludos cordiales,
Luis Vásquez.

Blank dates in DatePickers

Posted: Mon Jul 06, 2015 6:50 pm
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. :)