VC6工程转到.net下面时出现的问题,不知道怎么解决好

zsb_xt 2005-03-23 09:14:56
在工程里使用了SetDialogBkColor这个函数,而.net下出现警告并且没有成功调用这个函数,具体如下:
BOOL CTimeBoxApp::InitInstance()
{
AfxEnableControlContainer();

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

SetDialogBkColor( RGB( 231, 231, 231 ) );
//显示对话框
//..........
//
}
这个部分.net提示警告:
warning C4996: “CWinApp::Enable3dControls”被声明为否决的
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4369) : 参见“CWinApp::Enable3dControls”的声明
warning C4996: “CWinApp::SetDialogBkColor”被声明为否决的
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4360) : 参见“CWinApp::SetDialogBkColor”的声明

如果要修改程序重载OnCtlColor,则有很多代码要修改,有没有方法可以直接让SetDialogBkColor有效
...全文
193 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2005-03-26
  • 打赏
  • 举报
回复
嗯,SetDialogBkColor好像不支持了
stkim 2005-03-23
  • 打赏
  • 举报
回复
BOOL CExampleDlgApp::InitInstance()
{//
CExampleDlgDlg dlg;
m_pMainWnd = &dlg;
//先于DoModal()调用,将对话框设置为蓝色背景、红色文本
SetDialogBkColor(RGB(0,0,255),RGB(255,0,0));
int nResponse = dlg.DoModal();

}
不过这样只能改变程序中所有的对话框颜色,而且必须先于DoModal调用。
我觉得:
#ifdef _AFXDLL
Enable3dControls();// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic();// Call this when linking to MFC statically
#endif
这两句去掉比较好。

PS:
据MSDN里说CWinApp::Enable3dControls和CWinApp::SetDialogBkColor都是已经被废弃的函数了,MFC5.0以后就不再单独支持它们(已经被整合进系统),所以被声明为否决的,因此还是重载OnCtlColor (CDC* pDC, CWnd* pWnd, UINT nCtlColor),即WM_CTLCOLOR消息,然后用刷子画一下比较好,虽然比较麻烦。

7,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧