窗体移动时,窗体上的控件会收到什么消息呢?

markov 2002-12-05 02:55:45
苦!我已试过无数消息了。都没有反应!试过之后再来发言哦,不要想当然的说什么paint事件、……事件。
...全文
88 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
cuihl 2002-12-06
  • 打赏
  • 举报
回复
window机制没有问题,因为窗口移动时,需要处理的无非就是重新绘制窗口,而所有控件都在窗口内,所以只要窗口绘制成功,控件就没有必要重新画了。假设
所有控件都要重新绘制,每个控件(窗口)都会有一个WM_PAINT消息,这些消息都会放到线程的消息队列里面,但是Windows会把消息队列里面的所有WM_PAINT消息组合成一个WM_PAINT消息,并组合每个WM_PAINT中的绘制区域,以提高效率。
markov 2002-12-05
  • 打赏
  • 举报
回复
cuihl,我的想法和你的相似,我考虑给parent的onXX事件赋值,但是我担心会出现access invalidate错误,没有尝试。如果真的收不到消息,只能这样了。我很失望。window机制就是这样吗?我不愿相信。
markov 2002-12-05
  • 打赏
  • 举报
回复
cuihl,thanks very much. 我会仔细研究你的方案的,看得出来,你不是庸手!nice。
ehom 2002-12-05
  • 打赏
  • 举报
回复
WM_MOVING
ehom 2002-12-05
  • 打赏
  • 举报
回复
WM_SYSCOMMAND
cuihl 2002-12-05
  • 打赏
  • 举报
回复
调用时
procedure TForm1.FormCreate(Sender: TObject);
begin
MyCon := TMyControl.Create(self);
MyCon.Parent := self;
MyCon.SetMyWndProc;
end;
cuihl 2002-12-05
  • 打赏
  • 举报
回复
控件不会收到任何事件,你的问题可以这样解决:
TMyControl = class(TCustomControl)
private
OldProc: TWndMethod;
procedure MyWndProc(var Message: TMessage);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy;override;
procedure SetMyWndProc;
procedure ReleaseMyWndProc;
end;

implementation

{ TMyControl }

constructor TMyControl.Create(AOwner: TComponent);
begin
inherited;
end;

destructor TMyControl.Destroy;
begin
inherited;
if Assigned(OldProc) then ReleaseMyWndProc;
end;

procedure TMyControl.MyWndProc(var Message: TMessage);
begin
if Message.Msg = WM_MOVING then
ShowMessage('');
if Assigned(OldProc) then OldProc(Message);
end;

procedure TMyControl.ReleaseMyWndProc;
begin
if Assigned(OldProc) then
parent.WindowProc := OldProc;
end;

procedure TMyControl.SetMyWndProc;
begin
OldProc := Parent.WindowProc;
Parent.WindowProc := MyWndProc;
end;
markov 2002-12-05
  • 打赏
  • 举报
回复
拜托,不要说“至少”。自己试一下就知道理想于现实有多少差距。WM_PAINT
没有被触发。really。不信自己看了。
sun_cathay 2002-12-05
  • 打赏
  • 举报
回复
WM_MOUSEMOVE
jianzhang 2002-12-05
  • 打赏
  • 举报
回复
控件不会收到任何事件
jianzhang 2002-12-05
  • 打赏
  • 举报
回复
会得到 WM_MOVING 事件
如:unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;

type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
private
{ Private declarations }
procedure FormMove(var msg:TMessage);message WM_MOVING;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.FormMove(var msg: TMessage);
var
Rect:^Trect;
begin

Rect:=Pointer(msg.LParam);
StatusBar1.Panels.Items[0].Text:='Left='+inttostr(Rect.Left);
StatusBar1.Panels.Items[1].Text:='Top='+inttostr(Rect.Top);
StatusBar1.Panels.Items[2].Text:='Right='+inttostr(Rect.Right);
StatusBar1.Panels.Items[3].Text:='Bottom='+inttostr(Rect.Bottom);

end;

end.
耙子 2002-12-05
  • 打赏
  • 举报
回复
至少会得到 WM_PAINT
markov 2002-12-05
  • 打赏
  • 举报
回复
我正在写vcl组件,该组件需要在窗体位置改变时处理代码。
jianzhang 2002-12-05
  • 打赏
  • 举报
回复
WM_MOUSEMOVE

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧