forms - Delphi:重叠窗口/表单标题栏?
问题描述
是否可以将表单标题栏与其他控件(TPanel)重叠?
像这样的东西:
解决方案
正如Jerry 评论的那样,也许您可以使用放置面板的 StayOnTop 表单。假设您将该面板设计为主窗体上的(可能左对齐)控件,则此类解决方案的开头可能如下所示:
uses
Winapi.Windows, Winapi.Messages, System.Classes, Vcl.Controls, Vcl.Forms,
Vcl.ExtCtrls;
type
TMainForm = class(TForm)
Panel1: TPanel;
private
FStickIt: TForm;
protected
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged);
message WM_WINDOWPOSCHANGED;
public
constructor Create(AOwner: TComponent); override;
end;
implementation
{$R *.dfm}
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FStickIt := TForm.CreateNew(Self);
FStickIt.AutoSize := True;
FStickIt.BorderStyle := bsNone;
FStickIt.FormStyle := fsStayOnTop;
FStickIt.Show;
Panel1.Align := alCustom;
Panel1.Parent := FStickIt;
end;
procedure TMainForm.WMSysCommand(var Message: TWMSysCommand);
begin
inherited;
case Message.CmdType and $FFF0 of
SC_MINIMIZE: FStickIt.Hide;
SC_RESTORE: FStickIt.Show;
end;
end;
procedure TMainForm.WMWindowPosChanged(var Message: TWMWindowPosChanged);
var
EdgeSize: Integer;
TitleBarInfoEx: TTitleBarInfoEx;
begin
inherited;
if Assigned(FStickIt) then
begin
EdgeSize := (Width - ClientWidth) div 2;
FStickIt.Left := Left + EdgeSize - BorderWidth;
FStickIt.Top := Top + GetSystemMetrics(SM_CYBORDER);
Panel1.Height := Height - EdgeSize - GetSystemMetrics(SM_CYBORDER) +
BorderWidth;
TitleBarInfoEx.cbSize := SizeOf(TitleBarInfoEx);
SendMessage(Handle, WM_GETTITLEBARINFOEX, 0, LPARAM(@TitleBarInfoEx));
Constraints.MinWidth := Panel1.Width + TitleBarInfoEx.rgrect[5].Right -
TitleBarInfoEx.rgrect[2].Left + 2 * EdgeSize - 2 * BorderWidth;
end;
end;
推荐阅读
- sql-server - SQL Server 2012 - 消息 8114 - 错误?
- android - 初学者 android 应用程序在旧手机 (ZTE) 上崩溃
- c# - ORA-01036: 非法变量名称/编号,在 select 和 from 之间绑定参数
- android - 如何在 Flutter 上更新 Google Play Developer API?
- arrays - 如何打开切片
- firebase - 如何授权 Firebase 域确认电子邮件?
- cen-xfs - 如何使用 XFS 查找 ATM 显示器是否为触摸屏?
- python - 如何在 Pandas 中将 sing 列除以多列?
- jsf - 是否可以获得应用程序的根上下文(在 web.xml 上定义)
- php - 运行选择查询时出现奇怪的 Codeigniter 查询生成器错误