• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

TDATETIMEPICKER

Can tdatetimepicker component shows date in this format (dd/mm/yyyy) or (mm/dd/yyyy)????????????????????
0
Iamme
Asked:
Iamme
  • 5
  • 4
  • 2
  • +2
1 Solution
 
IammeAuthor Commented:
I need the answer........as fast you can
0
 
VendiCommented:
Look at the TDateTimeField.DisplayFormat property
0
 
VendiCommented:
Sorry, just reread your question.  I think the tdatetimepicker format comes from the regional settings of the computer, but I'm not sure.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
IammeAuthor Commented:
no I think tnat we can´t change the format .................i had tryed.....
0
 
intheCommented:
please try these different ways of setting the format:
 
(note upper/lowercase matters)

//Uses Commctrl;
procedure TForm1.FormCreate(Sender: TObject);
begin
SendMessage(DateTimePicker1.Handle,DTM_SETFORMAT, 0,LongInt(PChar('HH:mm:ss')));

//The format strings are what Windows allows in the Regional
// Settings for Time -  "HH" is military (24h time) and
//"hh" is 12 hour, adding "tt" to the end gets you the "am" / "pm", etc.

end;

//or with date and am/pm also:
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(DateTimePicker1.Handle,DTM_SETFORMAT, 0,LongInt(PChar('dd/MM/yyyy HH:mm:ss tt')));
end;

// or
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.UpdateFormatSettings := False;
ShortTimeFormat := 'HH:mm:ss';
end;
0
 
IammeAuthor Commented:
delphi doesn´t accept    DTM_SETFORMAT...............it says that it is undeclared............please help me...........
0
 
intheCommented:
add to Uses Commctrl;


did you try last method ?
0
 
IammeAuthor Commented:
yes the unit is alredy using.......and i tryed the last method......
can you tell me step by step????
I really need it..
0
 
lsaeCommented:
you could try setting the shortdateformat global variable (in case the dateformat = dfShort otherwise change the longdateformat variable) to 'dd/mm/yyyy' or
'mm/dd/yyyy' to accomplish this.

greetings;

Ludo
0
 
intheCommented:
did you try the last method i post:

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.UpdateFormatSettings := False;
ShortDateFormat := 'dd/MM/yyyy';
end;


or for the DTM_SETFORMAT you will have to use start-find and  search your harddrive for a *.pas   file that contains DTM_SETFORMAT then you will see what pas file to add to your uses..

for me it is declared in commctrl but maybe you can just add the const straight to your project :

procedure TForm1.Button1Click(Sender: TObject);
const
  {$EXTERNALSYM DATETIMEPICK_CLASS}
  DATETIMEPICK_CLASS = 'SysDateTimePick32';

  // Message constants
  {$EXTERNALSYM DTM_FIRST}
  DTM_FIRST         = $1000;
  {$EXTERNALSYM DTM_GETSYSTEMTIME}
  DTM_GETSYSTEMTIME = DTM_FIRST + 1;
  {$EXTERNALSYM DTM_SETSYSTEMTIME}
  DTM_SETSYSTEMTIME = DTM_FIRST + 2;
  {$EXTERNALSYM DTM_GETRANGE}
  DTM_GETRANGE      = DTM_FIRST + 3;
  {$EXTERNALSYM DTM_SETRANGE}
  DTM_SETRANGE      = DTM_FIRST + 4;
  {$EXTERNALSYM DTM_SETFORMATA}
  DTM_SETFORMATA    = DTM_FIRST + 5;
  {$EXTERNALSYM DTM_SETMCCOLOR}
  DTM_SETMCCOLOR    = DTM_FIRST + 6;
  {$EXTERNALSYM DTM_GETMCCOLOR}
  DTM_GETMCCOLOR    = DTM_FIRST + 7;
  {$EXTERNALSYM DTM_GETMONTHCAL}
  DTM_GETMONTHCAL   = DTM_FIRST + 8;
  {$EXTERNALSYM DTM_SETMCFONT}
  DTM_SETMCFONT     = DTM_FIRST + 9;
  {$EXTERNALSYM DTM_GETMCFONT}
  DTM_GETMCFONT     = DTM_FIRST + 10;
  {$EXTERNALSYM DTM_SETFORMATW}
  DTM_SETFORMATW    = DTM_FIRST + 50;
  {$EXTERNALSYM DTM_SETFORMAT}
  DTM_SETFORMAT     = DTM_SETFORMATA;
begin
SendMessage(DateTimePicker1.Handle,DTM_SETFORMAT, 0,LongInt(PChar('dd/MM/yyyy HH:mm:ss tt')));
end;

0
 
she3i3iCommented:
Iamme,

Simply do the following:

Start
Settings
Control Panel
Regional Settings

Move to the Date tab.

Change "Short Date Style" to either:
dd/MM/yyyy
or
MM/dd/yyyy

as you like.

If someone can do this programmatically, Id like to know how!


Chris.
0
 
she3i3iCommented:
P.S. Once you actually do that, remove and replace the TDateTimePicker component on the form in order for it to read the changes made to the system settings.

Cheers, Chris.
0
 
intheCommented:
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.UpdateFormatSettings := False;
ShortDateFormat := 'dd/MM/yyyy';
end;
0
 
IammeAuthor Commented:
hi.........she3i3i........are you women?....thank you...if a can do it programming,,,,I'll tell you.....but...your answer was ok....
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now