MFC, C++: Preventing a splitter window from being resized

Posted on 2007-11-23
Last Modified: 2013-12-14

I am working on an MFC splitter frame application. I want to prevent the user from resizing the splitter window.

I've followed this old article on MSDN, which covers this:

I can't even get the demo project to build in visual studio 2005 (I converted the VC 6 project). I get the following errors:

1>c:\documents and settings\user\desktop\msdnsplitter\nosize\mainfrm.cpp(22) : error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CMainFrame::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'
1>        Cast from base to derived requires dynamic_cast or static_cast
1>c:\documents and settings\user\desktop\msdnsplitter\nosize\statlink.cpp(27) : error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CStaticLink::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'
1>        Cast from base to derived requires dynamic_cast or static_cast
1>c:\documents and settings\user\desktop\msdnsplitter\nosize\statlink.cpp(123) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\User\Desktop\msdnsplitter\NoSize\Debug\BuildLog.htm"
1>NoSize - 3 error(s), 0 warning(s)

Could someone help me build the application, so that I can apply the same principle to my own application, or could someone suggest another way that I could prevent splitter resizing?

Question by:sternocera
  • 2
LVL 30

Accepted Solution

Zoppo earned 500 total points
Comment Utility
Hi sternocera,

in mainfrm.h, mainfrm.cpp, statlink.h and statlink.cpp the UINT return value for OnNcHitTest must be changed to LRESULT

In CStaticLink::OnSetCursor change this line
            static bTriedOnce = FALSE;
            static BOOL bTriedOnce = FALSE;

Hope that helps,


Author Comment

Comment Utility

That works, thanks. Whats going on here? Why was this necessary?

LVL 30

Expert Comment

Comment Utility
I'm not sure, it seems there's a difference between the implementation and the MSDN description of ON_WM_NCHITTEST and OnNcHitTest

In MSDN for MFC8.0 they're both described to use a function which returns UINT:

ON_WM_NCHITTEST( )  afx_msg UINT OnNcHitTest( CPoint );

afx_msg UINT OnNcHitTest(
   CPoint point

In code for MFC this differs:

#define ON_WM_NCHITTEST() \
      { WM_NCHITTEST, 0, 0, 0, AfxSig_l_p, \
            (AFX_PMSG)(AFX_PMSGW) \
            (static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(CPoint) > (&ThisClass :: OnNcHitTest)) },

class CWnd
      afx_msg LRESULT OnNcHitTest(CPoint point);

UINT is an 'typedef unsigned int'
LRESULT is 'typedef LONG_PTR' which is a 'typedef _W64 long' (for 32-bit build)

So they differ too ...

I don't know why this is, sorry ...

The missing 'BOOL' even was no problem in VC6



Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now