Solved

Dragging a Timage in scrollBox

Posted on 1998-08-22
9
551 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:1bdev
  • 5
  • 3
9 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1337439
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
0
 

Author Comment

by:1bdev
ID: 1337440
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;
0
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1337441
Here is something that I just whiped together

var
  PT : TPoint;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if ssLeft in Shift then
  begin
    if pt.x > x then
      SB.ScrollBy(1, 0)
    else if pt.x < x then
      SB.ScrollBy(-1, 0);
    if pt.y > y then
      SB.ScrollBy(0, 1)
    else if pt.y < y then
      SB.ScrollBy(0, -1);
  end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  GetCursorPos(PT);
end;

procedure TForm1.IMMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  GetCursorPos(pt);
end;

Hope this works...

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337442
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:1bdev
ID: 1337443
Thank you Viktor, I'm trying your solution... and it seems a good solution. I come back to you quickly.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337444
Is it working for you that way??? =)

Regards,
Viktor Ivanov
0
 

Author Comment

by:1bdev
ID: 1337445
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
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337446
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

0
 

Expert Comment

by:perkley
ID: 2621233
Will you post what you have found, I have the same problem that you have, will you post how you achieved your end result?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 63
indy Tmemory stream non latin charcter issue 2 98
Tviruailstringtree sort multi columns on header click 1 54
Graphics32 under Delphi 10.1 Berlin 2 37
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now