奇怪的问题

BSRONG BSRONG 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想动态创建窗体
代码如下
unit1.cpp
#include "Unit1.h"
#include "unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCreateActiveForm *CreateActiveForm=new TCreateActiveForm(Application,1);
CreateActiveForm->ShowModal();
delete CreateActiveForm;
}
//-----------------------------------------------

unit1.h
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//------------------------------------------------------------------------
#endif


unit2.cpp



//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)


__fastcall TCreateActiveForm::TCreateActiveForm(TComponent *Owner,int count):TForm(Owner,0)
{ Height=100;
Width=200;
Position=poScreenCenter;
Caption="动态创建窗体";
PopupMenu1=new TPopupMenu(this);
Exit1->Caption="退出";
Exit1->OnClick=OnExit1Click;
PopupMenu1->Items->Add(Exit1);
PopupMenu=PopupMenu1;
okBtn=new TButton(this);
okBtn->Parent=this;
okBtn->Top=32;
okBtn->Left=(Width-okBtn->Width)/2;
okBtn->Caption="退出";
okBtn->OnClick=okButtonClick;
}
void __fastcall TCreateActiveForm::OnExit1Click(TObject *Sender)
{ Close();
}
void __fastcall TCreateActiveForm::okButtonClick(TObject *Sender)
{
Close();
}

unit2.h

//---------------------------------------------------------------------------

#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#endif
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>

class TCreateActiveForm: public TForm
{
private:
TButton *okBtn;
TPopupMenu *PopupMenu1;
TMenuItem *Exit1;
void __fastcall OnExit1Click(TObject *Sender);
void __fastcall okButtonClick(TObject *Sender);
public:
virtual __fastcall TCreateActiveForm(TComponent *Owner,int Count);
};

按F9运行如下
按下确定后
就不正常了,为什么?
高手指点
project1.cpp如下
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
USERES("Project1.res");
USEFORM("Unit1.cpp", Form1);
USEUNIT("Unit2.cpp");
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//---------------------------------------------------------------------------


...全文

相关推荐

PNG绘制的奇怪问题

只要在OnPaint中换用AlphaBlend问题即可解决。 问题已经解决 请管理员删除此资源 。

glunoy

牛客 – 奇怪的背包问题增加了(贪心)

题目链接:点击查看 题目大意:中文题意 题目分析: 代码: #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ull; const int inf=0x3f3f3f3f; const int N=1e5+100; struct Node { int val,id;

weixin_38691199

php json_encode奇怪问题说明

php json_encode奇怪问题说明,使用json_encode的朋友可以参考下。

weixin_38647822

一个奇怪的问题使用ajax提交必须alert才能赋值

一个奇怪的问题,在使用ajax提交的时候将返回值赋给一个变量,无论怎么写都没法赋值,刚开始怀疑js有错但是ie没有反应过来,多次清缓存、部程序都没效果。。。。。。最后只好一行一行的alert看原因出在哪里;奇怪的是加上了alert之后就可以赋值,删掉alert后就又不可以了。百度了一下发现是因为ajax默认是异步执行的,也就是并没有等待请求完毕就开始执行下一行js语句了,导致赋值为null。 如果遇到ajax请求后有回调函数之类的问题就要加上async:false,注意如果是给false加上引号是没发解决问题的。 代码如下: $.ajax({ async:false })

weixin_38656226

WEB上调用HttpWebRequest奇怪问题的解决方法

WEB上调用HttpWebRequest奇怪问题的解决方法

weixin_38658568
评论 1
收藏 已收藏
分享
返回顶部
BSRONG
C++ Builder 13,871 成员 102,696 内容