Click here to Skip to main content
13,249,174 members (34,352 online)
Click here to Skip to main content
Add your own
alternative version

Stats

2.1K views
1 bookmarked
Posted 26 Oct 2017

Fixing the CanAdjustLayout Ommision from CDockablePane

, 26 Oct 2017
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rick York
Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 27 Oct 2017
Article Copyright 2017 by Rick York
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid