TDBNavigator button click lazarus / 16-Databases ---------------------------------------------------------------------- andtag · 2010-03-11 17:42 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? ---------------------------------------------------------------------- andtag · 2010-03-12 12:24 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 · 2010-03-15 05:23 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 · 2010-03-15 16:25 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 · 2010-03-17 15:23 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,[loCaseInsens itive, 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