Solved

Help with ShowMessagePos

Posted on 1998-08-29
5
367 Views
Last Modified: 2010-04-03
Could someone give me an example of how to get ShowMessagePos to center itself in the active form.

Thanks
0
Comment
Question by:evel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1338123
Why don't you use MessageDlgPos?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338124
Here is an example from Delphi help file =)

procedure TForm1.Button1Click(Sender: TObject);
begin
  MessageDlgPos('Are you there?',mtConfirmation, mbYesNoCancel, 0, 200, 200);
end;

Regards,
Viktor Ivanov
0
 
LVL 3

Expert Comment

by:vladika
ID: 1338125
All procedures (ShowMessage, MessageDlgPos etc) found on the function CreateMessageDialog
For details see dialogs.pas

So, I wrote procedure ShowMessageCenter.
You can use it instead of ShowMessagePos or you can modify it for your needs.

procedure ShowMessageCenter(const Msg: string);
var R: TRect;
begin
  if not Assigned(Screen.ActiveForm) then ShowMessage(Msg) else
  with CreateMessageDialog(Msg, mtCustom, [mbOK]) do
  try
    GetWindowRect(Screen.ActiveForm.Handle, R);
    Left := R.Left + ((R.Right - R.Left) div 2) - (Width div 2);
    Top := R.Top + ((R.Bottom - R.Top) div 2) - (Height div 2);
    ShowModal;
  finally
    Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessageCenter('I am centered in the active form');
end;


0
 

Author Comment

by:evel
ID: 1338126
Thanks vladika, that's just what I was looking for. Please answer the question so I can give you credit.
0
 
LVL 3

Accepted Solution

by:
vladika earned 100 total points
ID: 1338127
Ok. This is my "official answer".

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question