Thema: Delphi On mouse down bei canvas

Einzelnen Beitrag anzeigen

maximi

Registriert seit: 9. Jun 2003
217 Beiträge
 
Delphi 7 Personal
 
#1

On mouse down bei canvas

  Alt 16. Jan 2004, 19:11
Hallo!


Delphi-Quellcode:

type
  TBorderSkin = class(TImage)
  private
    { Private-Deklarationen }
  protected
    x,y:Integer;
    { Protected-Deklarationen }
  public
    Image:Array[0..9] of TImage;
    active_click :Boolean;
    forms:TForm;

  published
    procedure load_imagelist(ImageList:TImageList);
    procedure imagemousedown(Sender: TObject; Button: TMouseButton;
                             Shift: TShiftState; X, Y: Integer);

    procedure imagemouseup(Sender: TObject; Button: TMouseButton;
                             Shift: TShiftState; X, Y: Integer);
    procedure imagemousemove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);

    procedure imagemouseleft(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
    constructor set_koordinaten(Form:TForm;ImageList:TImageList);

    { Published-Deklarationen }
  end;


procedure Register;

implementation

procedure TBorderSkin.imagemouseleft;
begin
  if(active_click = true) then
  begin


  end;
end;


procedure TBorderSkin.imagemousemove;
begin
  if(active_click = true) then
  begin
    ReleaseCapture;
    forms.Perform(wm_syscommand,$f013, 0);
  end;
end;

procedure TborderSkin.imagemouseup;
begin
  active_click := false;
end;

procedure TBorderSkin.imagemousedown;
begin

  active_click := true;
end;

constructor TBorderSkin.set_koordinaten;
var I:Integer;

begin
  forms := form;
  for i := 0 to 9 do
  begin
    Image[i] := TImage.Create(self);
    Image[i].Parent := Form;

    //ganz links oben
    if(i = 0) then
    begin
      Image[i].Top := 0;
      Image[i].Width := 5;
      Image[i].Height := 30;
      Image[i].Left := 0;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemousemove;

    end;

    //mitte oben
    if(i = 1) then
    begin
      Image[i].Top := 0;
      Image[i].Width := trunc((Form.Width-55) / 1.1648522);;
      Image[i].Height := 32;
      Image[i].Left := 4;
      Image[i].Stretch := true;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemousemove;
    end;

    //mitte rechts
    if(i = 2) then
    begin
      Image[i].Top := 0;
      Image[i].Width := 45;
      Image[i].Height := 32;
      Image[i].Left := Image[1].Width + 3;
      Image[i].Stretch := true;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemousemove;
    end;

    if(i = 3) then
    begin
      Image[i].Top := 0;
      Image[i].Width := trunc((Form.Width-21)/7.1333333333);
      Image[i].Height := 32;
      Image[i].Left := Image[1].Width + Image[2].Width + 2;
      Image[i].Stretch := true;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemousemove;
    end;

    if(i = 4) then
    begin
      Image[i].Top := 0;
      Image[i].Width := 5;
      Image[i].Height := 30;
      Image[i].Left := Form.Width-5;
    end;

    if(i = 5) then
    begin
      Image[i].Top := 30;
      Image[i].Width := 5;
      Image[i].Height := Form.Height;
      Image[i].Left := Form.Width-5;
      Image[i].Stretch := true;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemouseleft;
    end;

    if(i = 6) then
    begin
      Image[i].Top := 30;
      Image[i].Width := 5;
      Image[i].Height := Form.Height;
      Image[i].Left := 0;
      Image[i].Stretch := true;
    end;

    if(i = 7) then
    begin
      Image[i].Top := form.Height-5;
      Image[i].Width := Form.width-8;
      Image[i].Height := 5;
      Image[i].Left := 4;
      Image[i].Stretch := true;
    end;

    if(i = 8) then
    begin
      Image[i].Top := 5;
      Image[i].Width := length(form.Caption)*10;
      Image[i].Height := 20;
      Image[i].Left := 30;
      Image[i].Canvas.Font.Size := 12;
      Image[i].Canvas.TextOut(0,0,form.Caption);
      Image[i].Transparent := true;
      Image[i].BringToFront;
      Image[i].OnMouseDown := imagemousedown;
      Image[i].OnMouseUp := imagemouseup;
      Image[i].OnMouseMove := imagemousemove;
    end;

    if(i = 9) then
    begin

    end;
  Form.BorderStyle := bsnone;
  end;
end;


procedure TBorderSkin.load_imagelist;
var i:Integer;
begin
  for i := 0 to 9 do
  begin

      ImageList.GetBitmap(i,Image[i].Picture.Bitmap);


  end;

end;
Wenn ich auf ein Image mit Canvas etwas zeichne funktioniert mein mousedown nicht mehr.(siehe procedure set_koordinaten bei dem if(i = 8')).Wie geht das

Hiermit
ReleaseCapture;
Perform(wm_syscommand,$f013, 0);
kann ich ja mein Form verschieben, aber wie kann ich, wenn ich an die Außenränder meines Forms gehe die Größe verändern?

Danke
  Mit Zitat antworten Zitat