Moving TImage

Moving TImage

Post by Francois Smi » Wed, 19 Jan 2000 04:00:00



Hi.

How do I drag an image in runtime from one place to another.

How do I get a Bevel around the image to resize it?

Thanx

 
 
 

Moving TImage

Post by Mauro Patin » Wed, 19 Jan 2000 04:00:00



> Hi.

> How do I drag an image in runtime from one place to another.

This code was posted by Peter Below(Team B) in the winapi group.

Drag around controls:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
  StdCtrls, ExtCtrls, ComCtrls, DBTables, DB;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure ControlMouseDown(Sender: TObject; Button:
TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ControlMouseMove(Sender: TObject; Shift: TShiftState;
X,
      Y: Integer);
    procedure ControlMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    downX, downY: Integer;
    dragging: Boolean;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

Type
  TCracker = Class(TControl);
  { Needed since TControl.MouseCapture is protected }

 procedure TForm1.Button1Click(Sender: TObject);
 begin
   Close
 end;

{ Control event handlers are attached to both memo and image mouse
  events. }
procedure TForm1.ControlMouseDown(Sender: TObject; Button:
TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  downX:= X;
  downY:= Y;
  dragging := TRue;
  TCracker(Sender).MouseCapture := TRue;
end;

procedure TForm1.ControlMouseMove(Sender: TObject; Shift:
TShiftState; X,
  Y: Integer);
begin
  If dragging Then
  with Sender As TControl Do Begin
    Left := X-downX+Left;
    Top  := Y-downY+Top;
  End;
end;

procedure TForm1.ControlMouseUp(Sender: TObject; Button:
TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  If dragging then Begin
    dragging := False;
    TCracker(Sender).MouseCapture := False;
  End;
end;

initialization
end.

Quote:

> How do I get a Bevel around the image to resize it?

You can place it inside a panel and set the Image.Align to client. Then
actually resize the panel.
Quote:

> Thanx


 
 
 

1. Moving Timage over another Timage causes flickering ??

Hello NG,

I have a TImage that contains a bitmap (~1024X768).
I have another Timage (150X150) no bitmap loaded, that has transparent set
to true.

I draw an ellipse on the 150X150 Timage and then move 5 times per second by
setting its Top and Left Property.

Problem.... Every time I reposition (move) the 150X150 image over the larger
image, I get a flicker.

I've tried with and without calling Image.Update..... no luck.

How do I get rid of the flicker?

Thanks
Bryan

2. Saving AVI in win95

3. Move TImage by drag on drop

4. Exposure compensation

5. How to avoid flickering while moving TImage

6. Using VB5's stdFont in an API call.

7. Moving TImage with Mouse

8. moving TImage

9. Help Moving a TImage over a TImage

10. Moving Rectangle upon the TImage...

11. Moving around a Timage

12. Help move a TImage diagonally.