Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

spinner for Ttime data type?

Posted on 2002-07-02
6
Medium Priority
?
238 Views
Last Modified: 2010-04-04
Hi,

Is there any spinner control for ttime data type?

it must be in the format of hh:nn (24 hours), no AM/PM

thanks.
0
Comment
Question by:llkhor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:alanwhincup
ID: 7125455
I couldnt find a pre-made component to do this but you could do something like below:

Stick a TEdit and a TUpDown on a form and then use the below code:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Can all be set in Object Inspector if you wanted to.
  Edit1.ReadOnly := True;
  UpDown1.Max := 32767;  // Max value of UpDown.Max property
  UpDown1.Min := -32768; // Min value of UpDown.Max property
end;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
var
  Hours, Minutes : ShortInt;
  Temp : string;
begin
  Hours := StrToInt(Copy(Edit1.Text, 1, 2));
  Minutes := StrToInt(Copy(Edit1.Text, 4, 2));
  if Button = btNext then
    Inc(Minutes)
  else
    Dec(Minutes);
  if Minutes > 59 then
  begin
    Minutes := 0;
    Inc(Hours);
  end;
  if Minutes < 0 then
  begin
    Minutes := 59;
    Dec(Hours);
  end;
  if (Hours > 23) and
     (Minutes > 0) then
  begin
    Hours := 0;
    Minutes := 0;
  end;
  if Hours < 0 then
  begin
    Hours := 24;
    Minutes := 0;
  end;
  if Length(IntToStr(Hours)) = 1 then
    Temp := '0' + IntToStr(Hours) + ':'
  else
    Temp := IntToStr(Hours) + ':';
  if Length(InttoStr(Minutes)) = 1 then
    Temp := Temp + '0' + IntToStr(Minutes)
  else
    Temp := Temp + IntToStr(Minutes);
  Edit1.Text := Temp;
end;

If you wanted it so users can enter data in as well, then you could use the same code along with a maskedit instead of a editbox.

Cheers,

Alan
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7126536
does not have the datetimepicker a spinner,
if datekind is set to dktime?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7126658
just for setting the format you want use

datetimepicker1.perform(DTM_SETFORMAT, 0, longint(pchar('YourTimeFormatString')));

sample
datetimepicker1.perform(DTM_SETFORMAT, 0, longint(pchar('hh:nn')));

not tested, but should work

meikl ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:llkhor
ID: 7142220
thanks for your reply.


alanwincup,

I'm actually looking for a ready made component or the standard components, with little or no coding needed. Anyhow, thanks for your code, it works.


kretzschmar,
I get undefined variable DTM_SETFORMAT when i tried out the code. I think datetimepicker's spin function supports only 12 hour format, but what i need is 24 hours format.

quenstion is, could I set datetimepicker to 24 hours format?

Thanks.






0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 150 total points
ID: 7142547
0
 

Author Comment

by:llkhor
ID: 7155971
thanks kreztschmar,

it works.  but need to change the format string to 'HH:MM' for the 24 hours format.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question