know when a scrollbar becomes visible. lazarus / 31-LCL ---------------------------------------------------------------------- taazz · 2013-07-26 11:48 on autoscroll components eg Tscrollbox or tform is there any mechanism that I could get notified when a scrollbar's visibilty state changes? I know there are no events but is there any method I could override and catch the change? ---------------------------------------------------------------------- howardpc · 2013-07-26 12:24 Does the IsScrollBarVisible function not meet your need? ---------------------------------------------------------------------- taazz · 2013-07-26 12:30 so I should place a timer on the form and pull its value constantly? ---------------------------------------------------------------------- taazz · 2013-07-26 12:40 after some more investigation it seems that I either need to find a windows message to catch or patch the TControlScrollBar to raise an event every time the ShowScrollBar api is called inside the UpdateScrollBar method. Hmm probably an enhancement for the team, an OnShowHide event which could pass the scroll bar as the sender or even a more customized event where you could influence the show process by changing the NewVisible value form the event. ---------------------------------------------------------------------- howardpc · 2013-07-26 12:42 You could use the OnIdle event and save a timer, or even add an OnPaint handler (rather a hack, I admit) to get the information. But there may be a better notification method. Perhaps you could use the message procedure CMVisibleChanged for the scrollbar? ---------------------------------------------------------------------- Martin_fr · 2013-07-26 12:47 What about placing the content of the Tscrollbox in an autosized panel. Then check if either the scrollbox or the panel fire OnResize? ---------------------------------------------------------------------- taazz · 2013-07-26 12:51 the onresize event gets my vote at this point thank you. ---------------------------------------------------------------------- Avishai · 2013-07-26 13:24 I tried this on Win7 and it seems to work. Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var   W: Integer; begin   W:= ListBox1.ClientRect.Right;   repeat     ListBox1.Height:= ListBox1.Height+1;   until (ListBox1.ClientRect.Right<>W)or(ListBox1.Height>150); end; ---------------------------------------------------------------------- Jurassic Pork · 2013-07-26 15:19 you can also test the delta between clientrect width of tlistbox and width of the tlisbox when the tlistbox onresize event is fired : Code: [Select]procedure TForm1.ListBox1Resize(Sender: TObject); begin if ((ListBox1.Width  - ListBox1.ClientWidth ) > 10 )  then     showMessage('VscrollBar  visible') else  showMessage('VscrollBar  not visible'); end; ---------------------------------------------------------------------- universe · 2013-10-18 15:34 Quote from: howardpc on July 26, 2013, 02:24:47 pmDoes the IsScrollBarVisible function not meet your need? This function is always returning false (Lazarus 1.1, Win32) ---------------------------------------------------------------------- taazz · 2013-10-18 16:27 Just a heads up I used a custom scrollbox like container where I made sure that the scrollbar raises an onshowhide event to solve this something along the lines of a virtualscrollbox based on the simplegraph container I ported, I did not use the resize idea because I do not trust lcl to work with out a problem when the containers is resized due to mouse or keyboard events when moving a control in the container with the mouse  for example it tends to fall in loops and raise exceptions (thank God for the exception). o until the resize mess is resolved I decided to stay away from it.