我想在borland C++ builder中自定義messagedlg。但是代碼如下改爲改變按鈕標題,在對話框的左上角創建新的按鈕。自定義MessageDlg
#include <vcl.h>
#pragma hdrstop
#include "frmMsgDlg.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
int __fastcall MsgDlg(const String Msg, TMsgDlgType DlgType, TMsgDlgButtons Buttons, const String* Captions, int Captions_maxidx)
{
int m = 0;
TButton *DlgButton;
int CaptionIndex = 0;
TForm* aMsgDlg = CreateMessageDialog(Msg, DlgType, Buttons);
aMsgDlg->Color = TColor(clWindow);
for (m = 0; m <= aMsgDlg->ComponentCount - 1; m++)
{
if (dynamic_cast< TButton *>(aMsgDlg->Components[m]))
{
DlgButton = new TButton(aMsgDlg->Components[m]);
DlgButton->Parent = aMsgDlg;
if (CaptionIndex > Captions_maxidx /*# High(Captions) */) break;
DlgButton->WordWrap = true;
DlgButton->Caption = Captions[CaptionIndex];
DlgButton->Width = 56;
DlgButton->Height= 28;
DlgButton->Cancel = false;
CaptionIndex++;
}
}
return aMsgDlg->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
int msg;
String capt[2] = {"PO","JO"};
msg = MsgDlg("Tre tentime dështuan, ju lutem startoni programin nga ikona!!!", mtInformation,TMsgDlgButtons() << mbOK <<mbCancel,capt,2);
}
//---------------------------------------------------------------------------
非常感謝。就是這個。 – 2010-12-01 08:02:35