您的位置:首页 > 编程语言 > Delphi

Windows的自带控件(比如TButton)大多数消息都由它自己处理,Delphi覆盖了那么多WM_函数优先级较低,一般用不上

2016-04-07 04:52 429 查看
在空窗体上放一个TButton,一个TPanel,然后把在TWinControl.WMEraseBkgnd里下断点:

procedure TWinControl.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
with ThemeServices do // 这里下断点
if ThemesEnabled and Assigned(Parent) and (csParentBackground in FControlStyle) then
begin
{ Get the parent to draw its background into the control's background. }
DrawParentBackground(Handle, Message.DC, nil, False);
end
else
begin
{ Only erase background if we're not doublebuffering or painting to memory. }
if not FDoubleBuffered or
(TMessage(Message).wParam = TMessage(Message).lParam) then
FillRect(Message.DC, ClientRect, FBrush.Handle);
end;

Message.Result := 1;
end;


点击运行,发现程序两次停留在断点上,在观察窗口输入Self.Name,发现就是Form1和Panel1,而没有Button1停在这里。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: