APS NZ
asked on
Changing the Font Color in a TMessageDlg?
Hi
Is there a way to change the font color in a TMessageDlg, and if so, how??
I am using D1 and WFW 3.11
Is there a way to change the font color in a TMessageDlg, and if so, how??
I am using D1 and WFW 3.11
ASKER
Hi Matvey - thanx for replying. You're quite right it is a function not a type. I'm experimenting with the Dialogs unit to see what I can come up with.
I think it's easier to just create your own new form and make it a good-looking dialog. You know how to do that, right? Just place a red-font label on a form and some buttons and there you go...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The color of the font of the button is not changed this way.
There is one (or no) TImage named "image" (for the icon)
There is one TLabel named "message" (for the text)
There are X buttons named:
'Yes'
'No'
'OK'
'Cancel'
'Abort'
'Retry'
'Ignore'
'All'
'Help'
So you can also use the FindComponent method to find the components and change them.
Example:
function MyMessageDlg(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
var
iCount : Integer;
begin
with CreateMessageDialog(Msg, DlgType, Buttons) do
try
HelpContext := HelpCtx;
with TLabel(FindComponent('mess age')) do begin
Font.Color := clYellow;
end;
if FindComponent('image')<>ni l then
with TImage(FindComponent('imag e')) do begin
Left:=0;
Top:=0;
end;
if FindComponent('ok')<>nil then
with TButton(FindComponent('ok' )) do begin
Caption := 'Go ahead';
end;
Result:=ShowModal;
finally
Free;
end;
end;
This way you can even add Buttons
There is one (or no) TImage named "image" (for the icon)
There is one TLabel named "message" (for the text)
There are X buttons named:
'Yes'
'No'
'OK'
'Cancel'
'Abort'
'Retry'
'Ignore'
'All'
'Help'
So you can also use the FindComponent method to find the components and change them.
Example:
function MyMessageDlg(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
var
iCount : Integer;
begin
with CreateMessageDialog(Msg, DlgType, Buttons) do
try
HelpContext := HelpCtx;
with TLabel(FindComponent('mess
Font.Color := clYellow;
end;
if FindComponent('image')<>ni
with TImage(FindComponent('imag
Left:=0;
Top:=0;
end;
if FindComponent('ok')<>nil then
with TButton(FindComponent('ok'
Caption := 'Go ahead';
end;
Result:=ShowModal;
finally
Free;
end;
end;
This way you can even add Buttons
I think Borland made the CreateMessageDlg function available public for other units for the purpose of extension.
Regards Jacco
Regards Jacco
ASKER
Hi Jacco - Thanks for the answer. I really got sick of the "default" font - it would be better even if it was black, not that sickly "purple" color.
Hi Matvey - Thanks for your further comments.
Hi Matvey - Thanks for your further comments.
I know there's the MessageDlg function, but not a TMessageDlg type (??)
In the Dialogs unit sources in the CreateMessageDialog body you see the following lines:
Font.Name := 'MS Sans Serif';
Font.Height := -11;
Font.Style := [fsBold];
You can try and recreate it so you add the color definition. You'll have to copy all this function and rewrite this section as you want.