我注意到 Delphi 11.1 Windows 應用程式中的一個奇怪問題。
單擊按鈕 5 分鐘后,我需要在螢屏右下方顯示 Form3:
procedure TForm1.Timer2Timer(Sender: TObject);
begin
Timer2.Enabled := False;
// Set form position on bottom right of the screen
with Form3 do
begin
Top := Screen.Height - Form3.Height - GetTaskBar_Y_Bottom_Height();
Left := Screen.Width - Form3.Width - GetTaskBar_X_Right_Width();
end;
// Now show the form
Form3.Show;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer2.Enabled := True;
end;
它作業正常,Form3 顯示在螢屏的右下方……嗯,大多數時候。
因為在某些情況下,它會顯示在螢屏的左上角:

即使 Screen.Height 和 Screen.Width 是正確的:
Screen.Height = 1080
Screen.Width = 1920
你有什么建議可以嗎?
一些額外的細節:
- 我正在使用解析度為 1920 x 1080 的單個顯示幕。
- 應用程式的清單使用“Per Monitor v2”。
uj5u.com熱心網友回復:
由于您還沒有回應我對這些GetTaskBar...功能的要求,我們可以放棄它們并使用更好的方法來評估可用的作業區域。
此外,您不考慮任務欄的位置。許多(如果不是大多數)用戶將其保留在底部,但用戶可能更喜歡將其保留在顯示幕的左側、頂部或右側邊緣。
要考慮不同的布局,您可以使用以下OnShow事件Form3:
procedure TForm3.FormShow(Sender: TObject);
begin
Left := Screen.WorkAreaRect.Right - Width;
Top := Screen.WorkAreaRect.Bottom - Height;
end;
你會從定時器事件中呼叫它Form1
procedure TForm1.Timer2Timer(Sender: TObject);
begin
Timer2.Enabled := False;
Form3.Show;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/503915.html
標籤:德尔福
