Re: ShowMessage can have any title!

From: Mark Arkey (markarkey1_at_msn.com)
Date: 05/23/04


Date: 22 May 2004 21:42:20 -0700

korax1214@mailandnews.co.uk (Robert J Baker) wrote in message news:<fe420e86.0405221116.11eed448@posting.google.com>...

> The dialog box popped up by ShowMessage (which is the simplest way I
> know to pop-up an on-the-fly dialog box with no bitmap, a single-line
> message and an OK button) is supposed to have your application's name
> as its title, but I've found a simple way to change this, as in this
> code fragment:
>
> g:=Application.Title;
> Application.Title:='How are you gentlemen?!'
> ShowMessage('All your base are belong to us.');
> Application.Title:=g;

I never use ShowMessage except for debugging, and one reason is the
problem you mention (there are others). While your solution works, I
don't personally care for it for as many reasons. The MessageDlg
function gives you pretty good control over the message box, and the
MessageBox function gives you control over the caption as well. Why
change the application name when you can just call another function?

I typically wrap MessageBox or MessageDlg into multiple library
functions that streamline what I need to do. This saves me the bother
of having to pass all the necessary parameters to MessageDlg and
MessageBox. Library routines I have at my disposal are
ShowInfoMessage (similar to ShowMessage), ShowConfirmationMessage
(which returns mrYes, mrNo, or mrCancel), ShowErrorMessage, etc. I
don't actually have a ShowHowAreYouGentlemenMessage, but perhaps I'll
add it for you!

In any event, to be totally frank, I wouldn't want a person who
inherited my code seeing me changing the application title to change
the caption in a message box!!! :)

Mark Arkey

"When I get real bored, I like to drive downtown and get a great
parking spot, then sit in my car and count how many people ask if I'm
leaving."
  -Stephen Wright