我想做一个可以手动调整控件大小的程序,如让其变长或变宽,主要是针对Shape操作。
请高手帮忙

解决方案 »

  1.   

    设置Weidth、height属性就可以了
      

  2.   

    procedure TForm1.shape1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
           if (x>=0)and(x<=3) then
      begin
        if (y>=0)and(y<=3) then shape1.Cursor:=crSizeNWSE;
        if (y>3)and(y<shape1.Height-3) then shape1.Cursor:=crSizeWE;
        if (y>=shape1.Height-3)and(y<=shape1.Height) then shape1.Cursor:=crSizeNESW;
      end
      else if (x>3)and(x<shape1.Width-3) then
      begin
        if (y>=0)and(y<=3) then shape1.Cursor:=crSizeNS;
        if (y>3)and(y<shape1.Height-3) then shape1.Cursor:=crArrow;
        if (y>=shape1.Height-3)and(y<=shape1.Width) then shape1.Cursor:=crSizeNS;
      end
      else if (x>=shape1.Width-3)and(x<=shape1.Width) then
      begin
        if (y>=0)and(y<=3) then shape1.Cursor:=crSizeNESW;
        if (y>3)and(y<shape1.Height-3) then shape1.Cursor:=crSizeWE;
        if (y>=shape1.Height-3)and(y<=shape1.Width) then shape1.Cursor:=crSizeNWSE;
      end;
    end;procedure TForm1.shape1MouseDown(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 shape1.Perform(WM_SysCommand,$F004,0);
        if (y>3)and(y<shape1.Height-3) then shape1.Perform(WM_SysCommand,$F001,0);
        if (y>=shape1.Height-3)and(y<=shape1.Height) then shape1.Perform(WM_SysCommand,$F007,0);
      end
      else if (x>3)and(x<shape1.Width-3) then
      begin
        if (y>=0)and(y<=3) then shape1.Perform(WM_SysCommand,$F003,0);
        if (y>3)and(y<shape1.Height-3) then shape1.Perform(WM_SysCommand,$F012,0);
        if (y>=shape1.Height-3)and(y<=shape1.Width) then shape1.Perform(WM_SysCommand,$F006,0);
      end
      else if (x>=shape1.Width-3)and(x<=shape1.Width) then
      begin
        if (y>=0)and(y<=3) then shape1.Perform(WM_SysCommand,$F005,0);
        if (y>3)and(y<shape1.Height-3) then shape1.Perform(WM_SysCommand,$F002,0);
        if (y>=shape1.Height-3)and(y<=shape1.Width) then shape1.Perform(WM_SysCommand,$F008,0);
      end;
    end;
      

  3.   

    这样为什么不行??
    把shape1 换成  Panel1 就能达到效果!
    为什么??
    请多指点! 
    肯定是 shape1MouseDown 事件对shape1  不起作用,对  Panel1 起作用.