ShowMessagePos(msg,myform.left+x,myform.top+y)

daupos2t  于 2022-09-21  发布在  其他
关注(0)|答案(1)|浏览(109)

我想在我的表单(FM、XE5)上居中显示一条消息。它在(FM、XE2)中运行良好:

放置坐标(myform.left+x, myform.top+y)是正确的,但消息始终放置在我的表单中心所在的监视器的中心。

以下是以最简单的形式表达的问题:

ShowMessagePos('Hello',0,0) gets posted at screen center; as does 
ShowMessagePos('Hello',1700,0), as does
ShowMessagePos('Hello',1700,1100), as does
ShowMessagePos('Hello',0,1100).

因此,“ShowMessagePos”的作用与“ShowMessage”相同。

svmlkihl

svmlkihl1#

function TForm1.ShowMessageCenter(const AOwner: TForm; const Msg: string):Integer;
begin
  with CreateMessageDialog(Msg, mtInformation, [mbOk]) do
    try
      Left := AOwner.Left + (AOwner.Width - Width) div 2;
      Top := AOwner.Top + (AOwner.Height - Height) div 2;
      Result := ShowModal;
    finally
      Free;
    end
end;

相关问题