EVC到vs2005工程移植

大家知道MOBIL5.0开始,EVC4开发的工程就无法进行DEBUG了,而必须使用VS.NET2005中的VC++来实现。但是以前我们费了很大心力做成的项目,也不能重新来写。
今天通过一上午的研究,将转化方法贴出来和大家共勉。
       这里我们以DIALOG BASED工程为例。首先用EVC4建立一个DIALOG BASED的POCKET PC 2003工程。此工程名我们暂定为TXDEMO。我们也可以在对话框放置一个BUTTON,在单击事件里,添加AfxMessageBox(L”Test”); 以便升级到VS.NET 2005后,测试资源对应情况。
       此时,保存TXDEMO工程,并关闭掉EVC4开发工具。此时用VS.NET 2005打开TXDEMO.VCW工程,并接受转换请求。此时并将编译环境切换到Windows Mobile 5.0 pocket pc sdk。编译工程,此时会提示如下错误:
 
1>C:Program FilesMicrosoft Visual Studio 8VCceatlmfcincludeafxver_.h(77) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
 
这里我们通过打开Project properties对话框里,切换到C/C++->Code generation页,将Runtime Libarary 设置成“Multi-threaded DLL(/MD)”。即可解决此问题。
 
接着编译工程,此时会提示如下错误:
1>.TXDEMO.rc(170) : fatal error RC1015: cannot open include file 'wceres.rc'.
 
这里我们需要在TXDEMO.RC文件里,将#include "wceres.rc"注释掉。
//#include "wceres.rc"     // WCE-specific components
 
接着编译工程,此时会提示如下错误:
1>corelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
1>Windows Mobile 5.0 Pocket PC SDK (ARMV4I)Debug/TXDEMO.exe : fatal error LNK1120: 1 unresolved externals
此时,我们依旧打开project properties对话框,切换到Linker->Advanced页,将Entry Point由wWinMainCRTStartup改成WinMainCRTStartup。
 
此时再次编译,系统不在提示错误,但是编译好的程序,还不能在模拟器或者MOBILE5.0 POCKET PC的机器上运行。
 
我们接着设置项目属性,在Configuration Properties->Gengeral页将Use of MFC ,改成静态连接。
 
此时我们运行程序 ,您会发现程序启动后,就立刻退去。经过我的研究,发现是加载对话框资源失败,在此我们再此打开TXDEMO.RC源文件,
找到 IDD_TXDEMO_DIALOG DIALOG DISCARDABLE 0, 0, 130, 90 语句,将下面的窗体属性改成如下,即可。
WS_POPUP | WS_VISIBLE | WS_CAPTION
此时,再次编译工程,你可以进行DEBUG并可以运行程序。
这是我对EVC4升级到VS.NET 2005一点总结,其中参考了MSDN中一些文档,但是MSDN说的还不够详细,通过我自己的研究,总结出一点经验,希望能给大家带来方便,谢谢。
另外。。。。。。。。

也谈EVC工程移植

        本文是针对作者本人的一个具体的移植项目,将碰到的所有问题列出来,并给出具体的解决方法。由于是一个具体的项目,因此不能把所有的EVC工程移植问题囊括进来。所以,在移植项目前,建议还是看看以下的文章:
循序渐进:将 eMbedded Visual C++ 应用程序迁移到 Visual Studio 2005
eMbedded Visual C++ 到 Visual Studio 2005 升级向导(注意其最后一句话:默认情况下,Embedded Visual C++ 4.0 版会将 MFC Pocket PC 应用程序的对话框样式(Border)设置为 DS_MODALFRAME。MFC 8.0 不支持此样式。 —— 应改为Thin,如果不改的话,窗口就无法弹出。)
从 eVC 移植所带来的已知问题
Migrating Microsoft eMbedded Visual C++ Projects to Visual Studio 2005
        开发环境:Windows XP +SP2, Visual Studio 2005 professional, Windows Mobile 6.0 Professional SDK。
注:(1)对于Windows Mobile 5.0 SDK 开发的程序在Windows Mobile 6.0 下也能运行,而且不需要对程序进行任何的修改。
      (2)由于有些错误,是环境配置问题,所以在Debug/Resease模式下,都需要进行修改,以下错误中,如果是这类错误,都在标号后面写着“Resealse 模式也需要改”,当天切换到别的SDK下,如Windows Mobile 5.0 SDK,也需要修改。
      以下是针对Debug模式下的:
1、StdAfx.cpp (Resealse 模式也需要改)
编译错误:D:Program FilesMicrosoft Visual Studio 8VCceatlmfcincludeafxver_.h(77) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
解决方法:右击工程名,打开Project properties对话框,切换到C/C++->Code generation页,将Runtime Libarary 设置成“Multi-threaded DLL(/MD)”,即可解决此问题。
2、编译错误:error C2065: 'i' : undeclared identifier
原因:是由于存在以下的代码段:
for (int i = 0; i < MAX_LEN; i ++)
{
   //……
}
for (i = 0; i < MAX_NUM; i ++)
{
    //……
}
对于evc离开循环后,循环变量仍然有效,并且仍可以使用,但是在VS2005下是不行的,由此可见VS2005对变量的定义与审查更为严格,还有就是对数组越界问题也比EVC来的强。
解决方法:(不能完全相信编译器,也不能把所有的语法检查都丢给编译器)
int i = 0;
for (i = 0; i < MAX_LEN; i ++)
{
    //……
}
for (i = 0; i < MAX_NUM; i ++)
{
     //……
}
3、error C2664: '_wcsnicmp' : cannot convert parameter 2 from 'LPWORD' to 'const wchar_t *'
 需要强制类型转换
4、error C2061: syntax error : identifier 'HELPINFO'
自己增加HELPINFO的类型,增加头文件HelpInfo.h
5、error C2146: syntax error : missing ';' before identifier 'm_wndCommandBar'
原因:在Windows Mobile 5.0/6.0 下CCeCommandBar类被CCommandBar替换
解决方法:
CCeCommandBar   m_wndCommandBar; ---- 〉CCommandBar   m_wndCommandBar;
6、error C2065: 'NUM_TOOL_TIPS' : undeclared identifier
解决:
//#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 212)
#define NUM_TOOL_TIPS 8
//#endif
7、error C3861: 'ON_WM_HELPINFO': identifier not found
同 4
8、error C2440: 'static_cast' : cannot convert from 'void (__cdecl CMyAppView::* )(void)' to 'LRESULT (__cdecl CWnd::* )(WPARAM,LPARAM)'None of the functions with this name in scope match the target type
解决方法:
afx_msg void OnHotLinkExplain();  --- 〉
afx_msg LRESULT OnHotLinkExplain(WPARAM wParam,LPARAM lParam);
9、error C2664: 'CSize CDC::GetTextExtent(LPCTSTR,int) const' : cannot convert parameter 1 from 'WORD *' to 'LPCTSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast需要强制转换
pDC->GetTextExtent(&i, 1).cx);   ——>
pDC->GetTextExtent((LPCTSTR)&i, 1).cx;
10、error C2039: 'OnHelpInfo' : is not a member of 'CView'
error C2039: 'OnHelpInfo' : is not a member of 'CFrameWnd'
error C2039: 'OnHelpInfo' : is not a member of 'CDialog'
解决方法:用TRUE替换相应的类成员函数OnHelpInfo'
return CView::OnHelpInfo(pHelpInfo); ——> return TRUE;
11、error C2039: 'm_bShowSharedNewButton' : is not a member of 'CCommandBar'
D:Program FilesMicrosoft Visual Studio 8VCceatlmfcincludeafxext.h(557) : see declaration of 'CCommandBar'
解决方法
直接注释掉 m_wndCommandBar.m_bShowSharedNewButton = FALSE;
12、.MyApp.rc(380) : fatal error RC1015: cannot open include file 'wceres.rc'.
解决方法
直接注释掉:#include "wceres.rc"         // WCE-specific components
但是,这个错误很讨厌,每次你修改资源文件后,都得修改该语句,不知道为什么。
13、Resease 模式下也要修改
error LNK2019: unresolved external symbol SHInitExtraControls referenced in function "protected: __cdecl CMyAppView::CMyAppView(void)" (  0CMyAppView@@IAA@XZ)
问题:程序中调用了SHInitExtraControls();
error LNK2019: unresolved external symbol SHSipPreference referenced in function "protected: void __cdecl CMyAppView::OnKillfocusWord(void)" ( OnKillfocusWord@CMyAppView@@IAAXXZ)
问题:程序中调用了SHSipPreference
以上两个函数都在:Library: aygshell.lib里
解决方法:
工程-->属性-->Linker -->input -- > Additional Denpendencies :aygshell.lib
14、Resease 模式下也要修改
orelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
属性—〉Linker—〉Anvanced—〉EntryPoint
将 wWinMainCRTStartup 更改为 WinMainCRTStartup
Entry Point是WinMainCRTStartup(ANSI)或wWinMainCRTStartup(UINCODE),即: ... WinMainCRTStartup 或wWinMainCRTStartup 会调用WinMain 或wWinMain。
15、  error C3861: 'LoadStdProfileSettings': identifier not found
注释掉函数 LoadStdProfileSettings
该函数的具体功能,看MSDN。 
       BTW:编译的时候,有可能会出现一些由以上错误产生的连锁错误,俗称“蝴蝶效应”,如error C2143: syntax error : missing ';' before '}'
error C2143: syntax error : missing ';' before ','
error C2143: syntax error : missing ';' before '{'
少了了'{'、'}'、';'等等,把以上的错误—主要矛盾解决了,这些错误—错误矛盾也就迎刃而解了。何况,这个工程是以前在EVC IDE下编译通过,MS再怎么优化或改进编译器,也总不可能发生自相矛盾的事情吧,总要考虑兼容性吧,要对自己或公司的前辈有信心!
      到此,已经能够编译通过,但是运行的时候,又出现如下的问题:
16、Resease 模式下也要修改
按F5,出现如下的对话框:

解决方法:
 右击工程的属性—〉General—〉Project Defaults –〉Use MFC :
Use MFC in a shared DLL ——> Use MFC in a static DLL
也正是因为这个,VS2005产生的EXE程序比EVC产生的要大200多k。

      这样,程序基本移植完成,但是还要把所有的功能过一遍,有可能还会碰到,诸如对话框出现乱码、菜单不对等问题。
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值