TObject 如何转变成 TTabControl.有例子
TObject 怎么转变成 TTabControl.有例子!5.H代码C/C++ code//---------------------------------------#if
TObject 怎么转变成 TTabControl.有例子!
5.H代码
C/C++ code//---------------------------------------#ifndef Unit5H#define Unit5H//---------------------------------------extern void sss(TObject *Sender);#endif
5.CPP文件代码
C/C++ code//---------------------------------------#pragma hdrstop#include "Unit5.h"//---------------------------------------#pragma package(smart_init)void sss(TObject *Sender){ TButton *newbtn=new TButton(TTabControl *Sender); //注意以下2行代码 newbtn->Parent = TTabControl *Sender; //这行! TTabControl *Sender}
看到以上代码了吧! TTabControl *Sender
我以Obj 作为参数,然后我希望转换成TTAB.但是无果!
(DELphi 跟以上一样的写法是可以做到的!请问C++能不能.我知道可以void sss(TTabControl *Sender)这样写!但是我希望学到多种方法!)
错误信息
Checking project dependencies...
Compiling Project1.cbproj (Debug configuration)
[BCC32 Error] Unit5.cpp(34): E2108 Improper use of typedef 'TTabControl'
Full parser context
Unit5.cpp(31): parsing: void sss(TObject *)
[BCC32 Error] Unit5.cpp(35): E2108 Improper use of typedef 'TTabControl'
Full parser context
Unit5.cpp(31): parsing: void sss(TObject *)
Failed
Elapsed time: 00:00:00.8
[解决办法]void sss(TObject *Sender)
{
TTabControl *tc = dynamic_cast <TTabControl *>(Sender);
TButton *newbtn = new TButton(tc);
newbtn->Parent = tc;
}