Mfc onvscroll未在MDI主框架类中调用 [英] Mfc onvscroll not getting called in MDI main frame class

查看:224
本文介绍了Mfc onvscroll未在MDI主框架类中调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用visual studio 2013社区进行基于c ++ MFC MDI的项目。 Mainframe类派生为类CMainFrame:public CMDIFrameWndEx



在预创建的主机类中,滚动条设置如下。

 cs.style | = WS_VSCROLL | WS_HSCROLL; 

添加了OnVScroll回调函数,以便在移动主框架滚动条时接收回调。 ON_WM_VSCROLL()已添加到大型机的消息映射中。我们发现OnVScroll永远不会被调用。每当用户移动滚动条时,我们如何在OnVScroll上启用回调。任何帮助将非常感激。谢谢&此致,Rakesh



我的尝试:



我不喜欢我不知道该怎么做。我想在大型机类的任何地方调用SetScrollSizes。

解决方案

那是因为 CFrameWnd 基于类路由那些消息到活动视图和 CMDIFrameWnd 捕获 WS_VSCROLL WS_HSCROLL 和样式:

CFrameWnd类提供对活动视图的管理。以下消息通过活动视图路由:

  • 所有命令消息(活动视图首先访问它们)。

  • 来自WM_HSCROLL和WM_VSCROLL的消息兄弟滚动条(见下文)。

  • WM_ACTIVATE(和MDI的WM_MDIACTIVATE)变成了对虚函数CView :: OnActivateView的调用。


...

在旁注中,有两个CWnd派生类,其中创建时指定的滚动条样式被捕获而不传递给Windows。

...

对于CMDIFrameWnd,传入Create或LoadFrame的滚动条样式用于创建MDICLIENT。



因此,您无法使用基于 CFrameWnd 的类的滚动条。只有实现您自己的( CWnd )类才能提供所有必需的MDI功能。由于MFC文档和视图类之间的关系,您可能需要创建一个完整的新文档并查看实现。



还请注意框架窗口用于托管和组织视图,通常不需要滚动条。


I have a c++ MFC MDI based project using visual studio 2013 community. Mainframe class is derived as class CMainFrame : public CMDIFrameWndEx

In mainframe class in pre-create, the scroll bar is set as below.

cs.style |= WS_VSCROLL | WS_HSCROLL;

An OnVScroll call back function has been added to receive a call back whenever the main frame scroll bar is moved. ON_WM_VSCROLL() has been added to the message map in the mainframe. We find that OnVScroll never gets called. How do we enable callbacks on OnVScroll whenever the user moves the scrollbar. Any help will be very appreciated. Thanks & Regards, Rakesh

What I have tried:

I don't know what to do. I wanted to to call SetScrollSizes any where in the mainframe class.

解决方案

That is because CFrameWnd based classes route those message to the active view and CMDIFrameWnd traps the WS_VSCROLL and WS_HSCROLL and styles:

The CFrameWnd class provides management of the active view. The following messages are routed through the active view:

  • All command messages (the active view gets first access to them).
  • WM_HSCROLL and WM_VSCROLL messages from sibling scroll bars (see below).
  • WM_ACTIVATE (and WM_MDIACTIVATE for MDI) get turned into calls to the virtual function CView::OnActivateView.

...
On a side note, there are two CWnd derived classes where the scroll bar styles specified at create time are trapped and not passed to Windows.
...
For CMDIFrameWnd the scroll bar styles you pass in to Create or LoadFrame are used to create the MDICLIENT.


So you can't use scrollbars with CFrameWnd based classes. It would be only possible by implementing your own (CWnd based) classes that must provide all the necessary MDI functionality. Due to the relationship between the MFC document and view classes you might have to create a complete new document and view implementation.

Note also that frame windows are for hosting and organising the views and usually do not require scrollbars.


这篇关于Mfc onvscroll未在MDI主框架类中调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆