- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有几个第三方控件(例如 Raize Components )具有关闭的“十字”按钮“选项”(例如页面控件)。我的要求更简单,我想将右上角对齐的十字“按钮”放在 TPanel 上并访问其单击事件。是否有一种简单的方法可以在不创建 TPanel 后代的情况下执行此操作,或者是否有我可以使用的付费或免费库组件?
最佳答案
我为你写了一个控件。
unit CloseButton;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, UxTheme;
type
TCloseButton = class(TCustomControl)
private
FMouseInside: boolean;
function MouseButtonDown: boolean;
protected
procedure Paint; override;
procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override;
procedure WndProc(var Message: TMessage); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X: Integer;
Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer;
Y: Integer); override;
public
constructor Create(AOwner: TComponent); override;
published
property Align;
property Anchors;
property Enabled;
property OnClick;
property OnMouseUp;
property OnMouseDown;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Rejbrand 2009', [TCloseButton]);
end;
{ TCloseButton }
constructor TCloseButton.Create(AOwner: TComponent);
begin
inherited;
Width := 32;
Height := 32;
end;
function TCloseButton.MouseButtonDown: boolean;
begin
MouseButtonDown := GetKeyState(VK_LBUTTON) and $8000 <> 0;
end;
procedure TCloseButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
inherited;
Invalidate;
end;
procedure TCloseButton.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited;
if not FMouseInside then
begin
FMouseInside := true;
Invalidate;
end;
end;
procedure TCloseButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
inherited;
Invalidate;
end;
procedure TCloseButton.Paint;
function GetAeroState: cardinal;
begin
result := CBS_NORMAL;
if not Enabled then
result := CBS_DISABLED
else
if FMouseInside then
if MouseButtonDown then
result := CBS_PUSHED
else
result := CBS_HOT;
end;
function GetClassicState: cardinal;
begin
result := 0;
if not Enabled then
result := DFCS_INACTIVE
else
if FMouseInside then
if MouseButtonDown then
result := DFCS_PUSHED
else
result := DFCS_HOT;
end;
var
h: HTHEME;
begin
inherited;
if UseThemes then
begin
h := OpenThemeData(Handle, 'WINDOW');
if h <> 0 then
try
DrawThemeBackground(h,
Canvas.Handle,
WP_CLOSEBUTTON,
GetAeroState,
ClientRect,
nil);
finally
CloseThemeData(h);
end;
end
else
DrawFrameControl(Canvas.Handle,
ClientRect,
DFC_CAPTION,
DFCS_CAPTIONCLOSE or GetClassicState)
end;
procedure TCloseButton.WndProc(var Message: TMessage);
begin
inherited;
case Message.Msg of
WM_MOUSELEAVE:
begin
FMouseInside := false;
Invalidate;
end;
CM_ENABLEDCHANGED:
Invalidate;
end;
end;
end.
示例(启用和不启用主题):
只需将其放在右上角的 TPanel
中,并将 Anchors
设置为顶部和右侧即可。
关于delphi - 如何最好地创建一个右上角带有关闭 'cross' 按钮的 TPanel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6550249/
我正在尝试自己编译跨平台工具链。 当我编译 binutils-2.22 时,它成功了,但为什么会出现“检查我们是否正在交叉编译...否”?我想应该是"is",对吧? 我的主机是运行 ubuntu 的
设置: 有远程测量站,有集中收集/处理/呈现服务器(带有网络服务器),还有观测站,为客户显示收集到的数据。 这些观测站由简单的嵌入式计算机组成,配备网络浏览器,以信息亭模式工作,每个观测站显示来自中央
我对 Spark 和 Scala 很陌生,我正在编写 Spark SQL 代码。我可以在我的逻辑中应用 CROSS JOIN 和 CROSS APPLY。在这里,我将发布必须转换为 Spark SQL
警告是: jquery-1.9.1.js:8526 跨源读取阻止 (CORB) 阻止跨源响应 https://www.metaweather.com/api/location/search/?quer
我正在尝试对用户进行身份验证,但由于Cross-Origin Read Blocking (CORB) blocked 问题我的 login.ts 代码是 if (this.plugins.isOnl
这是我的表格 public class TaskForm extends WebForm { public TaskForm(){ this(new TaskModel());
首先,对不起我的英语语言不好,我是初学者程序员。在我的项目中,我使用线程类,但完成后我看到了这个异常: Cross-thread operation not valid: Control 'lblp4
我目前正在为一个项目开发前端(VueJS),为了测试我的登录和注册逻辑,我使用 laravel 作为后端,尽管我们实际上将使用 springboot 作为后端。我在桌面上编码,一切正常。所以我开始使用
我一直认为,就主要浏览器在不同平台上的渲染而言,唯一的区别是操作系统的底层字体渲染技术,其他一切都依赖于浏览器中包含的相同库。 就我的研究而言,前端开发人员要么相信,要么不相信。似乎我们可以选择任何一
我需要在我正在处理的网站中显示一些交互式(附加 DOM 监听器等和事件处理)矢量图形。 W3C 推荐了 SVG,尽管 Internet Explorer 支持仍然无法识别这种格式,这是必须的(对于公共
子域是否有跨域策略限制? 如果我在 paint.xxxx.com 上有申请这是处理来自 image.xxxx.com 的图像,有没有跨域问题? 我问这些问题,因为我正在考虑在子域上放置一个代理。 最佳
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 6年前关闭。 Improve this questi
一个项目迫在眉睫,我将要编写的一些代码可能会部署在潜在客户碰巧拥有的任何硬件上。它是一个 24/7 全天候运行的业务应用程序,因此我设想大多数主机将是服务器类型的机器,但较小的客户端可能只有一台简单的
首先,我不反对Opera。似乎当我遇到跨浏览器问题并进行一些研究时,总能找到“解决办法”,但是随后我看到一条评论,说我正在查看的跨浏览器解决方案无法在Opera中使用,这是一种愚蠢的评论。 我应该在乎
作为优秀的开发人员,我们尽可能保持我们的代码符合标准,以帮助平台之间的移植。但是有哪些工具可以帮助我们以统一的方式跨多个平台构建代码。 *nix 家族有 make但 Windows 需要 nmake
我目前正在构建浏览器帮助对象。 的事情之一BHO要做的是绕过跨域策略进行跨站请求。 为此,我公开了 __MyBHONameSpace.Request使用 WebClient 的方法内部。 然而,我想到
我开发了一个 NP API 插件并正在使用它。我观察到以下两件事 当我第一次安装插件时,我需要重新启动我的 mac os 以加载插件。 每当我更新插件时,我都需要重新启动浏览器。 我想在不重新启动浏览
浏览器在接收到“足够”的数据后或数据停止流入后呈现内容(例如,达到内容长度)。 我要慢慢地将数据流式传输到浏览器;为此,我必须解决此数据缓存问题。 例如,不是发送 40 字节的 JavaScript,
我搜索了一些关于跨平台编程开发的文献,但没有找到真正好的东西。 我不是在寻找像 Java 那样的跨平台虚拟机。 有没有关于这方面的书籍或文献? 最佳答案 我会说这归结为: 不使用非标准的“标准库”功能
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 7年前关闭。 Improve t
我是一名优秀的程序员,十分优秀!