读书人

新手问有关问题

发布时间: 2012-02-22 19:36:54 作者: rapoo

新手问问题。
各位大侠,我是菜鸟,想问一下: 我想在点击button的时候弹出来新的一个form,也就是新弹出来一个窗口,我要怎么做,button里面的代码要怎么写?

[解决办法]
添加一个新 form,myform
button 事件里
myform *f = new myform();
f->Show();
[解决办法]

C/C++ code
TfrmQuery * frmQy = new TfrmQuery(this);frmQy->ShowModal();delete frmQy ;
[解决办法]
//---------------------------------------

#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

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

#ifndef Unit2H
#define Unit2H
//---------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------
class TForm2 : public TForm
{
__published:// IDE-managed Components
private:// User declarations
public:// User declarations
__fastcall TForm2(TComponent* Owner);
};
//---------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------
#endif

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

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------


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

#include <vcl.h>
#pragma hdrstop

#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)
{
Form2 = new TForm2(NULL);
Form2->Visible = true;
}
//---------------------------------------

[解决办法]
这些问题最好的办法就是找本bcb的书看看,否则,这个问题解决了,还有一万个问题,你总不能个个都上来问吧。。

读书人网 >C++ Builder

热点推荐