Hi guys after 3 days of not finding the right answer i come to you for help :) , so my question is this i have a TScrollBox component in my form and i create TImage components at FormCreate event this fills up the Scroll-box with components but when i want to scroll through them using Scroll-by it goes way beyond the end of the last component, the code will run on 2 buttons and mouse wheel 1 button left 2 button right and mouse wheel either sides
procedure TForm1.RightButtonClick(Sender: TObject);
var
Coff : Double;
begin
Coff := 6.6;
scrollbarpos := scrollbarpos - 100;
if((scrollbarpos>= -Coff * screen.PixelsPerInch) AND (scrollbarpos<=0)) then
begin
ScrollBox1.ScrollBy(-100,0);
end
else
begin
scrollbarpos := scrollbarpos + 100;
if(scrollbarpos < -(Coff /2) * screen.PixelsPerInch) then
begin
ScrollBox1.ScrollBy(-Round(scrollbarpos+Coff *screen.PixelsPerInch),0);
scrollbarpos := round( -Coff * screen.PixelsPerInch);
end;
end;
end;
this code works but when i change my "Control Panel\Appearance and Personalization\Display" settings from smaller - 100% to medium or large it goes beyond the last component, it has something to do with the Coff value. Any ideas of a more effective way to scroll without using scroll bars because they are invisible.
Project can be found here: http://www.failai.lt/i9famvv1my9f/proj.rar.htm