Recent

Author Topic: TDBNavigator button click  (Read 11069 times)

andtag

  • Newbie
  • Posts: 4
TDBNavigator button click
« on: March 11, 2010, 06:42:26 pm »
Hello,
I have a DB with 400 records and clicking the next button i can see the next record. If i want to reach record 200 i must do 200 clicks.
I want to have a continue action pressing the dbnavigator button, for example, when i click Next button, i want the records go forward until i leave the button. Is possible to do?
« Last Edit: March 11, 2010, 10:08:06 pm by andtag »

andtag

  • Newbie
  • Posts: 4
Re: TDBNavigator button click
« Reply #1 on: March 12, 2010, 01:24:03 pm »
nobody can help me? Any solution will be welcome for do what i need, please... maybe with normal button: exists a function for know if a button is pressed down, not only a click?

mrmikehicks

  • New Member
  • *
  • Posts: 39
Re: TDBNavigator button click
« Reply #2 on: March 15, 2010, 06:23:57 am »
I think you can use the 'OnMouseDown' event handler and put in code that advances the dbnavigator while the mouse is down. This is not tested code but you'll get the idea.

The dbnavigator buttons are: nbFirst,nbPrior,nbNext,nbLast,nbInsert,nbDelete
nbEdit,nbPost,nbCancel,nbRefresh

Create a boolean variable 'mouseup' and set it to false in the OnMouseDown event
(there are OnMouseDown and OnMouseUp event handlers in the dbnavigator)

You probably need some sort of timer to time how many times per second
you click the dbnavigator button. I found a neat little delay snippet on the web.

So, putting it all together:
1. Make the mouseup boolean variable global in scope by putting it in the implementation section of your code.

...
implementation
var mouseup: boolean;
...

// delay in milliseconds, uses the system time, also uses
// Application.ProcessMessages, which allows access to other events
// during the delay, the Win32 API function Sleep() does not
//
procedure Tform.Delay(msecs: integer);
var
  FirstTickCount: longint;
begin
  FirstTickCount := GetTickCount;
   repeat
     Application.ProcessMessages;
   until ((GetTickCount-FirstTickCount) >= Longint(msecs));
end;

procedure Tform.dbnavigator_itemMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   mouseup := false; // we got here by a mouse down event
   while not mouseup do begin // keep at it as long as mouse_btn is down
      //  wait one second
     delay(1000); // 1000 mS = second
     dbnavigator_file.BtnClick(nbNext);
     // do anything else you need to do
   end;
end;
procedure Tform.dbnavigator_itemMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   mouseup := true;
end;

This will get you started at least I hope.
     Mike
   



andtag

  • Newbie
  • Posts: 4
Re: TDBNavigator button click
« Reply #3 on: March 15, 2010, 05:25:12 pm »
thank you mrmike, effectively in this days waiting a reply, i've used mousedown and mouseup property and two timers for emulate the action loop with 2 external buttons (prior and next).
For now is ok and works fine, but i believe an internal property on dbnavigator will be more elegant and useful. Strange that nobody need this feature :)

Thank you again.
Andy.

DougNettleton

  • Jr. Member
  • **
  • Posts: 84
Re: TDBNavigator button click
« Reply #4 on: March 17, 2010, 04:23:51 pm »
The reason "nobody need this feature" is because nobody moves through a database this way. Presumably, you're not always going to the 200th record, rather you're holding the button down 'til you get near the desired record - so probably you recognize it.  Try implementing some "search" capability.  Something like ...

procedure TFundEmployerForm.SearchBtnClick(Sender: TObject);
begin
  if EmployerNumberItem.Checked then
    UbpsDataMod.EmployerQry.Locate('emprnumb',Edit1.Text,[loPartialKey])
  else
    UbpsDataMod.EmployerQry.Locate('emprname',Edit1.Text,[loCaseInsensitive, loPartialKey]);
end;

I usually, browse with a DBGrid on one page of a TPageControl and the interesting data for the selected record on one or more other pages.  Clicking on the "empty space" of the vertical scroll bar works even better than what you want, it moves through "grid pages" with each click and holding the mouse down continues the operation until the "slider" gets to the mouse pointer or you take your finger off the mouse.

HTH,

Doug

 

TinyPortal © 2005-2018