Solved

looking for Time Picker

Posted on 2004-09-17
8
397 Views
Last Modified: 2010-05-18
Hi

I am looking for a Time Picker Control (not datetime) where I can specify the minimum and maximum times that can be selected.

Any ideas?

Voodooman
0
Comment
Question by:Voodooman
8 Comments
 
LVL 17

Assisted Solution

by:mokule
mokule earned 25 total points
Comment Utility

What about TDateTimePicker set Kind to dtkTime and use OnChange event.
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 25 total points
Comment Utility
yeah mokule, was suggesting the same :)
....here an example:

procedure TForm1.FormCreate(Sender: TObject);
begin
datetimepicker1.Kind :=  dtkTime;
datetimepicker1.DateTime := strtotime('10.00.00');
end;

procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
if (datetimepicker1.Time > strtoTime('22.00.00')) or
   (datetimepicker1.Time < strtotime('10.00.00')) then begin
      Showmessage('Time must be between 10.00.00 and 22.00.00');
      datetimepicker1.Time := strtotime('10.00.00');
   end;
end;

F68 ;-)
0
 
LVL 5

Author Comment

by:Voodooman
Comment Utility
Hi

Sorry guys its not what I'm looking to do.

I could do this when I validate the data on the form.

When I load the popup, I want to prevent the users from selecting outside the limits of the day (that I set).

I don't want to work around it - this is a very nice high end piece of softare - hence I need to deal with the problem - not work around it!

Thanks

Voodooman
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
--> When I load the popup
I first place you just said '...where I can specify the minimum and maximum times that can be selected...'

Maybe if you give more info about your needs we can suggest something more than a 'workaround', but for what is knowed until now mokule suggestion is an answer, not just a workaround....

What do you mean with 'when i load the popup'? what is the situation?

F68 ;-)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 22

Expert Comment

by:mnasman
Comment Utility
Hello

Do you mean you want to prevent the user to choose date out of the range you woud like to set?

if so then use MinDate and MaxDate to set the range for the TDateTimePicker

uses
  DateUtils ;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DateTimePicker1.MinDate := IncDay(Date,-5);
  DateTimePicker1.MaxDate := Date;
end;
0
 
LVL 5

Author Comment

by:Voodooman
Comment Utility

Firstly - apologies if anyone thought I was being unappreciative of the answers - this is not the case.  I try to help with answers, and I have been on EE for 5 years - mostly in the VB area - where I have answered hundreds of questions and hopefully helped some people.

F68 - I was quite clear in what I asked for - its a time picker where I can select the maximum and minimum times that a user can select.

The popup is a modal form where the user edits appointments.  The appointments must only be possible within the working day.

When I save the record I can easily tell the user that the time the user has selected is outside of the day.

If I wanted to do that I would do it.  The professional approach is to prevent the user making the mistake in the first place.

I would like a control like Lotus Organiser (if you havent seen it you wouldnt know what I mean) - lathough any control that limited the day (e.g. 08:00 - 17:00) would do.

Lotus use a drop down slider to adjust the time - it is fast and efficient and is limited to the extent of the day setup.

I was hoping that one of the experts may have seen such a control - bearing in mind the large number of excellent controls that there are for Delphi - surely one of the main reasons for using Delphi.

Voodooman
0
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
1) As Mocule said, adjust it to Kind of dtkTime and you will be able to change only time. Then using methods ReplaceDate and ReplaceTime you can make the DateTime you need.

2) http://www.torry.net/pages.php?id=297
0
 
LVL 5

Author Comment

by:Voodooman
Comment Utility
Hi

I have found a control that works for me - TADVSpinEdit from http://www.TMSSoftware.com.  Luckily I have bought this already as part of a package (I think it is also on the Delphi7 Companion CD).

This spin edits the time.

With this, the user cannot type into the box - they can only increment the time up and down with the spin button.

This has the advantage that the user can see when they have reached the top or bottom of the limit - without having to be told with a message box.

Using a simple bit of code under the change event the time spins only with the limits.

if strtotime(spintime.Text)<strtotime('10:00') then
        spintime.Text:='10:00';

     if strtotime(spintime.Text)>strtotime('17:00') then
        spintime.Text:='17:00';

By doing this I can make sure that users cannot set appointments out of the day without nagging them.  It also allows different ranges to be used on different days (e.g. Half Day on Saturday).

I will split the points between Mokule and F68 - thanks for the idea, and thanks all for the help!

Voodoman
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now