PDA

View Full Version : message box



مجید رجبی
چهارشنبه 01 شهریور 1385, 10:26 صبح
چگونه می توان گزینه های yes , no را در messagebox به حالت بله و خیر تبدیل کرد

mzjahromi
چهارشنبه 01 شهریور 1385, 12:45 عصر
اگر اشتباه نکنم



if( Application.MessageBox("is this a test?","text",mb_yesno)=ID_YES)
.....

Mahyaa
چهارشنبه 01 شهریور 1385, 13:30 عصر
منظورتون متنشه که فارسی شه ؟!
فکر نکنم بشه !

اگه میخواهید فارسی بشه باید خودتون یک MessageBox بسازید!

mzjahromi
چهارشنبه 01 شهریور 1385, 13:32 عصر
چگونه می توان گزینه های yes , no را در messagebox به حالت بله و خیر تبدیل کرد
ببخشید من اشتباه فهمیدم
میتونید از Resource DLL Wizard استفاده کنید

sasan_vm
پنج شنبه 02 شهریور 1385, 08:09 صبح
سلام

این هم MessageDlg کاملا فارسی:



void __fastcall SetStyle(TButton * Btn)
{
TBitBtn * bBtn;
bBtn = new TBitBtn (Btn->Owner);
bBtn->Parent = Btn->Parent;
bBtn->Kind = (TBitBtnKind) Btn->Tag;
bBtn->Caption = Btn->Caption;
bBtn->ModalResult = Btn->ModalResult;
bBtn->TabOrder = Btn->TabOrder;
bBtn->Height = Btn->Height + 2;
bBtn->Width = Btn->Width + 4;
bBtn->Left = Btn->Left;
bBtn->Top = Btn->Top;

delete Btn;
}
int __fastcall MsgDlg(const AnsiString Msg, TMsgDlgType DlgType, TMsgDlgButtons Buttons, int HelpCtx)
{
// variables that use in function
TForm * dlg; // Store dialog box
TButton * btn; // Dynamic cast use for items in dialog
int mResult, Idx, uId, kId; // ModalResult from dialog box
static const char * BtnCaption [] = { // constant labels buttons and name
"بله", "Yes",
"خیر", "No",
"تائید", "OK",
"لغو", "Cancel",
"خاتمه", "Abort",
"دوباره", "Retry",
"صرفنظر", "Ignore",
"همه", "All",
"همه نه", "NotoAll",
"همه بله", "YestoAll",
"راهنما", "Help",
NULL
};
static const TBitBtnKind BtnKind [] = { // constant button kind
bkYes,
bkNo,
bkOK,
bkCancel,
bkAbort,
bkRetry,
bkIgnore,
bkAll,
bkNo,
bkYes,
bkHelp
};
// Start block of code
__try
{
dlg = CreateMessageDialog(Msg, DlgType, Buttons);
dlg->HelpContext = HelpCtx;
dlg->BiDiMode = bdRightToLeft;
dlg->Position = dlg->Parent ? poOwnerFormCenter : poScreenCenter;
if ( IsRun() )
dlg->Font->Assign(Application->MainForm->Font);

switch (DlgType)
{
case mtWarning: dlg->Caption = "اخطار";
uId = MB_ICONASTERISK; break;
case mtError: dlg->Caption = "خطا";
uId = MB_ICONHAND; break;
case mtInformation: dlg->Caption = "اطلاعات";
uId = MB_ICONEXCLAMATION; break;
case mtConfirmation: dlg->Caption = "پرسش";
uId = MB_ICONQUESTION; break;
case mtCustom: dlg->Caption = Application->Title;
uId = MB_OK;
}
// change buttons caption and right to left order
for (Idx = 1, kId = 0; Idx <= 21; Idx += 2, kId++)
{
btn = dynamic_cast <TButton *> (dlg->FindComponent(BtnCaption[Idx]));
if (btn)
{
btn->Caption = BtnCaption[Idx-1];
btn->Left = dlg->ClientWidth - btn->Width - btn->Left;
btn->Tag = BtnKind [kId];
SetStyle(btn);
}
}
// change icon & message and right to left order
TLabel * Txt = dynamic_cast <TLabel *>(dlg->FindComponent("Message"));
if (Txt)
{
Txt->Left = dlg->ClientWidth - Txt->Width - Txt->Left;
Txt->Transparent = true;
}
TImage * Img = dynamic_cast <TImage *>(dlg->FindComponent("Image"));
if (Img)
{
Img->Left = dlg->ClientWidth - Img->Width - Img->Left;
}
MessageBeep(uId);
mResult = dlg->ShowModal();
}
__finally
{
delete dlg;
}
return mResult;
}