请问怎样用SendMessage 修改某控件的(Left、Top、Width、Height) ( 积分: 20 )

  • 主题发起人 主题发起人 无厘头
  • 开始时间 开始时间
不用:SendMessage
你可以用:窗体的:boundRect或setBound来实现;
例:
form1.boundrect:rect(left,top,width,height)
form1.setbound(left,top,width,height)
 
用API函数 SetWindowPos(
hWnd:HWND; // handle of window
hWndInsertAfter:HWND; // placement-order handle
X:integer; // horizontal position
Y:integer; // vertical position
cx:integer; // width
cy:integer; // height
uFlags:UINT // window-positioning flags
):BOOL;
 
自己定义消息;
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
Const
WM_SETSIZE=WM_USER+100;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
Procedure ButWMSize(var Message:TMessage); Message WM_SETSIZE;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
Procedure TForm1.ButWMSize(var Message:TMessage);
begin
Form1.BitBtn2.Left:=100;
Form1.BitBtn2.Top:=100;
Form1.BitBtn2.Width:=50;
Form1.BitBtn2.Height:=50;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
SendMessage(Form1.Handle,WM_SETSIZE,0,0);
end;

end.
 
我就要SendMessage 这个
 
后退
顶部