从VC6到VS2005移植代码:warning C4996

来源:互联网 发布:java正则表达式单引号 编辑:程序博客网 时间:2024/04/30 19:12

从VC6到VS2005移植代码问题说明

这个是编译使用了老的向导生成的MFC代码时遇到的问题,一个典型的告警信息输出如下所示:

  CrpFileCrack.cpp

  f:/project/...../crpfilecrack.cpp(52) : warning C4996: 'CWinApp::Enable3dControls': CWinApp::Enable3dControls is no longer needed. You should remove this call.

  e:/software/microsoft visual studio 9.0/vc/atlmfc/include/afxwin.h(4818) : see declaration of 'CWinApp::Enable3dControls'

  通常向导生成的代码是:

  #ifdef _AFXDLL

  Enable3dControls(); // Call this when using MFC in a shared DLL

  #else

  Enable3dControlsStatic(); // Call this when linking to MFC statically

  #endif

这两个函数的调用是旧的MFC版本对新版本的操作系统特性的支持,在新的(那个时候是新的)Windows 95平台上要这样调用一下才能使用新的Windows 3D样式的控件,否则就是老的Win 3.2样子的控件。想当初喜欢OWL就是因为感觉它的控件比较“酷”,比如那个带底纹的对话框,菱形的checkbox,还有带图标的“OK”按钮,看到MFC作出来的灰灰的界面就觉得土,不过后来就知道MFC做界面也是很漂亮的,比如我做的。。。。,再打住。对于新的MFC版本来说已经不需要再调用这两个函数了,参考前面的方法,用_MSC_VER对其隔离就行了:

  #if _MSC_VER <= 1200 // MFC 6.0 or earlier

  #ifdef _AFXDLL

  Enable3dControls(); // Call this when using MFC in a shared DLL

  #else

  Enable3dControlsStatic(); // Call this when linking to MFC statically

  #endif

  #endif

原创粉丝点击