gpt4 book ai didi

c++ - C++ sdi 应用程序中的 Static_cast 编译器错误

转载 作者:太空狗 更新时间:2023-10-29 21:29:44 25 4
gpt4 key购买 nike

我有一个小型 SDI 应用程序,我试图在其中添加对菜单使用情况的跟踪,即。用户选择某些菜单项的次数。

一些菜单项由 View 组件 (DemoView.cpp) 处理,其他菜单项由主应用程序 (DemoApp.cpp) 处理。 Since the tracking structure is defined in the main app, I believe that I have to notify the View's parent with a special message when a menu item (handled by the View) is selected.

如果这是正确的,我的问题是我无法创建正确的 ON_MESSAGE 命令。它看起来像这样:

 ON_MESSAGE(WM_INCREASE_FREQ, &CDemoApp::OnIncreaseFreq)

OnIncreaseFreq() 的定义如下:

LRESULT CDemoApp::OnIncreaseFreq(WPARAM, LPARAM)

但是我得到这个错误:

error C2440: 'static_cast' : cannot convert from 
'LRESULT (__thiscall CDemoApp::* )(WPARAM,LPARAM)' to
'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

如果有任何帮助,我将不胜感激

最佳答案

根据错误,回调函数必须是派生自CWnd的类的成员函数。使 CDemoApp 从 CWnd 派生,您的代码应该可以编译和工作。

关于c++ - C++ sdi 应用程序中的 Static_cast 编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4193363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com