📄 umsgbox.cpp
字号:
//----------------------------------------
// UMsgBox.cpp
// Coding By:袁军
// 2004-5-18
//----------------------------------------
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "UMsgBox.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "UTemplate"
#pragma resource "*.dfm"
TFormMsgBox *FormMsgBox;
//---------------------------------------------------------------------------
__fastcall TFormMsgBox::TFormMsgBox(TComponent* Owner)
: TFormTemplate(Owner)
{
ShowWindow(Handle, SW_HIDE);
ImageIcon->Visible=false;
LabelCaption->Left=5;
}
//---------------------------------------------------------------------------
void __fastcall TFormMsgBox::MsgBox(AnsiString Caption, AnsiString Text, ButtonType Btntype,MessageType Msgtype)
{
//TODO: Add your source code here
Beep();
LabelCaption->Caption=Caption;
LabelMsg->Caption=Text;
LabelMsg->Visible=true;
if(Btntype==MBOKONLY) //OKONLY时的窗口大小
{
SBtnYes->Caption="确定(&O)";
ImageYes->Visible=true;
SBtnYes->Visible=true;
ImageNo->Visible=false;
SBtnNo->Visible=false;
ImageCancel->Visible=false;
SBtnCancel->Visible=false;
SBtnYes->Left=113;
ImageYes->Left=113;
}
else if(Btntype==MBOKCANCEL) //OKCANCEL时的窗口大小
{
SBtnYes->Caption="确定(&O)";
ImageYes->Visible=true;
SBtnYes->Visible=true;
SBtnNo->Caption="取消(&C)";
ImageNo->Visible=true;
SBtnNo->Visible=true;
ImageCancel->Visible=false;
SBtnCancel->Visible=false;
SBtnYes->Left=70;
ImageYes->Left=70;
SBtnNo->Left=150;
ImageNo->Left=150;
}
else if(Btntype==MBYESNOCANCEL)
{
ImageYes->Visible=true;
SBtnYes->Visible=true;
ImageNo->Visible=true;
SBtnNo->Visible=true;
ImageCancel->Visible=true;
SBtnCancel->Visible=true;
}
if(Msgtype==MBINFORMATION) //信息
{
ImageInformation->Visible=true;
ImageWarning->Visible=false;
ImageError->Visible=false;
}
else if(Msgtype==MBWARNING) //警告
{
ImageInformation->Visible=false;
ImageWarning->Visible=true;
ImageError->Visible=false;
}
else if(Msgtype==MBERROR)
{
ImageInformation->Visible=false;
ImageWarning->Visible=false;
ImageError->Visible=true;
}
SBtnMax->Visible=false;
SBtnMin->Visible=false;
//ismsgbox=true;
ShowModal();
}
void __fastcall TFormMsgBox::SBtnCloseTempClick(TObject *Sender)
{
Id=IDNO;
Close();
}
void __fastcall TFormMsgBox::SBtnYesClick(TObject *Sender)
{
Id=IDYES;
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFormMsgBox::SBtnNoClick(TObject *Sender)
{
Close();
Id=IDNO;
}
//---------------------------------------------------------------------------
void __fastcall TFormMsgBox::SBtnCancelClick(TObject *Sender)
{
Close();
Id=IDCANCEL;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -