- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我右键单击 TPaintBox 时,我需要能够弹出一个 TForm(表单的内容将取决于我单击的位置)。如果用户单击其他任何地方,我希望原始表单被销毁(或至少消失)。如果新的单击恰好是在 TPaintBox 上再次右键单击,则必须出现一个新的 TForm。基本上,这是一个右键单击属性查询类型的操作,即右键单击以获取 TPaintBox 区域的属性。
这似乎比我想象的要困难。当使用 OnDeactivate 事件停用弹出窗口时,我首先尝试销毁弹出窗口。这导致弹出窗口未显示。
最佳答案
这是我的解决方案(经过测试且有效)...
type
TForm1 = class(TForm)
...
private
ContextForm: TfrmContext;
end;
...
implementation
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ContextForm <> nil then
FreeAndNil(ContextForm);
if Button = mbRight then
begin
ContextForm := TfrmContext.Create(Application);
ContextForm.SetParentComponent(Application);
ContextForm.Left := Mouse.CursorPos.X;
ContextForm.Top := Mouse.CursorPos.Y;
ContextForm.Show;
end;
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ContextForm <> nil then
FreeAndNil(ContextForm);
end;
在此演示中,右键单击 Button1 将创建“上下文表单”(这是一个 TForm)并设置其位置,以便“上下文表单”的左上角将恰好位于鼠标光标所在的位置。
单击表单上的任何其他位置都会破坏上下文表单。
享受吧!
关于delphi - 如何右键弹出窗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3280454/
我有点困惑。在 : http://delphi.about.com/od/objectpascalide/l/blvkc.htm 它说“Space”的正确键是#20。试过了,但行不通。但是,将其替换为
我有一个 input 的 type="submit" 并且我希望当我点击(右键或左键点击)它时这个元素周围没有蓝色边框。 我在下面的chrome浏览器中添加了OK模式和not OK模式的图片: OK模
我想在右键单击选项卡标题时显示上下文菜单条。 但是,我没有找到检测选项卡标题点击的方法。 有人知道如何做到这一点吗? 最佳答案 Private Sub tab1_MouseClick(sender A
我对编程还很陌生,正在尝试制作扫雷 GUI。游戏完美地右键单击 JToggleButton,在按钮上显示了一个代表炸弹的“B”,但是当我在鼠标监听器中用 setIcon() 替换 setText()
我正在尝试将一个按钮 float 到卡片的右侧。我希望它出现在右下角。 当我正确使用 float 时。它出现在父 div 之外,有没有办法正确定位它?
我正在使用 Struts2 标签和下面的代码使用 JS 计算并检查/验证在文本字段中输入的值。 它还会更新在 textfield 中输入的总数列表,这些由 onblur 处理和 onkeydown事件
我是一名优秀的程序员,十分优秀!