Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Changing TTimeEdit intervals


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Feb 26, 2016 1:43 PM Last Post By: Knut Reckweg
Steven Wiberg

Posts: 28
Registered: 3/6/12
Changing TTimeEdit intervals  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2014 11:26 AM
I am using firemonkey in XE5 update 2 with hotfixes 1 and 3-6 installed (as 2 was for C++ builder)

I am building a mobile project for both iOS and android and have need of a TTimeEdit control; however, instead of using the time control as it exists I need it to only show 5 minute increments, so the user could only select say 10:00 am, 10:05 am, 10:10 am and so on.

Has anyone come across something like this?

Or does anyone have any suggestions as to how I could accomplish this as the basic TTimeEdit does not give this functionality.

Thanks in advance
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: Changing TTimeEdit intervals  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 27, 2014 2:28 PM   in response to: Steven Wiberg in response to: Steven Wiberg
Steven Wiberg wrote:
I am using firemonkey in XE5 update 2 with hotfixes 1 and 3-6 installed (as 2 was for C++ builder)

I am building a mobile project for both iOS and android and have need of a TTimeEdit control; however, instead of using the time control as it exists I need it to only show 5 minute increments, so the user could only select say 10:00 am, 10:00 am, 10:00 am and so on.

Has anyone come across something like this?

Or does anyone have any suggestions as to how I could accomplish this as the basic TTimeEdit does not give this functionality.

Thanks in advance

Not perfect but

unit UTimeEdit;
 
interface
 
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMX.DateTimeCtrls;
 
type
  TMyTimeEdit = class( TTimeEdit )
  protected
    procedure IncrementDateTimePart; override;
    procedure DecrementDateTimePart; override;
    procedure SetText(const AValue: string); override;
  end;
 
  TTimeEdit = class(  TMyTimeEdit );
 
  TForm3 = class(TForm)
    TimeEdit1: TTimeEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form3: TForm3;
 
implementation
 
{$R *.fmx}
uses
  FMX.DateTimeCtrls.Types, System.DateUtils;
 
{ TMyTimeEdit }
 
procedure TMyTimeEdit.DecrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.IncrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.SetText(const AValue: string);
var
  TempTime: TDateTime;
  OutMin : integer;
begin
  if TryStrToDateTime(AValue, TempTime, FormatSettings) then
    begin
      OutMin := MinuteOf( TempTime ) mod 5;
      inherited SetText( TimeToStr( TempTime - OutMin * ( 1 / ( 24 * 60 )), FormatSettings ));
    end;
end;
 
end.


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Steven Wiberg

Posts: 28
Registered: 3/6/12
Re: Changing TTimeEdit intervals  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 4, 2014 2:32 PM   in response to: Linden ROTH in response to: Linden ROTH
Linden ROTH wrote:
Steven Wiberg wrote:
I am using firemonkey in XE5 update 2 with hotfixes 1 and 3-6 installed (as 2 was for C++ builder)

I am building a mobile project for both iOS and android and have need of a TTimeEdit control; however, instead of using the time control as it exists I need it to only show 5 minute increments, so the user could only select say 10:00 am, 10:00 am, 10:00 am and so on.

Has anyone come across something like this?

Or does anyone have any suggestions as to how I could accomplish this as the basic TTimeEdit does not give this functionality.

Thanks in advance

Not perfect but

unit UTimeEdit;
 
interface
 
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMX.DateTimeCtrls;
 
type
  TMyTimeEdit = class( TTimeEdit )
  protected
    procedure IncrementDateTimePart; override;
    procedure DecrementDateTimePart; override;
    procedure SetText(const AValue: string); override;
  end;
 
  TTimeEdit = class(  TMyTimeEdit );
 
  TForm3 = class(TForm)
    TimeEdit1: TTimeEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form3: TForm3;
 
implementation
 
{$R *.fmx}
uses
  FMX.DateTimeCtrls.Types, System.DateUtils;
 
{ TMyTimeEdit }
 
procedure TMyTimeEdit.DecrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.IncrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.SetText(const AValue: string);
var
  TempTime: TDateTime;
  OutMin : integer;
begin
  if TryStrToDateTime(AValue, TempTime, FormatSettings) then
    begin
      OutMin := MinuteOf( TempTime ) mod 5;
      inherited SetText( TimeToStr( TempTime - OutMin * ( 1 / ( 24 * 60 )), FormatSettings ));
    end;
end;
 
end.


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Ya that kind of worked, but not exactly what I was going for, just going to go ahead and build my own control instead.

I don't want the user to even be able to see the times between 10:00 and 10:05 and after digging around in the components found it easier to just make my own.
Knut Reckweg

Posts: 1
Registered: 5/4/07
Re: Changing TTimeEdit intervals  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2016 1:43 PM   in response to: Steven Wiberg in response to: Steven Wiberg
I'm just running into the same problem.
Did you build that component and would you share it with us - or at least me ;-) ?

Steven Wiberg wrote:
Linden ROTH wrote:
Steven Wiberg wrote:
I am using firemonkey in XE5 update 2 with hotfixes 1 and 3-6 installed (as 2 was for C++ builder)

I am building a mobile project for both iOS and android and have need of a TTimeEdit control; however, instead of using the time control as it exists I need it to only show 5 minute increments, so the user could only select say 10:00 am, 10:00 am, 10:00 am and so on.

Has anyone come across something like this?

Or does anyone have any suggestions as to how I could accomplish this as the basic TTimeEdit does not give this functionality.

Thanks in advance

Not perfect but

unit UTimeEdit;
 
interface
 
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMX.DateTimeCtrls;
 
type
  TMyTimeEdit = class( TTimeEdit )
  protected
    procedure IncrementDateTimePart; override;
    procedure DecrementDateTimePart; override;
    procedure SetText(const AValue: string); override;
  end;
 
  TTimeEdit = class(  TMyTimeEdit );
 
  TForm3 = class(TForm)
    TimeEdit1: TTimeEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form3: TForm3;
 
implementation
 
{$R *.fmx}
uses
  FMX.DateTimeCtrls.Types, System.DateUtils;
 
{ TMyTimeEdit }
 
procedure TMyTimeEdit.DecrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.IncrementDateTimePart;
var
  i : integer;
  DTPart: TDTFormatPart;
begin
  inherited;
  if FindCurrentFormatPart(DTPart) and CanInput then
    if DTPart.Part = TDTPart.Minute then//tpMin is Depricated in XE6
      for I := 2 to 5 do
        inherited;
end;
 
procedure TMyTimeEdit.SetText(const AValue: string);
var
  TempTime: TDateTime;
  OutMin : integer;
begin
  if TryStrToDateTime(AValue, TempTime, FormatSettings) then
    begin
      OutMin := MinuteOf( TempTime ) mod 5;
      inherited SetText( TimeToStr( TempTime - OutMin * ( 1 / ( 24 * 60 )), FormatSettings ));
    end;
end;
 
end.


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Ya that kind of worked, but not exactly what I was going for, just going to go ahead and build my own control instead.

I don't want the user to even be able to see the times between 10:00 and 10:05 and after digging around in the components found it easier to just make my own.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02