2

当我将鼠标移到其位置时,如何使面板显示其中的所有内容?

当我再次将其移开时,它会淡出?

在可见时执行它不是问题(淡出除外),我可以使用 onmouseleaves 执行此操作。

但是当它不可见时,你如何让它可见呢?

谢谢

4

2 回答 2

4

将面板放在另一个(空白)面板上。当您在空白面板上移动鼠标时,使“魔术”面板显示出来。


已编辑,因为我现在了解到 OP 在 WebBrowser 上有面板。我放置虚拟/空白面板的解决方案不再有效;干扰进入 WebBrowser 的鼠标消息也不是一个好主意,所以这里有一个简单的方法来解决这个问题。我正在使用间隔设置为“100”的 TTimer,并且正在合并鼠标坐标。

procedure TForm25.Timer1Timer(Sender: TObject);
var PR: TRect; // Panel Rect (in screen coordinates)
    CP: TPoint; // Cursor Position (always in screen coordinates)
begin
  // Get the panel's coordinates and convert them to Screen coordinates.
  PR.TopLeft := Panel1.ClientToScreen(Panel1.ClientRect.TopLeft);
  PR.BottomRight := Panel1.ClientToScreen(Panel1.ClientRect.BottomRight);
  // Get the mouse cursor position
  CP := Mouse.CursorPos;
  // Is the cursor over the panel?
  if (CP.X >= PR.Left) and (CP.X <= PR.Right) and (CP.Y >= PR.Top) and (CP.Y <= PR.Bottom) then
    begin
      // Panel should be made visible
      Panel1.Visible := True;
    end
  else
    begin
      // Panel should be hidden
      Panel1.Visible := False;
    end;
end;
于 2011-03-17T09:52:35.750 回答
1

如果您的面板将出现在某个区域中,您可以捕获底层表单或父面板的鼠标移动事件,并检查它是否在您的不可见面板将出现的范围内。

例如。(伪代码)

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if ((X > MyPanel.Left) and (Y > MyPanel.Top) and (X < mypanel.right) and 
  (Y < mypanel.bottom)) then
  begin
      mypanel.visible := true;
  end;
end;
于 2011-03-17T09:56:01.583 回答