Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Customize Message Dialog ?

Posted on 2004-10-05
4
Medium Priority
?
472 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 200 total points
ID: 12241638
0
 

Author Comment

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

thanks
josh
:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

783 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