2014-03-30 80 views

回答

2

目前,沒有任何功能可讓您將嚮導表格僅在垂直方向居中。所以,要創建一個你需要編碼一點點。下面是功能,它允許你爲中心的方向,你在最近的監護儀上選擇的形式,該形式涵蓋了最:

[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; 
+0

不客氣! – TLama