有关dll中包含Form的问题
我是新手,正在学习中。关于创建含form的dll文件的采用下面的方法:
new->Progect->Dynamic-link Library, c++ and vcl。
然后在其中添加一个form。该方法对么。还需要其他的操作吗。
Unit.cpp
#include <vcl.h>
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>
#include <stdlib.h>
#pragma hdrstop
#include "Unit.h"
//---------------------------------------
USEFORM("Unit7_6.cpp", Form1);
//----------------------------------------
extern "C" _declspec(dllexport) void _stdcall CustomerForm(char *st);
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------
void _stdcall CustomerForm(char *st)
{
Form1 = new TForm1(NULL); //动态创建Form对象
Form1->Caption = AnsiString(st);//把调用者传来的字串设为标题
Form1->ShowModal();//显示Form1
delete Form1;
}
Unit.h
//---------------------------------------
#ifndef UnitH
#define UnitH
//---------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------
class TForm1 : public TForm
{
__published:// IDE-managed Components
private:// User declarations
public:// User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------
#endif C++ dll
[解决办法]
cpp文件里没有构造函数的实现啊
你新建一个form看看IDE自动生成的代码