dll中动态生成控件的问题

yybailan 2003-02-24 04:11:07
我需要做一个dll,这个dll导出函数类似于Showform(TForm * form)
form是调用这个dll时传来的TForm的地址。在dll中,要在这个form上动态生成控件。
我是这样写的
extern "C" void _declspec Showform(TForm *form)
{
TButton * Button2= new TButton(form);
Button2->Caption="new";
Button2->Left=100;
Button2->Top=50;
Button2->Parent=form;
Button2->Visible=true;
form->ShowModal();
}

在调用这个dll的程序中我传进来了一个form地址,但一运行,就说cannot assing a font to font'
请问这是什么问题啊
...全文
56 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ThinkX 2003-02-24
  • 打赏
  • 举报
回复
你应该设置Parent属性。
但是应该还有问题,问题的原因可能是dll中的Application和主程序中的Application不一样。还有一些其他的原因,你出的这个错误我以前见过,解决挺麻烦的。
arran 2003-02-24
  • 打赏
  • 举报
回复
extern "C" __declspec(dllexport) void __stdcall runform(TForm * form);
void __stdcall runform(TForm * form)
{
form = new TForm(Application);
form->Width = 200;
form->Height = 100;
form->Position = poScreenCenter;
TButton * button1 = new TButton(form);
button1->Parent = form;
button1->Left = 100;
button1->Top = 50;
button1->Caption = "new button";
button1->Visible = true;
form->ShowModal();
delete button1;
delete form;
}
lanren_me 2003-02-24
  • 打赏
  • 举报
回复
TForm *form = new TForm(Application);
TButton * button1 = new TButton(this); //上边写错了.
button1->Parent = form;
button1->Top = 200;
button1->Left = 100;
button1->Visible = true;
form->ShowModal();
delete button1;
delete form;
lanren_me 2003-02-24
  • 打赏
  • 举报
回复
form = new TForm(Application);
TButton * button1 = new TButton(NULL);
button1->Parent = form;
button1->Top = 200;
button1->Left = 100;
button1->Visible = true;
form->ShowModal();
delete button1;
delete form;
arran 2003-02-24
  • 打赏
  • 举报
回复
extern "C" __declspec(dllexport) void __stdcall runform(TForm * form);
void __stdcall runform(TForm * form)
{
form = new TForm(Application);
form->ShowModal();
TButton * button1 = new TButton(form);
button1->Parent = form;
button1->Top = 200;
button1->Left = 100;
button1->Visible = true;
delete button1;
delete form;
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧