0
votes

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

1

1 Answers

1
votes

Please be aware that a scrollbar for CMDIFrameWndEx makes no sense.

The CMDIFrameWndEx has a child window of type CMDIClientAreaWnd,this window covers the complete client area that is left after toolbars and ribbon are created.

So when you create the main frame with the styles WS_VSCROLL | WS_HSCROLL this styles are removed from the main frame window and transferred to the inner class (the MDI client window).

So the outer frame window will never receive the scroll messages.

You have the MFC source code, just look into the source code of the function CMDIFrameWnd::CreateClient! You find the behavior there.

After this is done the CMDIClientAreaWnd gets control via a subclass of the handle m_hWndMDIClient to the class CMDIClientAreaWnd.

This class is responsible for the MDI-Tab View style.

So if you want the scrollbar messages you may use classic subclassing to the inner MDI Client window.

Spy++ may help you to understand the window structure.