在运行期间也能改变控件的尺寸和位置
就像在设计期间一样。
如何实现这样的功能,各位大侠有何高见?
什么地方有这样的文章?

解决方案 »

  1.   

    unit MyButton1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TMyButton1 = class(TButton)
      private
        { Private declarations }
        procedure WMHITTEST(var Msg:TWMNCHitTest);message WM_NCHITTEST;//WM_HITTEST;
      protected
        { Protected declarations }
      public
        { Public declarations }
      published
        { Published declarations }
      end;procedure Register;implementationprocedure TMyButton1.WMHITTEST(var Msg:TWMNCHitTest);
    var
      Rct : TRect;
      Pt : TPoint;
    begin GetWindowRect(Handle,Rct);     // Get self Rect; pt.x := Msg.pos.x;
     pt.y := Msg.pos.y; if (pt.y > Rct.Bottom - 3) and (pt.x > Rct.right - 3) then  // bottom right.
     begin
       Msg.Result :=HTBOTTOMRIGHT;
       exit;
     end; if (pt.y < Rct.Top + 3) and (pt.x > Rct.right - 3) then   // Top right.
     begin
       Msg.Result :=HTTOPRIGHT;
       exit;
     end; if (pt.y > Rct.Bottom - 3) and (pt.x < Rct.Left + 3) then  // Bottom left.
     begin
       Msg.Result :=HTBOTTOMLEFT;
       exit;
     end; if (pt.y < Rct.Top + 3) and (pt.x < Rct.Left + 3) then   // Top left.
     begin
       Msg.Result :=HTTOPLEFT;
       exit;
     end; if (pt.x < Rct.Left + 3) then  // Show left arrow.
     begin
       Msg.Result :=HTLEFT;
       exit;
     end;
     if (pt.x > Rct.right - 3) then  // Show right arrow.
     begin
       Msg.Result :=HTRIGHT;
       exit;
     end;
     if (pt.y < Rct.Top + 3) then  // Show top arrow.
     begin
       Msg.Result :=HTTOP;
       exit;
     end; if (pt.y > Rct.Bottom - 3) then  // Show bottom arrow.
     begin
       Msg.Result :=HTBOTTOM;
       exit;
     end; // Default is drag control.
     if PtInRect(Rct,pt) then Msg.Result :=HTCAPTION;end;
    procedure Register;
    begin
      RegisterComponents('MyComponent', [TMyButton1]);
    end;end.
      

  2.   

    TO :Wnyu(西门吹水) 
    这样的原理是什么?能否告知一二!还请介绍几篇相关的文章。在没有人了
    我还想知道的更多。大家能不能关注一下,贴子放了好几天了,只有一个答复!!!
      

  3.   

    http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=14689这个是你要的东东,写成了一个控件,很不错的,你可以看看
      

  4.   

    VCL揭密0.002版可以实现这样的功能。另外还有一些其他VCL的秘密
      

  5.   

    在代码上控制:例如:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Edit1.Width := 100;
      Edit1.Height := 50
    end;