Solved

Customize Message Dialog ?

Posted on 2004-10-05
4
462 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:joshfly
Comment Utility
Thanks ! -Karamja-
that's what i want.

thanks
josh
:)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

7 Experts available now in Live!

Get 1:1 Help Now