本文介绍了在C ++中停止C风格转换以满足MFC需求。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨。 我想知道是否有办法在C ++中停止C风格转换以满足MFC需求。例如,这是代码。 #include stdafx.h #include 01.h App myApp; BOOL App :: InitInstance() { m_pMainWnd = new MainWindow; m_pMainWnd-> ShowWindow(m_nCmdShow); m_pMainWnd-> UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(MainWindow,CFrameWnd) // 这不是一个演员表 ON_WM_CREATE() ON_WM_PAINT() END_MESSAGE_MAP() MainWindow :: MainWindow() {创建( NULL,_T( window)); } void MainWindow :: OnCreate() { } void MainWindow :: OnPaint() { } 我在评论的行中有问题。这不是演员。这就是MFC如何开始消息映射。但是编译器尝试将ON_WM_CREATE()转换为(MainWindow,CFrameWnd)。正如我所看到的,停止此转换的唯一方法是在BEGIN_MESSAGE_MAP行的末尾插入分号。但它会导致MFC出现其他问题。 所以我想知道如何防止这样的错误?为什么他们会实现让编译器变得模糊的东西呢? 提前谢谢。解决方案 请参阅 http://msdn.microsoft.com/en-us/library/384x0633.aspx [ ^ ]。 Hi.I want to know if there's any way to stop C style casting in C++ for MFC needs. For example, here is the code.#include "stdafx.h"#include "01.h"App myApp;BOOL App::InitInstance(){m_pMainWnd = new MainWindow;m_pMainWnd->ShowWindow(m_nCmdShow);m_pMainWnd->UpdateWindow();return TRUE;}BEGIN_MESSAGE_MAP(MainWindow, CFrameWnd) //this is not a castingON_WM_CREATE()ON_WM_PAINT()END_MESSAGE_MAP()MainWindow::MainWindow(){Create(NULL, _T("window"));}void MainWindow::OnCreate(){}void MainWindow::OnPaint(){}Im having a problem in the line where I commented. It's not a casting. That's how MFC begins the message map. But the compiler tries to cast the ON_WM_CREATE() into a (MainWindow, CFrameWnd). The only way, as I see, to stop this casting is insert a semicolon at the end of the BEGIN_MESSAGE_MAP line. But it would cause other problems with MFC.So I want to know how can I prevent errors like this ? Why on earth would they implements such things that makes the compiler gone fuzzy ?Thanks in advance. 解决方案 See http://msdn.microsoft.com/en-us/library/384x0633.aspx[^]. 这篇关于在C ++中停止C风格转换以满足MFC需求。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 01:44