Translating the MessageBox
Translating the MessageBox
Hi
We have many message dialogs of the windows-type "MessageBox" in our code.
Is there a way to internationalize these type of dialog box? Yes, we can translate the messagetext, no problem, but what about the "Yes", "No", etc. buttoncaptions?
I've read the FAQ and i know that there are the tsilang versions of MessageDlg and MessageDlgPos, but these dialog boxes have not the same possibilites like the windows messagebox. What we need is to set the headerline of a dialog box.
Thanks and best regards
Robert
We have many message dialogs of the windows-type "MessageBox" in our code.
Is there a way to internationalize these type of dialog box? Yes, we can translate the messagetext, no problem, but what about the "Yes", "No", etc. buttoncaptions?
I've read the FAQ and i know that there are the tsilang versions of MessageDlg and MessageDlgPos, but these dialog boxes have not the same possibilites like the windows messagebox. What we need is to set the headerline of a dialog box.
Thanks and best regards
Robert
In order to internationalize this you will still need to use TsiLang's methods with small trick:
And use InternalMessageDlg() in your code instead of MessageBox, passing there the TsiLang instance and needed captions for dialogs.
Does this help?
P.S. Typed from scratch so it may contain mistypes.
Code: Select all
type
TAccessLang = class(TsiCustomLang)
end;
function InternalMessageDlg(const siLang: TsiCustomLang; const MsgCaption: string; const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; const DefaultBtn: TMsgDlgBtn = mbOK; const CancelBtn: TMsgDlgBtn = mbCancel): Integer;
begin
with TAccessLang(siLang).CreateMessageDialog(Msg, DlgType, Buttons, DefaultBtn, CancelBtn) do
try
HelpContext := HelpCtx;
HelpFile := Application.HelpFile;
Caption := MsgCaption;
Result := ShowModal;
finally
Release;
end;
end;
Does this help?
P.S. Typed from scratch so it may contain mistypes.

Best regards,
Igor Siticov.
Igor Siticov.
I'm not a C++ Guru but you can try:
You can place this code in some global unit and just call it instead of MessageBox.
Hope this helps.
Code: Select all
class PASCALIMPLEMENTATION TAccessLang : public TsiCustomLang
{
typedef TsiCustomLang inherited;
public:
Forms::TForm* __fastcall CreateMessageDialog(const AnsiString Msg, Dialogs::TMsgDlgType DlgType, Dialogs::TMsgDlgButtons Buttons, const Dialogs::TMsgDlgBtn DefaultBtn = (Dialogs::TMsgDlgBtn)(0x2), const Dialogs::TMsgDlgBtn CancelBtn = (Dialogs::TMsgDlgBtn)(0x3)) {
return (TsiCustomLang::CreateMessageDialog(Msg, DlgType, Buttons, DefaultBtn, CancelBtn));
}
};
int __fastcall InternalMessageDlg(const TsiCustomLang * siLang, const AnsiString MsgCaption, const AnsiString Msg, Dialogs::TMsgDlgType DlgType, Dialogs::TMsgDlgButtons Buttons, int HelpCtx, const Dialogs::TMsgDlgBtn DefaultBtn = (Dialogs::TMsgDlgBtn)(0x2), const Dialogs::TMsgDlgBtn CancelBtn = (Dialogs::TMsgDlgBtn)(0x3)){
TAccessLang * ALang = (TAccessLang *)siLang;
TForm * MsgForm = ALang->CreateMessageDialog(Msg, DlgType, Buttons, DefaultBtn, CancelBtn);
int I;
try
{
MsgForm->HelpContext = HelpCtx;
MsgForm->HelpFile = Application->HelpFile;
MsgForm->Caption = MsgCaption;
I = MsgForm->ShowModal();
return (I);
}
__finally
{
MsgForm->Release();
}
return (I);
}
Hope this helps.
Best regards,
Igor Siticov.
Igor Siticov.
Message box
I use C++Builder as well. I copy the 2nd code into a unit, compiled it. I got quite a few errorr:
Error: E2303 type name expected @
class PASCALIMPLEMENTATION TAccessLang : public TsiCustomLang
{
Error: E2090 Qulifier "TsiCustomLang' is not a class or namespace name @
return (TsiCustomLang::CreateMessageDialog(Msg, DlgType, Buttons, DefaultBtn, CancelBtn));
and some more. Please point me what's wrong there. Thank you.
Error: E2303 type name expected @
class PASCALIMPLEMENTATION TAccessLang : public TsiCustomLang
{
Error: E2090 Qulifier "TsiCustomLang' is not a class or namespace name @
return (TsiCustomLang::CreateMessageDialog(Msg, DlgType, Buttons, DefaultBtn, CancelBtn));
and some more. Please point me what's wrong there. Thank you.

Just be sure to add in your header. 
Code: Select all
#include "siComp.hpp"

Best regards,
Igor Siticov.
Igor Siticov.
parameters to pass
It works. No more error as I included #include "siComp.hpp".
Another question:
What is the last two parameters to pass when make the call?
const Dialogs::TMsgDlgBtn DefaultBtn = (Dialogs::TMsgDlgBtn)(0x2),
const Dialogs::TMsgDlgBtn CancelBtn = (Dialogs::TMsgDlgBtn)(0x3))
Thankyou.
Another question:
What is the last two parameters to pass when make the call?
const Dialogs::TMsgDlgBtn DefaultBtn = (Dialogs::TMsgDlgBtn)(0x2),
const Dialogs::TMsgDlgBtn CancelBtn = (Dialogs::TMsgDlgBtn)(0x3))
Thankyou.
message box
I still struggle with the code you provided to replace the mesaage box.
What is the first parameter to pass when making the call?
InternalMessageDlg(const TsiCustomLang * siLang, ...
The TsiCustomLang data type.
If possible, please give me an example of the call.
Thanks for your help so far.
What is the first parameter to pass when making the call?
InternalMessageDlg(const TsiCustomLang * siLang, ...
The TsiCustomLang data type.
If possible, please give me an example of the call.
Thanks for your help so far.
Hi,
You can use something like this:
InternalMessageDlg(siLang1, "Some caption", "Some message text!", mtWarning, TMsgDlgButtons() << mbOK << mbCancel << mbYes << mbNo, 0, mbOK, mbCancel);
The full example (BCB6) project could be downloaded from:
http://www.sicomponents.com/soft/demos/ ... ageBox.zip
Hope this helps.
You can use something like this:
InternalMessageDlg(siLang1, "Some caption", "Some message text!", mtWarning, TMsgDlgButtons() << mbOK << mbCancel << mbYes << mbNo, 0, mbOK, mbCancel);
The full example (BCB6) project could be downloaded from:
http://www.sicomponents.com/soft/demos/ ... ageBox.zip
Hope this helps.
Best regards,
Igor Siticov.
Igor Siticov.
Messagebox header and buttons
Hi,
I've used siComponents example code for Messagebox
InternalMessageDlg(siLang1,siLang1->GetTextOrDefault("IDS_8" /* "Test" */ ),siLang1->GetTextOrDefault("IDS_8" /* "Test" */ ),mtWarning, mbOKCancel , 0 );
However, in Japanese the message itself comes out as it should, but the dialogs Header caption and buttons are garbled. How do i get these to also show in Japanese? (the Dialogs section in the Translations tree view on the translation Editor have all be translated into Japanese.
Many Thanks
Angus.
I've used siComponents example code for Messagebox
InternalMessageDlg(siLang1,siLang1->GetTextOrDefault("IDS_8" /* "Test" */ ),siLang1->GetTextOrDefault("IDS_8" /* "Test" */ ),mtWarning, mbOKCancel , 0 );
However, in Japanese the message itself comes out as it should, but the dialogs Header caption and buttons are garbled. How do i get these to also show in Japanese? (the Dialogs section in the Translations tree view on the translation Editor have all be translated into Japanese.
Many Thanks
Angus.