Welcome

Welcome, thanks to look my blog

Monday 18 January 2016

24 Hour format for Date time picker

24 Hour format for Date time picker

I use DateTimePicker component, Time mode. I want to set it's time format to 24 hour time format. How can I do this ?

//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;

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.UpdateFormatSettings := False;
ShortTimeFormat := 'HH:mm:ss';
end;

sumber:http://www.experts-exchange.com/questions/10264999/24-Hour-format-for-Date-time-picker.html

No comments:

Post a Comment