MouseDown behaviour lazarus / 31-LCL ---------------------------------------------------------------------- Blaazen · 2011-06-06 23:12 Components TScrollBar, TTrackBar and others have this behaviour: When I press mouse button (not click but only press left mouse button and hold it down) then Knob moves. I don't have to click many times but I simply hold left mouse button. How can I make this with my own component (without using my own Timers) ? My component is derived from TCustomControl. I looked to sources of TScrollBar and I can't find anything there. Thanks. ---------------------------------------------------------------------- typo · 2011-06-06 23:33 What does your component do? ---------------------------------------------------------------------- Martin_fr · 2011-06-06 23:42 I believe you will need to instantiate a timer. Scrollbar is a widget provided by the OS or Qt/Gtk. The continues scroll behavior is implemented there. So Lazarus needs no timer, it get's messages from Win,Gtk or Qt. Why do you not want to use a timer? ---------------------------------------------------------------------- typo · 2011-06-07 00:33 Maybe you can extract something from this phenomenon: Code: [Select]procedure TForm1.Panel3MouseDown(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); var   N :integer = 0; begin   MouseCapture := True;   while MouseCapture do   begin     Panel3.Canvas.TextOut(0,0, IntToStr(N)+'----------');     Application.ProcessMessages;     Inc(n);   end; end; ---------------------------------------------------------------------- Blaazen · 2011-06-07 00:57 QuoteWhat does your component do?QuoteWhy do you not want to use a timer?It will be component similar to trackbar. I didn't want to use timer because I was looking for some simlpier (elegant) way. OK. For timer I need to know first longer delay and next shorter delays (they seem to be the same as for KeyPress). For example on my system it is 660 miliseconds between first and second repeat and 40 miliseconds between all next repeats. Can we access these constatns in Lazarus? Code: [Select]  MouseCapture := True;   while MouseCapture do   begin     Panel3.Canvas.TextOut(0,0, IntToStr(N)+'----------');     Application.ProcessMessages;     Inc(n);   end;This code (adapted) works but it is too fast (and hi CPU load). I had to insert "sleep(40)" into loop and it seems better.