改变位置:  
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);  
begin
  ReleaseCapture;
  Panel1.perform(WM_SysCommand,$F012,0);
end;
给分.改变大小呢,你可以MouseMove中的X,Y参数,想应的Panel1.Width+-*/X-原先的x; Panel1.Height+-*/Y.

解决方案 »

  1.   

      Panel1.perform(WM_SysCommand,$F004,0);你再试一试,嘻嘻
      

  2.   

    Panel1.perform(WM_SysCommand,$F001,0); 
    Panel1.perform(WM_SysCommand,$F002,0); 
    Panel1.perform(WM_SysCommand,$F003,0); 
    Panel1.perform(WM_SysCommand,$F004,0); 
    Panel1.perform(WM_SysCommand,$F005,0); 
    Panel1.perform(WM_SysCommand,$F006,0); 
    Panel1.perform(WM_SysCommand,$F007,0); 
    Panel1.perform(WM_SysCommand,$F008,0); 
    分别对应改变大小的8个方向,你可以编程判断x,y的位置(取Panel的8个控制点,上下左右....),然后根据不同的控制点改变不同的光标,在执行不同的perform。
    嘻嘻成功了,一个完整的移动并改变大小的代码。
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      ReleaseCapture;
      if (x>=0)and(x<=3) then
      begin
        if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F004,0);
        if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F001,0);
        if (y>=Panel1.Height-3)and(y<=Panel1.Height) then Panel1.perform(WM_SysCommand,$F007,0);
      end
      else if (x>3)and(x<Panel1.Width-3) then
      begin
        if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F003,0);
        if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F012,0);
        if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.perform(WM_SysCommand,$F006,0);
      end
      else if (x>=Panel1.Width-3)and(x<=Panel1.Width) then
      begin
        if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F005,0);
        if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F002,0);
        if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.perform(WM_SysCommand,$F008,0);
      end;
    end;procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if (x>=0)and(x<=3) then
      begin
        if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNWSE;
        if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crSizeWE;
        if (y>=Panel1.Height-3)and(y<=Panel1.Height) then Panel1.Cursor:=crSizeNESW;
      end
      else if (x>3)and(x<Panel1.Width-3) then
      begin
        if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNS;
        if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crArrow;
        if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.Cursor:=crSizeNS;
      end
      else if (x>=Panel1.Width-3)and(x<=Panel1.Width) then
      begin
        if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNESW;
        if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crSizeWE;
        if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.Cursor:=crSizeNWSE;
      end;
    end;end.
    在窗口里只加了一个Panel1,你运行运行吧
      

  4.   

    做好了,正是你要的.我用了一个Image1,你改为Panel1就行了,已测试过了.
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;type
      TForm1 = class(TForm)
        Image1: TImage;
        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;
      x0,y0:integer;
      down,resized:Boolean;implementation{$R *.DFM}procedure Tform1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      x0:=x;
      y0:=y;
      if (x>Image1.Width-10)or(y>image1.Height-10) then begin
        Image1.Cursor:=crSize;
        resized:=true;
      end else begin
        Image1.Cursor:=crDefault;
        down:=TRUE;
      end;
    end;procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if x>Image1.Width-10 then begin
        Image1.Cursor:=crSize;
      end else begin
        Image1.Cursor:=crDefault;
      end;
      if down then begin
        Image1.Left:=Image1.Left+x-x0;
        Image1.top:=Image1.top+y-y0;
      end;
      if resized then begin
        Image1.Width:=Image1.Width+x-x0;
        Image1.Height:=Image1.Height+y-y0;
        x0:=x;y0:=y;
      end;
    end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      down:=False;
      resized:=False;
    end;
    end.