tanm
asked on
coloring the message dialog..
Is there a way to display a message dialog with customised colours.?
I am using the "messagedlg()" command.
I am using the "messagedlg()" command.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
It is not possible without creating your own form ! Because windows is calling an API .
It is not possible without creating your own form ! Because windows is calling an API .
Not necessarily ... I think you can override the CreateMessageDialog() for that ...
Let me check.
Let me check.
Ok ... my answer is "Yes", according to the question. The question simply says "Is there a way...?" and yes, there is. Not with MessageDlg(), but there sure is. And except for the color, the dialog looks exactly like the one with MessageDlg().
If you are willing to change all the MessageDlg() commands in your app to, say, MyMessageDlg(), you can change the background of your boxes to a different color.
Of course, you have to write your own MyMessageDlg like this:
function MyMessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
begin
with CreateMessageDialog(Msg, DlgType, Buttons) do
begin
try // ..finally
HelpContext := HelpCtx;
// Let's try red
Color := $000000FF;
Result := ShowModal;
finally
free;
end; // try
end;
end;
If you try, you can see that only the background is red; the buttons are still grey.
Now that I think of it, what I did is exactly what d32coder said... I have created a new Form that emulates the messagebox, with a coloring twist. I just created the form using code supplied by Delphi.
I personally will consider this good enough code. ^_^
By the way, if you want to change the button colors as well, do post a comment here.
If you are willing to change all the MessageDlg() commands in your app to, say, MyMessageDlg(), you can change the background of your boxes to a different color.
Of course, you have to write your own MyMessageDlg like this:
function MyMessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
begin
with CreateMessageDialog(Msg, DlgType, Buttons) do
begin
try // ..finally
HelpContext := HelpCtx;
// Let's try red
Color := $000000FF;
Result := ShowModal;
finally
free;
end; // try
end;
end;
If you try, you can see that only the background is red; the buttons are still grey.
Now that I think of it, what I did is exactly what d32coder said... I have created a new Form that emulates the messagebox, with a coloring twist. I just created the form using code supplied by Delphi.
I personally will consider this good enough code. ^_^
By the way, if you want to change the button colors as well, do post a comment here.
ASKER
Brilliant! That's is precisely what i need..
Thanks very much..
Thanks very much..
I think this isn't possible, because MessageDlg() uses a windows-api-function to display the messagebox....
The colors of the msgbox are determined by the system settings, so you could change these settings..
regards
rene