Solved

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

Posted on 2007-11-23
3
1,253 Views
Last Modified: 2013-12-14
Hello,

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:

http://msdn.microsoft.com/msdnmag/issues/01/02/c/

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>NoSize.cpp
1>StatLink.cpp
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>View.cpp
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?
Regards,
Sternocera

0
Comment
Question by:sternocera
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 20339534
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;
to
            static BOOL bTriedOnce = FALSE;

Hope that helps,

ZOPPO
0
 

Author Comment

by:sternocera
ID: 20339567
Zoppo,

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

Regards,
Sternocera
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 20339758
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:

MSDN:
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

Regards,

ZOPPO
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix Command -- Challenging  question 7 87
WPF issue with Trigger 2 96
Eclipse IDE - Cannot copy/paste from console output 8 132
Online file editor, manager 6 62
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

861 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

25 Experts available now in Live!

Get 1:1 Help Now