user2817127
user2817127

Reputation: 21

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

I want to center a message on my form (FM, XE5). It works well in (FM, XE2):

The placement coordinates (myform.left+x, myform.top+y) are correct but the message is always placed in the center of the monitor that hosts the center of my form.

Here's the problem expressed in its easiest form:

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).

So "ShowMessagePos" acts the same as "ShowMessage".

Upvotes: 1

Views: 270

Answers (1)

cubik2k
cubik2k

Reputation: 1

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;

Upvotes: 0

Related Questions