2
我基於我的設置 Larger "Select Components" page in Inno Setup。我想知道在進入組件頁面時如何居中設置窗口,因爲在小分辨率下底部按鈕不可見。InnoSetup:如何中心設置窗口
我基於我的設置 Larger "Select Components" page in Inno Setup。我想知道在進入組件頁面時如何居中設置窗口,因爲在小分辨率下底部按鈕不可見。InnoSetup:如何中心設置窗口
目前,沒有任何功能可讓您將嚮導表格僅在垂直方向居中。所以,要創建一個你需要編碼一點點。下面是功能,它允許你爲中心的方向,你在最近的監護儀上選擇的形式,該形式涵蓋了最:
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
type
HMONITOR = THandle;
TMonitorInfo = record
cbSize: DWORD;
rcMonitor: TRect;
rcWork: TRect;
dwFlags: DWORD;
end;
const
MONITOR_DEFAULTTONULL = $0;
MONITOR_DEFAULTTOPRIMARY = $1;
MONITOR_DEFAULTTONEAREST = $2;
function GetMonitorInfo(hMonitor: HMONITOR; out lpmi: TMonitorInfo): BOOL;
external 'GetMonitorInfo{#AW}@user32.dll stdcall';
function MonitorFromWindow(hwnd: HWND; dwFlags: DWORD): HMONITOR;
external '[email protected] stdcall';
procedure CenterForm(Form: TForm; Horz, Vert: Boolean);
var
X, Y: Integer;
Monitor: HMONITOR;
MonitorInfo: TMonitorInfo;
begin
if not (Horz or Vert) then
Exit;
Monitor := MonitorFromWindow(Form.Handle, MONITOR_DEFAULTTONEAREST);
MonitorInfo.cbSize := SizeOf(MonitorInfo);
if GetMonitorInfo(Monitor, MonitorInfo) then
begin
if not Horz then
X := Form.Left
else
X := MonitorInfo.rcWork.Left + ((MonitorInfo.rcWork.Right -
MonitorInfo.rcWork.Left) - Form.Width) div 2;
if not Vert then
Y := Form.Top
else
Y := MonitorInfo.rcWork.Top + ((MonitorInfo.rcWork.Bottom -
MonitorInfo.rcWork.Top) - Form.Height) div 2;
Form.SetBounds(X, Y, Form.Width, Form.Height);
end;
end;
要實現它在你使用the code
,你需要在頁面修改部分正在更改:
...
procedure CurPageChanged(CurPageID: Integer);
begin
if CurpageID = wpSelectComponents then
begin
SaveComponentsPage(CompPagePositions);
LoadComponentsPage(CompPagePositions, 200);
CenterForm(WizardForm, False, True); // <- center the form only vertically
CompPageModified := True;
end
else
if CompPageModified then
begin
LoadComponentsPage(CompPagePositions, 0);
CenterForm(WizardForm, False, True); // <- center the form only vertically
CompPageModified := False;
end;
end;
不客氣! – TLama
'WizardForm'具有可以做到這一點的'Center'方法,但它甚至在水平方向居中。那真的是你想要的嗎?你不想讓它垂直居中嗎? – TLama
我想垂直,因爲哪裏的按鈕不可見是在底部。 – DeXon