就象Dialog控件那样
很简单啊,可以有几种办法,可以用新建,在弹出的对话框中选择Dialog From,然后在主窗体中詷用
也可以直接新建一个Form,然后设置其FormStyle的属性就可以了,以后就用动态定义的办法如
TForm3 *form3=new TForm3(this);
给代码让你参考吧
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "PrinterDBGridEh.h"
#include "report_dlg.h"
#pragma resource "make_report.dcr"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TPrinterDBGridEh *)
{
new TPrinterDBGridEh(NULL);
}
//---------------------------------------------------------------------------
__fastcall TPrinterDBGridEh::TPrinterDBGridEh(TComponent* Owner)
: TComponent(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TPrinterDBGridEh::Execute()
{
if(DBGridEh->DataSource->DataSet->Active)
{
TBookmark Bookmark = DBGridEh->DataSource->DataSet->GetBookmark();
DBGridEh->DataSource->DataSet->DisableControls();
Treport_dlg_frm *form=new Treport_dlg_frm(Application);
try
{
form->ShowModal();
}
catch(...)
{
delete form;
form=NULL;
}
delete form;
form=NULL;
DBGridEh->DataSource->DataSet->GotoBookmark(Bookmark);
DBGridEh->DataSource->DataSet->FreeBookmark(Bookmark);
DBGridEh->DataSource->DataSet->EnableControls();
}
else
Application->MessageBox("請先開啟檔案,再作打印","提示",MB_OK);
}
}
//---------------
void __fastcall TPrinterDBGridEh::SetDBGridEh(TDBGridEh *Value)
{
if(Value!=NULL)
Value->FreeNotification(this);
FDBGridEh=Value;
}
//----------------
void __fastcall TPrinterDBGridEh::Setmin_caption(AnsiString Value)
{
if(!Value.IsEmpty())
min_caption=Value;
else
min_caption="";
}
namespace Printerdbgrideh
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TPrinterDBGridEh)};
RegisterComponents("Data Controls", classes, 0);
}
}
//---------------------------------------------------------------------------