Meng Indonesiakan message Dialog
sumber : http://wishknew.multiply.com/journal/item/118/classIndonesianDialog
var tt,r,l : integer; sNumRev : string;
begin
tt := MessageDlg('Revisi invoice ini?',mtConfirmation,[mbYes,mbNo],0);
if tt = 6 then
One way:
This approach works for all Delphi versions.
Previously, I compiled a stringtable resource into my exe
to do multi-language apps.
I have modified this to be quick and simple for any number
of languages. remember, Delphi creates it's own .RES file
and the INCLUDE file is loaded in there as a string
resource.
This is how I used it for multi-language dialogs with the
changes.
Here is some example code, give it a try:
unit French1;
interface
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
{$INCLUDE french.txt}
{ Here is the way the include file for this project looks:
In French: called french.txt
const
sAttention = 'Attention';
sCondition = 'Pas de condition Selectionnée';
sAlways = 'Toulours';
sDelete = 'Ne peux effacer la condition ''Toujours''';
sConfirm = 'Confirmation';
sDeleteConfirm = 'Effacer cette condition?';
sYesBtn = '&Oui';
sNoBtn = '&Non';
In English: called english.txt
const
sAttention = 'Attention';
sCondition = 'No Condition definition selected!';
sHow = 'Always';
sDelete = 'Cannot delete the ''always'' condition.';
sConfirm = 'Confirmation';
sDeleteConfirm = 'Delete the condition?';
sYesBtn = 'Yes';
sNoBtn = 'No';
}
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
j : integer;
DialogForm : tform;
begin
Application.NormalizeTopMosts;
{No Condition Selected!}
DialogForm := CreateMessageDialog(sCondition,mtWarning,
[mbOK]);
{Attention}
DialogForm.Caption := sAttention;
DialogForm.showmodal;
Application.RestoreTopMosts;
{Cannot Delete the 'always' condition}
DialogForm := CreateMessageDialog(sDelete,mtWarning,[mbOK]);
{Always}
DialogForm.caption := sHow;
DialogForm.showmodal;
Application.RestoreTopMosts;
{Delete the condition?}
DialogForm := CreateMessageDialog(sDeleteConfirm,mtInformation,
[mbYes, mbNo]);
{confirmation}
DialogForm.caption := sConfirm;
for j := 0 to DialogForm.controlCount-1 do
begin
if DialogForm.controls[j] is tButton then
with tButton(DialogForm.controls[j]) do
begin
if Name = 'btnYes' then caption := sYesBtn;
if Name = 'btnNo' then caption := sNoBtn;
end;
end;
DialogForm.showmodal;
end;
end.
Confusious say:
Never stand between fire hydrant and dog.
MB34
Lalavava
10-02-2003, 10:16 AM
function MyMessageDialog(const Msg: string; DLGCaption: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string): Integer;
var
i: Integer;
dlgButton: TButton;
CaptionIndex: Integer;
begin
{ Create the Dialog }
with CreateMessageDialog(Msg, DlgType, Buttons) do begin
captionIndex := 0;
Caption := DLGCaption;
{ Loop through Objects in Dialog }
for i := 0 to ControlCount - 1 do
begin
{ If the object is of type TButton, then }
if (Components[i] is TButton) then
begin
dlgButton := TButton(Components[i]);
if CaptionIndex > High(Captions) then Break;
{ Give a new caption from our Captions array}
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := ShowModal;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if MyMessageDialog('Text, 'Caption', mtConfirmation, mbOKCancel, ['yES', 'nO']) = mrOk then
ShowMessage('"yES" clicked')
else
ShowMessage('"nO" clicked');
end;
Please click accept if this helps
Norrit
10-02-2003, 11:04 PM
I normally use the following function (stripped version) ...
function ShowMsg (const Msg: String; DlgType: TMsgDlgType = mtInformation; Buttons: TMsgDlgButtons = [mbOK]; HelpCtx: Longint = 0): Word;
var
Btn : TButton;
LanguageID : TLanguage;
begin
with CreateMessageDialog (Msg, DlgType, Buttons) do
try
Btn := TButton (FindComponent ('CANCEL'));
if Btn <> nil then
Btn.Caption := 'Annuleren';
Btn := TButton (FindComponent ('OK'));
if Btn <> nil then
Btn.Caption := 'Ok';
btn := TButton (FindComponent ('YES'));
if Btn <> nil then
Btn.Caption := 'Ja';
btn := TButton (FindComponent ('NO'));
if Btn <> nil then
Btn.Caption := 'Nee';
Caption := Application.Title;
Position := poMainFormCenter;
Result := ShowModal;
finally
Free;
end;
end; // ShowMsg
MvG
Peter
var tt,r,l : integer; sNumRev : string;
begin
tt := MessageDlg('Revisi invoice ini?',mtConfirmation,[mbYes,mbNo],0);
if tt = 6 then
One way:
This approach works for all Delphi versions.
Previously, I compiled a stringtable resource into my exe
to do multi-language apps.
I have modified this to be quick and simple for any number
of languages. remember, Delphi creates it's own .RES file
and the INCLUDE file is loaded in there as a string
resource.
This is how I used it for multi-language dialogs with the
changes.
Here is some example code, give it a try:
unit French1;
interface
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
{$INCLUDE french.txt}
{ Here is the way the include file for this project looks:
In French: called french.txt
const
sAttention = 'Attention';
sCondition = 'Pas de condition Selectionnée';
sAlways = 'Toulours';
sDelete = 'Ne peux effacer la condition ''Toujours''';
sConfirm = 'Confirmation';
sDeleteConfirm = 'Effacer cette condition?';
sYesBtn = '&Oui';
sNoBtn = '&Non';
In English: called english.txt
const
sAttention = 'Attention';
sCondition = 'No Condition definition selected!';
sHow = 'Always';
sDelete = 'Cannot delete the ''always'' condition.';
sConfirm = 'Confirmation';
sDeleteConfirm = 'Delete the condition?';
sYesBtn = 'Yes';
sNoBtn = 'No';
}
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
j : integer;
DialogForm : tform;
begin
Application.NormalizeTopMosts;
{No Condition Selected!}
DialogForm := CreateMessageDialog(sCondition,mtWarning,
[mbOK]);
{Attention}
DialogForm.Caption := sAttention;
DialogForm.showmodal;
Application.RestoreTopMosts;
{Cannot Delete the 'always' condition}
DialogForm := CreateMessageDialog(sDelete,mtWarning,[mbOK]);
{Always}
DialogForm.caption := sHow;
DialogForm.showmodal;
Application.RestoreTopMosts;
{Delete the condition?}
DialogForm := CreateMessageDialog(sDeleteConfirm,mtInformation,
[mbYes, mbNo]);
{confirmation}
DialogForm.caption := sConfirm;
for j := 0 to DialogForm.controlCount-1 do
begin
if DialogForm.controls[j] is tButton then
with tButton(DialogForm.controls[j]) do
begin
if Name = 'btnYes' then caption := sYesBtn;
if Name = 'btnNo' then caption := sNoBtn;
end;
end;
DialogForm.showmodal;
end;
end.
Confusious say:
Never stand between fire hydrant and dog.
MB34
Lalavava
10-02-2003, 10:16 AM
function MyMessageDialog(const Msg: string; DLGCaption: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string): Integer;
var
i: Integer;
dlgButton: TButton;
CaptionIndex: Integer;
begin
{ Create the Dialog }
with CreateMessageDialog(Msg, DlgType, Buttons) do begin
captionIndex := 0;
Caption := DLGCaption;
{ Loop through Objects in Dialog }
for i := 0 to ControlCount - 1 do
begin
{ If the object is of type TButton, then }
if (Components[i] is TButton) then
begin
dlgButton := TButton(Components[i]);
if CaptionIndex > High(Captions) then Break;
{ Give a new caption from our Captions array}
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := ShowModal;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if MyMessageDialog('Text, 'Caption', mtConfirmation, mbOKCancel, ['yES', 'nO']) = mrOk then
ShowMessage('"yES" clicked')
else
ShowMessage('"nO" clicked');
end;
Please click accept if this helps
Norrit
10-02-2003, 11:04 PM
I normally use the following function (stripped version) ...
function ShowMsg (const Msg: String; DlgType: TMsgDlgType = mtInformation; Buttons: TMsgDlgButtons = [mbOK]; HelpCtx: Longint = 0): Word;
var
Btn : TButton;
LanguageID : TLanguage;
begin
with CreateMessageDialog (Msg, DlgType, Buttons) do
try
Btn := TButton (FindComponent ('CANCEL'));
if Btn <> nil then
Btn.Caption := 'Annuleren';
Btn := TButton (FindComponent ('OK'));
if Btn <> nil then
Btn.Caption := 'Ok';
btn := TButton (FindComponent ('YES'));
if Btn <> nil then
Btn.Caption := 'Ja';
btn := TButton (FindComponent ('NO'));
if Btn <> nil then
Btn.Caption := 'Nee';
Caption := Application.Title;
Position := poMainFormCenter;
Result := ShowModal;
finally
Free;
end;
end; // ShowMsg
MvG
Peter
Komentar