gpt4 book ai didi

delphi - 鼠标输入/离开消息不起作用?

转载 作者:行者123 更新时间:2023-12-03 15:09:21 26 4
gpt4 key购买 nike

我正在尝试检测鼠标进入/离开消息 CM_MOUSEENTERCM_MOUSELEAVE 但它没有捕获它。我在这里做错了什么?

type
TMyControl = class(TCustomControl)
private
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
end;

procedure TMyControl.CMMouseEnter(var Message: TMessage);
begin
//Handle mouse entering
//Breakpoint never reached, procedure never called
end;

procedure TMyControl.CMMouseLeave(var Message: TMessage);
begin
//Handle mouse leaving
//Breakpoint never reached, procedure never called
end;

procedure TMyControl.WMNCHitTest(var Message: TWMNCHitTest);
var
Ch: Bool;
begin
if csDesigning in ComponentState then
Message.Result := HTCLIENT
else begin
Ch:= False;

//Do checks and pass `Ch:= True;` if something changed...

if Ch then Invalidate;
end;
end;

最佳答案

我发现了我的问题:我也在使用WM_NCHITTEST,但我没有传递inherited;。我添加了这个,现在可以正常工作了。

关于delphi - 鼠标输入/离开消息不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10794876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com