Solved

Customize Message Dialog ?

Posted on 2004-10-05
4
463 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
automatically logging in via bde delphi 3 69
Need Delphi function to get Youtube video title 5 225
Convert Jpg /PNG To GIF 5 120
Help on project with Soap 10 48
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 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

21 Experts available now in Live!

Get 1:1 Help Now