You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TTntUpDown点击异常:点击外部仍响应的问题排查求助

TTntUpDown点击后持续响应外部区域点击的异常问题

组件层级结构:

  • 继承自TTntFrame的框架包含TTntUpDown实例,该实例关联到TTntDateTimePicker
  • 上述框架放置在TTntPageControl的标签页上
  • TTntPageControl位于继承自TTntForm的窗体中

异常现象

点击TTntUpDown后,再点击其外部区域(如DB Grid或页控件的其他标签页),TTntUpDown仍会持续处理这些新的点击事件。要让它停止响应点击非常棘手:有时需要多次点击不同元素,有时需要在其他位置双击。

最初完全不清楚问题原因,也不知道如何开始调试。


更新

我在主窗体添加了一个100ms的定时器,代码如下:

procedure TMainForm.DebugTimerTimer(Sender: TObject);
var
  fcn: string;
  frm: TCustomForm;
  ac: TWinControl;
begin
  fcn := 'None';
  ac := Screen.ActiveControl;
  if ac <> nil then
    fcn := ac.Name;
  frm := GetParentForm(Self);
  if (frm <> nil) and (frm.Caption <> fcn) then
    frm.Caption := fcn;
end;

这段代码显示:当异常发生时,ActiveControl是主窗体本身或页控件。TTntUpDown会检测鼠标光标是否在其中线上下以激活向上/向下按钮,但此时它无法检测到光标完全在其外部。

当TTntUpDown.OnClick触发时,调用栈如下:

TMyFrame.udExpDayClick(???,btNext)
TCustomUpDown.Click(btNext)
TCustomUpDown.WMVScroll((48405, 4, 2, 3081912, 0))
TControl.WndProc((48405, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TWinControl.WndProc((48405, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TWinControlTrap.WindowProc((48405, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TControl.Perform(48405,131076,3081912)
DoControlMsg(3081912,(no value))
TWinControl.WMVScroll((277, 4, 2, 3081912, 0))
TControl.WndProc((277, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TWinControl.WndProc((277, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TToolBar.WndProc((277, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
TWinControl.MainWndProc((277, 131076, 3081912, 0, 4, 2, 1720, 47, 0, 0))
StdWndProc(3999914,277,131076,3081912)
TWinControlTrap.DefWin32Proc(???)
StdWndProc(3081912,513,1,-1244951)
TWinControl.DefaultHandler((no value))
TControl.WMLButtonDown((513, 1, 233, -19, (233, -19), 0))
TControl.WndProc((513, 1, -1244951, 0, 1, 0, 233, 65517, 0, 0))
TWinControl.WndProc((513, 1, -1244951, 0, 1, 0, 233, 65517, 0, 0))
TWinControlTrap.WindowProc((513, 1, -1244951, 0, 1, 0, 233, 65517, 0, 0))
TWinControl.MainWndProc((513, 1, -1244951, 0, 1, 0, 233, 65517, 0, 0))
StdWndProc(3081912,513,1,-1244951)
TWinControlTrap.Win32Proc(???)
StdWndProc(3081912,513,1,-1244951)
TApplication.ProcessMessage((3081912, 513, 1, -1244951, 29697894, (868, 56)))
TApplication.HandleMessage
TApplication.Run

我认为TControl.WMLButtonDown触发TWinControl.WMVScroll是不合理的。此次我点击了TTntPageControl的标签,但调用栈中却出现了TToolBar.WndProc。

在调用链中,第一个TWinControl.MainWndProc调用已属于UpDown控件,说明该链中没有错误传递,可能是第一个TWinControlTrap.Win32Proc已指向错误控件。


内容的提问来源于stack exchange,提问作者Paul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 19:13:11