?
Solved

Help with ShowMessagePos

Posted on 1998-08-29
5
Medium Priority
?
381 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
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 400 total points
ID: 1338127
Ok. This is my "official answer".

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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