Solved

Help with ShowMessagePos

Posted on 1998-08-29
5
360 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 100 total points
ID: 1338127
Ok. This is my "official answer".

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Activex get website that activex running on 3 85
Thread safe  opinion 7 126
Printing problem 2 81
Firemonkey DbLookupComboBox equivalent ? 2 38
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now