Solved

Customize Message Dialog ?

Posted on 2004-10-05
4
466 Views
Last Modified: 2010-04-05
hey,
Is it possible to customize the message dialog without using any component?

can i create a new button for the message dialog? if is possible, how can i do it.

thanks
josh
0
Comment
Question by:joshfly
4 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 12234776
You could use your own message dialog derived from the original one, but customized.
Something like:

function MyMessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
begin
  with CreateMessageDialog(Msg, DlgType, Buttons) do
  begin
    try
      HelpContext := HelpCtx;
      Color := $00A2EAB0;
      Result := ShowModal;
    finally
      free;
    end;
  end;
end;
0
 
LVL 1

Expert Comment

by:Bart_Thomas
ID: 12241532
Another way is to use the Windows MessageBox. It is possible to customize it through a "trick".
You post a user-message and in its hander you can change caption, buttoncaption, etc:

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure WM_Hack (var message: TMessage); message WM_USER + 1025;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PostMessage (Handle, WM_USER + 1025, 0,0);
  MessageBox (Handle, 'Test', 'MyApplication', MB_OKCANCEL or MB_ICONINFORMATION);
end;

procedure TForm1.WM_Hack(var message: TMessage);
var
  h: HWND;
begin
  h := FindWindow (WC_DIALOG, 'MyApplication');
  if GetParent (h) = Handle then
  begin
    SetDlgItemText (h, ID_OK, '&Login');
    SetDlgItemText (h, ID_CANCEL, '&Cancel');
  end;
end;
0
 
LVL 2

Accepted Solution

by:
-Karamja- earned 50 total points
ID: 12241638
0
 

Author Comment

by:joshfly
ID: 12256014
Thanks ! -Karamja-
that's what i want.

thanks
josh
:)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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