0

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

AirWolf
  • 597
  • 7
  • 27
  • What is scrollbarpos? I cannot see its declaration. And again, why can't we have an SSCCE? – David Heffernan Nov 18 '13 at 07:35
  • I don't know about your application, but we always disable `Scaled` for our forms to avoid any DPI related differences. – jpfollenius Nov 18 '13 at 07:37
  • i uploaded a sample project for you to see. – AirWolf Nov 18 '13 at 07:57
  • @jpfollenius Why would you do that? Do you only expect your application to be used by people with 20/20 vision? What you are actually "avoiding" is you the programmer having to make your application pay its taxes. – David Heffernan Nov 18 '13 at 11:30
  • the main idea is that the scrollbox can grow depending on the items putted in there, so i need an easy way to scroll it in runtime can anyone give me a simple example? – AirWolf Nov 18 '13 at 11:36
  • @DavidHeffernan Because we need our applications look **exactly** the same independent of any Windows settings. Of course that might be a special case that's why I started with "I don't know about your application". – jpfollenius Nov 18 '13 at 12:33

0 Answers0