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

第三方Delphi组件提示框无法消失问题及手动隐藏方法咨询

Fixing Stuck Tooltips from Third-Party Delphi Components

Hey Matej, I’ve run into similar tooltip stubbornness with Delphi components before—let’s get this sorted out. The good news is there are a few reliable ways to manually hide those stuck tooltips, especially for your specific scenario (when opening a new form from a button with a tooltip).

Here are your best options, ordered by simplicity and specificity:

1. Check for Built-in Component Methods First

Most reputable third-party components expose methods to hide their tooltips directly. Dig into the component’s documentation or inspect its class in the Object Inspector:

  • Look for methods like HideHint, HideTooltip, or properties like Tooltip.Visible that you can set to False.
  • For example, if your button component is called TMySpecialBtn, you might just need to call:
    MySpecialBtn.HideHint;
    

This is the cleanest solution if it’s available—always start here.

2. Target the Tooltip via Delphi’s Native THintWindow

If the component uses Delphi’s built-in THintWindow for hints (common for VCL-based components), you can find and hide the hint window tied directly to your component:

uses Vcl.Controls;

procedure HideComponentSpecificHint(AComponent: TWinControl);
var
  TargetHintWindow: THintWindow;
begin
  // Find the hint window associated with your component's handle
  TargetHintWindow := THintWindow.FindHintWindow(AComponent.Handle);
  if Assigned(TargetHintWindow) then
    TargetHintWindow.Hide;
end;

Use this right before opening your new form:

procedure TMainForm.MyTooltipBtnClick(Sender: TObject);
begin
  // Hide the button's stuck tooltip first
  HideComponentSpecificHint(MyTooltipBtn);
  // Now open your form
  TNewForm.Create(Self).ShowModal;
end;

3. Use Windows API to Force Tooltip Closure

If the third-party component uses a raw Windows Tooltip control (class name tooltips_class32), you can locate it by its parent window (your component’s handle) and send a close message:

uses Winapi.Messages, Winapi.Windows, Vcl.Controls;

procedure ForceHideComponentTooltip(AComponent: TWinControl);
var
  TooltipHandle: HWND;
begin
  // Enumerate all tooltip windows
  TooltipHandle := FindWindowEx(0, 0, 'tooltips_class32', nil);
  while TooltipHandle <> 0 do
  begin
    // Check if this tooltip belongs to your component
    if GetParent(TooltipHandle) = AComponent.Handle then
    begin
      // Send the message to pop/hide the tooltip
      SendMessage(TooltipHandle, TTM_POP, 0, 0);
      Break; // Exit once we find the right one
    end;
    TooltipHandle := FindWindowEx(0, TooltipHandle, 'tooltips_class32', nil);
  end;
end;

This is a bit more low-level but works for components that don’t expose tooltip controls directly.

4. Quick Global Workaround (If All Else Fails)

If you don’t mind temporarily disabling all hints (not just the stuck one), you can toggle the global Application.ShowHint property:

procedure TMainForm.MyTooltipBtnClick(Sender: TObject);
begin
  // Turn off all hints temporarily
  Application.ShowHint := False;
  try
    TNewForm.Create(Self).ShowModal;
  finally
    // Restore hints after the form closes
    Application.ShowHint := True;
  end;
end;

This is a brute-force approach, but it’s simple and effective for your specific trigger scenario.

Pro Tip

If you can reproduce the issue consistently, consider adding a breakpoint in your form’s OnActivate or OnShow event to check if the tooltip is still active—this can help you narrow down whether the component is not cleaning up its tooltip properly, which might be a bug you can report to the component vendor.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 07:47:40