Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / MFC
Tip/Trick

Fixing the CanAdjustLayout Ommision from CDockablePane

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
26 Oct 2017CPOL2 min read 9.4K   2   1
Something to help compile samples from the VS2010 feature pack

Introduction

In the Visual Studio 2010 Feature Pack Samples, there are two projects that will not compile in releases since 2012. These are the OutlookDemo and the VisualStudioDemo. The problem is since the VS2012 release, Microsoft deleted the CanAdjustLayout member of the CDockablePane class. Here is a simple way to work around this omission.

Background

The CanAdjustLayout member function of the CDockablePane has been deleted from recent editions of Visual Studio. In the "Breaking Changes in Visual C++", it was noted in a sentence starting with, "Removed unused methods". This method is used in three places between the two samples. It is called in the OnSize handler of three classes derived from CDockablePane.

Using the Code

It turns out this method was actually just inlined in the header file, afxdockablepane.h. To allow these samples to compile, we will add a simple derivation from CDockablePane which contains only the CandAdjustLayout implementation. Here is what it looks like:

C++
class CDockablePaneEx : public CDockablePane
{
protected:
    virtual BOOL CanAdjustLayout() const { return !m_bIsSliding || !m_bIsHiding; }
};

I added this to stdafx.h but it could go into its own header file if you wanted to do that. To make the sample apps compile, change classes derived from CDockablePane to derive from CDockablePaneEx. For the VisualStudioDemo app, the classes to change are CResourceView and CWatchBar. There are others that are derived from CDockablePane but only those two classes call CanAdjustLayout so they don't need to be changed. In the OutlookDemo app, the class to change is CFolderListBar. It turns out that there are two places to change for each class. The first is in the header file. Here's one example:

C++
class CResourceViewBar : public CDockablePaneEx

The second place is in the implementation file at the location in this example:

C++
BEGIN_MESSAGE_MAP( CResourceViewBar, CDockablePaneEx )

With these changes, those two samples in the Feature Pack will compile and you will have this method available for your own use elsewhere.

Points of Interest

I thought it was kind of odd that Microsoft would delete a method and claim that it is unused yet samples from the previous version of Visual Studio used it. Oh well.

As a first attempt, I commented out the calls to CanAdjustLayout in the respective classes of the VisualStudioDemo and the app seemed to work OK. I didn't notice any strange behavior. I dug this up just to be thorough because I figured it was there because of something someone saw once during testing. I really don't know, but this is a simple addition (and edition) to make.

History

  • Initial posting

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I work on an industrial HPC project that can run on either the CPU or the GPU. I usually use which ever one has the most horsepower on a given machine. It's written with CUDA with very few ifdefs used. My company is quite large, in the top five in our industry in North America, and I work in a small group with just five programmers.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Anton9623-Oct-22 23:51
Anton9623-Oct-22 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.