学习C++/CLI发现的一些问题,算不算Bug?

作者在学习C++/CLI过程中遇到多个问题,包括托管DirectX错误、封装IE控件事件不触发及CollapsibleSplitterControlfor.Net设计界面问题。这些问题可能是语言本身存在的Bug,期待后续版本改进。

这两天学习了一下C++/CLI,将C#几个控件和例子翻写C++下,感觉确实还是属于Beta的语言,Bug是在不少,而且很多你就根本没有办法去调试。
列举如下,当然也有可能使我栽赃,水平不行,导致出现的错误。
1、首先是托管DirectX。
代码如下:

None.gif         Texture ^  CreateTextureFromFileEx(Device ^  device, String ^  filename,  int  w,  int  h,  int  mip, Usage usage, Format fmt, Pool pool, Filter filter, Filter mipfilter,  int  colorkey)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
// Search the cache first
InBlock.gif
            for each(CachedTexture^ ct in safe_cast<array<CachedTexture^>^>(textureCache->Keys))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if ( (String::Compare(ct->Source, filename, true== 0&&
InBlock.gif                    ct
->Width == w &&
InBlock.gif                    ct
->Height == h &&
InBlock.gif                    ct
->MipLevels == mip &&
InBlock.gif                    ct
->Usage == usage &&
InBlock.gif                    ct
->Format == fmt &&
InBlock.gif                    ct
->Pool == pool &&
InBlock.gif                    ct
->Type == ResourceType::Textures)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
// A match was found, return that
InBlock.gif                    
// 错误代码                    return (safe_cast<Texture^>(textureCache[ct]));
ExpandedSubBlockEnd.gif
                }

ExpandedSubBlockEnd.gif            }

出现错误error C2535: 'Microsoft::DirectX::Direct3D::Texture::~Texture(void)' : member function already defined or declared c:\xhluo\程序开发
\My codes\CustomUIMC++\CustomUI\DXMUTMisc.h 644。到网上一找,有这个错误的还不少,给的建议,暂时放弃,等待成熟。 emsad.gif
二、RssBandit下的一个封装IE的Control,也翻写了一下,发现也有问题。
None.gif HtmlControl::HtmlControl() : AxHost( " 8856f961-340a-11d0-a96b-00c04fd705a2 " )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
this->cbFlags = ControlBehaviorFlags::scrollBarsEnabled |
InBlock.gif        ControlBehaviorFlags::imagesDownloadEnabled 
|
InBlock.gif        ControlBehaviorFlags::scriptEnabled 
|
InBlock.gif        ControlBehaviorFlags::javaEnabled 
|
InBlock.gif        ControlBehaviorFlags::flatScrollBars 
|
InBlock.gif        ControlBehaviorFlags::imagesDownloadEnabled 
|
InBlock.gif        ControlBehaviorFlags::behaviorsExecuteEnabled 
|
InBlock.gif        ControlBehaviorFlags::frameDownloadEnabled 
|
InBlock.gif        ControlBehaviorFlags::clientPullEnabled;
InBlock.gif
InBlock.gif    HandleCreated 
+= gcnew EventHandler(this&HtmlControl::SelfHandleCreated);
InBlock.gif    HandleDestroyed 
+= gcnew EventHandler(this&HtmlControl::SelfHandleDestroyed);
InBlock.gif    NavigateComplete 
+= gcnew BrowserNavigateComplete2EventHandler(this&HtmlControl::SelfNavigateComplete);
ExpandedBlockEnd.gif}

代码看着和C#的差不多,运行也没问题,可是就是不停的发生ProgressChange事件,却始终没有NavigateComplete2事件。
后来跟踪才发现,SHDocVw::IWebBrowser2^ ocx这个对象看是初始化正常,但是里面的Application和Container对象均为<undefine value>,
而C#里面这两个对象都初始化了,而且显然还是两个大对象。
这个错误,从语法上代码与C#的差别很小,但是结果去不正确,感觉也和托管DirectX一样,是一些实在的Bug。
三、NJF的Collapsible Splitter Control for .Net,翻写道C++/CLI后,也有问题。
None.gif              this -> splitterListView -> AnimationDelay  =   20 ;
None.gif            
this -> splitterListView -> AnimationStep  =   20 ;
None.gif            
this -> splitterListView -> BorderStyle3D  =  System::Windows::Forms::Border3DStyle::Flat;
None.gif            
this -> splitterListView -> ControlToHide  =  nullptr;
None.gif            
this -> splitterListView -> Dock  =  System::Windows::Forms::DockStyle::Top;
None.gif            
this -> splitterListView -> ExpandParentForm  =   false ;
None.gif            
this -> splitterListView -> Location  =  System::Drawing::Point( 0 200 );
None.gif            
this -> splitterListView -> Name  =   " SplitterListView " ;
None.gif            
this -> splitterListView -> TabIndex  =   4 ;
None.gif            
this -> splitterListView -> TabStop  =   false ;
None.gif            
this -> splitterListView -> UseAnimations  =   true ;
None.gif            
this -> splitterListView -> VisualStyle  =  Luo::CollapsibleSplitter::VisualStyles::XP;
None.gif


默认情况下,this->splitterListView->ControlToHide = nullptr,但是在设计界面却提示不知道nullptr是啥。
而且在C#下能用的SandBar和SandDock在设计界面都不能显示,提示有问题,编译后运行可以。
看来想提前用用C++/CLI是不现实的了,起码在Beta1,它还不是一个完整可用的语言,
但是它的介绍确实很诱人,既可以用一些现代语言的先进特性,接口、事件、属性等,而且还能结合native C++的性能。
期待Beta2以及后续的。
希望大家多发表评论!!!!!
郁闷,系统分析师考试没过,51/35/35,连个省线也不够,唉。emcry.gifemcrook.gif    还努力emdgust.gifemsmileo.gif

 

posted on 2005-01-10 12:41  loli 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/xhluo/archive/2005/01/10/89375.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值