Link to home
Start Free TrialLog in
Avatar of 1bdev
1bdev

asked on

Dragging a Timage in scrollBox

Sorry for my bad English...
I would like to move at runtime an image with the mouse, inside a scrollbox like in PaintShop Pro or others graphic programs.
I need this when the Image is greater than the scrollbox dimensions.I have tried some solutions but when I move the image, I get Flickering.
Avatar of viktornet
viktornet
Flag of United States of America image

Try this .....

inOnMouseMove of the Image....

if ssleft in shift then
begin
     releasecapture;
     Image1.perform(WM_SYSCOMMAND, $F012, 0);
end;

Hope this helps....You can also assign OnDragDrop, and OnDropOver...

Regards,
Viktor Ivanov
Avatar of 1bdev
1bdev

ASKER

Hi Viktor,
thank you for your answer but it is not the answser that I am waiting.
Due to my very bad english, my question is not so clear.
It's not the Image I want to move but the scrollbars of the scrollBox.
For example :
I have an image 640x480 pixels inside a scrollbox 100x100 pixels.
My users needs to see the invisibles portions of this image by dragging
the image with the mouse. Like in PaintShop Pro

Best regards
Bernard Deveza
bdeveza@hol.fr

Here is a code I used but it is not good :

public
    mousedown:boolean;
    currentx:longint;
    currenty:longint;
    { Public declarations }
  end;

procedure Tframeview.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if button=mbleft then
   begin
     mousedown:=true;
     currentx:=x;
     currenty:=y;
   end;
end;

procedure Tframeview.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if (image1.Width>frameview.width) or (image1.height>frameview.height) then
    if mousedown then
      begin
        if horzscrollbar.position<horzscrollbar.range then
          horzscrollbar.position:=horzscrollbar.position+(currentx-x);
        if vertscrollbar.position<vertscrollbar.range then
          vertscrollbar.position:=vertscrollbar.position+(currenty-y);
        currentx:=x;
        currenty:=y;
      end;
end;

procedure Tframeview.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  mousedown:=false;
  currentx:=x;
  currenty:=y;
end;
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SB is the scroll box, and the OnMouseDown, OnMouseUp, and OnMouseMove are part of Image's events not the form's or the scrollbox's events....

Regards,
Viktor Ivanov
Avatar of 1bdev

ASKER

Thank you Viktor, I'm trying your solution... and it seems a good solution. I come back to you quickly.
Is it working for you that way??? =)

Regards,
Viktor Ivanov
Avatar of 1bdev

ASKER

Yes it globally work for me but with some imperfections I am working on. I have made a little program based on your example. Is it possible to email it to you because It is difficult for me to explain correctly the problems encountered.
Best regards
Bernard
bdeveza@hol.fr
Sorry for so late reply but I was out of town....so here I am again =)
Of course send it to me...My e-mail is viktor@megsinet.net

Will you post what you have found, I have the same problem that you have, will you post how you achieved your end result?