Board index » delphi » '&' in Message box

'&' in Message box

Hi, How could I show the "&" sign in message box?
I just got underscore.

such as ShowMessage('R&D');
Thank you.

vincent

 

Re:'&' in Message box


Quote
Vincent Chao wrote:

> Hi, How could I show the "&" sign in message box?
> I just got underscore.

> such as ShowMessage('R&D');
> Thank you.

> vincent

Hi

Just type 2 & like this && , then you got a &

S{*word*249} B.

Re:'&' in Message box


Quote
Vincent Chao wrote:

> Hi, How could I show the "&" sign in message box?
> I just got underscore.

> such as ShowMessage('R&D');
> Thank you.

> vincent

  Simply by typing && (ie R&&D). (same thing with the '.  to send 'Don't
do this', you would send 'Don''t do this...').

Re:'&' in Message box


Quote
Vincent Chao <vc...@courseware.com> wrote:
>Hi, How could I show the "&" sign in message box?
>I just got underscore.
>such as ShowMessage('R&D');
>Thank you.
>vincent

For C++ anyway, you'd just type '&&' to show the amperstand.
I've never tried this is delphi...

dan
d...@intuisysinc.com

Re:'&' in Message box


Quote
> d...@intuisysinc.com wrote in article <4sg7bs$...@clarknet.clark.net>...
> Vincent Chao <vc...@courseware.com> wrote:

> >Hi, How could I show the "&" sign in message box?
> >I just got underscore.
> >such as ShowMessage('R&D');

> For C++ anyway, you'd just type '&&' to show the amperstand.
> I've never tried this is delphi...

This comes about because the message box is using a TLabel to draw the
text, and the default behavior for a TLabel is to show ampersands as
accelerator characters.  I've actually modified the VCL source to prevent
this from happening, as an accelerator character in a message box is
useless, you can't assign it to do anything.  Simply using '&&' wouldn't
work for my needs, because I was reading some text from a database, and
using '&&' would cause the text to look funny in other places it was
displayed, so modifying the VCL was the only real solution for me.

Open DIALOGS.PAS and locate the implementation portion of the
CreateMessageDialog function.  This is a long function, so I will not
quote the entire thing.  The following is a snippet on the changes code,
with some surrounding code for perspective.  Locate the place where this
goes, drop it in, and recompile the unit.  Now you don't have to worry
about using '&' in a message box.    (The following directions are for D1,
and may be different for D2.)

[snip]
    TextRect := Rect(0, 0, Screen.Width div 2, 0);
    {MODIFIED 06/28/96 - DSB}
    {Modified to prevent showing of accelerator character.}
    DrawText(Canvas.Handle, StrPCopy(C, Msg), -1, TextRect, DT_CALCRECT or
DT_WORDBREAK or DT_NOPREFIX);

    { create the text }
    MsgLabel := TLabel.Create(Result);
    MsgLabel.Name := 'Message';
    MsgLabel.Parent := Result;
    {ADDED 06/28/96 - DSB}
    {Modified to prevent showing of accelerator character.}
    MsgLabel.ShowAccelChar := False;
    MsgLabel.WordWrap := True;
    MsgLabel.Caption := Msg;
    MsgLabel.BoundsRect := TextRect;
[snip]
--
David S. Becker
ADP Dealer Services (Plaza R&D)
mailto:d...@plaza.ds.adp.com
(503)402-3236

Re:'&' in Message box


Quote
> Vincent Chao <vc...@courseware.com> wrote in article

<31E6C9CA.1...@courseware.com>...

Quote
> Hi, How could I show the "&" sign in message box?
> I just got underscore.

You should use a double-ampersand whereever you want an ampersand to
appear.  such as 'Mort && Mindy'

                        David Green

Other Threads