Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Fixing the CanAdjustLayout Ommision from CDockablePane

0.00/5 (No votes)
26 Oct 2017 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:

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:

class CResourceViewBar : public CDockablePaneEx

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

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here