Recent

Author Topic: moving bitmap into paintbox or image component.  (Read 4783 times)

twinpoint

  • Newbie
  • Posts: 2
moving bitmap into paintbox or image component.
« on: June 15, 2010, 04:46:30 am »
Hello all, i`m newbie into programming. I want to create a something like map-viewer, but i don`t know what doing this:

1. Moving picture in image/paintbox component - i can only move component on the form like this:
uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, Buttons, ExtDlgs;

type

  { TForm1 }

  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Image1: TImage;
    opd: TOpenPictureDialog;
    procedure BitBtn1Click(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
      );
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  LMButton: Boolean;
  tmp: Boolean;
  Mouse: TPoint;

implementation

{ TForm1 }

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 if opd.Execute then
 image1.Picture.LoadFromFile(opd.FileName);
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 LMButton:=True;
  tmp:=True;
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
         if (LMButton) then
  begin
    if (tmp) then
    begin
      Mouse.X:=X;
      Mouse.Y:=Y;
    end;
    tmp:=False;

    Image1.Left:=Image1.Left+X-Mouse.X;
    Image1.Top:=Image1.Top+Y-Mouse.Y;
  end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 LMButton:=False;
end;



2. how to add a next image (for example at left) - when my first image is moved more than left border of component.
i try something with visible/unvisible bitmap but it not working.

Help, please.
Thanks a lot.

 

TinyPortal © 2005-2018