Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: C++ Berlin TDBNavigator - stop repeat timer on a nbNext button press


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


Permlink Replies: 3 - Last Post: Nov 3, 2017 10:07 AM Last Post By: Mark Richards Threads: [ Previous | Next ]
Mark Richards

Posts: 42
Registered: 12/8/99
C++ Berlin TDBNavigator - stop repeat timer on a nbNext button press  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2017 10:15 AM
Is it possible to disable the repeat timer on a TDBNavigator vcl component?

I understand it is basically a panel with TSpeedbuttons linked to dataset but it introduces an unwanted element for me, a repeat timer, that is, if you press the Next or Prior buttons, and don't release the mouse button, then the dataset scrolls until you do or start/end of dataset is reached.

I suffer from arthritis, and I am unable to always release the mouse button as quickly as 'normal' so often end up skipping several records, and If I do it, others must surely do it.

Can anyone help?

Thanks

Edited by: Mark Richards on Nov 2, 2017 10:16 AM

Mark Richards

Posts: 42
Registered: 12/8/99
Re: C++ Berlin TDBNavigator - stop repeat timer on a nbNext button press  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2017 10:43 AM   in response to: Mark Richards in response to: Mark Richards
I found two lines in Vcl.DBCtrls.pas


procedure TDBNavigator.InitButtons;
var
  I: TNavigateBtn;
  Btn: TNavButton;
  X, Y: Integer;
begin
  MinBtnSize := Point(20, 18);
  X := 0;
  Y := 0;
  for I := Low(Buttons) to High(Buttons) do
  begin
    Btn := TNavButton.Create(Self);
    Btn.Flat := Flat;
    Btn.Index := I;
    Btn.Visible := I in FVisibleButtons;
    Btn.Enabled := True;
    Btn.SetBounds (X, Y, MinBtnSize.X, MinBtnSize.Y);
    Btn.Enabled := False;
    Btn.Enabled := True;
    Btn.OnClick := ClickHandler;
    Btn.OnMouseDown := BtnMouseDown;
    Btn.Parent := Self;
    Buttons[I] := Btn;
    if Kind = dbnHorizontal then
      X := X + MinBtnSize.X
    else
      Y := Y + MinBtnSize.Y;
  end;
// Removed the following to prevent repeats on a mouse being key being held down!
//  Buttons[nbPrior].NavStyle := Buttons[nbPrior].NavStyle + [nsAllowTimer];
//  Buttons[nbNext].NavStyle  := Buttons[nbNext].NavStyle + [nsAllowTimer];
end;
 

relating to timers for nbNext and nbPrior, so I have copied the file into my project folder, remarked out the lines, and compiled the application. It now requires 1 click per move!

I have a working solution for this project, but I would prefer a method that doesn't involve altering system files, as they may change drastically in future updates.

Mark Richards wrote:
Is it possible to disable the repeat timer on a TDBNavigator vcl component?

I understand it is basically a panel with TSpeedbuttons linked to dataset but it introduces an unwanted element for me, a repeat timer, that is, if you press the Next or Prior buttons, and don't release the mouse button, then the dataset scrolls until you do or start/end of dataset is reached.

I suffer from arthritis, and I am unable to always release the mouse button as quickly as 'normal' so often end up skipping several records, and If I do it, others must surely do it.

Can anyone help?

Thanks

Edited by: Mark Richards on Nov 2, 2017 10:16 AM


Edited by: Mark Richards on Nov 2, 2017 10:44 AM
Alex Belo

Posts: 626
Registered: 10/8/06
Re: C++ Berlin TDBNavigator - stop repeat timer on a nbNext button press [Edit]
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 3, 2017 8:09 AM   in response to: Mark Richards in response to: Mark Richards
Mark Richards wrote:

procedure TDBNavigator.InitButtons;
...
// Removed the following to prevent repeats on a mouse being key
being held down
// Buttons[nbPrior].NavStyle := Buttons[nbPrior].NavStyle +
[nsAllowTimer];
// Buttons[nbNext].NavStyle := Buttons[nbNext].NavStyle +
[nsAllowTimer]; end;
...
relating to timers for nbNext and nbPrior, so I have copied the file
into my project folder, remarked out the lines, and compiled the
application. It now requires 1 click per move!

I have a working solution for this project, but I would prefer a
method that doesn't involve altering system files

Why not remove this option from NavStyle of navigator(s) in in form's
constructor:

dbn.Buttons[nbPrior].NavStyle:=
Buttons[nbPrior].NavStyle - [nsAllowTimer];
dbn.Buttons[nbNext].NavStyle:=
Buttons[nbNext].NavStyle - [nsAllowTimer];

Also you can create a descendant of TDBNavigator and remove unwanted
option right in its constructor; install this new component and use it
in appropriate cases.

--
Alex
Mark Richards

Posts: 42
Registered: 12/8/99
Re: C++ Berlin TDBNavigator - stop repeat timer on a nbNext button press [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 3, 2017 10:07 AM   in response to: Alex Belo in response to: Alex Belo
That made me look again at the .pas file, and I realised that what I actually would like to do is change the RepeatPause to be longer, so I tried to create a new component, but got the problem that the Navbutton uses const for InitRepeatPause and RepeatPause values, therefore I cannot adjust the values, but was able to build a component with the RepeatPause removed.

Alex Belo wrote:
Mark Richards wrote:

procedure TDBNavigator.InitButtons;
...
// Removed the following to prevent repeats on a mouse being key
being held down
// Buttons[nbPrior].NavStyle := Buttons[nbPrior].NavStyle +
[nsAllowTimer];
// Buttons[nbNext].NavStyle := Buttons[nbNext].NavStyle +
[nsAllowTimer]; end;
...
relating to timers for nbNext and nbPrior, so I have copied the file
into my project folder, remarked out the lines, and compiled the
application. It now requires 1 click per move!

I have a working solution for this project, but I would prefer a
method that doesn't involve altering system files

Why not remove this option from NavStyle of navigator(s) in in form's
constructor:

dbn.Buttons[nbPrior].NavStyle:=
Buttons[nbPrior].NavStyle - [nsAllowTimer];
dbn.Buttons[nbNext].NavStyle:=
Buttons[nbNext].NavStyle - [nsAllowTimer];

Also you can create a descendant of TDBNavigator and remove unwanted
option right in its constructor; install this new component and use it
in appropriate cases.

--
Alex
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02