Click here to Skip to main content
15,884,823 members
Articles / Desktop Programming / MFC

CUsefulSplitterWnd (An Extension to CSplitterWnd)

Rate me:
Please Sign up or sign in to vote.
4.82/5 (26 votes)
24 Jan 2000CPOL 384.6K   8.1K   57   91
An extension to MFCs CSplitterWnd that provides splitter locking and dynamic view replacement

The CUsefulSplitterWnd class presents two extensions to CSplitterWnd.

  1. The first extension is the ability to lock the bar in position so that it can no longer be moved.
     // bar is locked using LockBar(TRUE) 
    m_wndSplitter.LockBar(TRUE);  
    
    // and is unlocked using LockBar(FALSE) 
    m_wndSplitter.LockBar(FALSE);
  2. The second extension allows the views in each pane to be changed dynamically using the ReplaceView() method.
     // to replace a view in a pane you use ReplaceView 
    m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASS(CForm1),CSize(100,100));

    This would replace the view in row 0, column 1 with CForm1 and with a minimum size of 100x100.

License

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


Written By
Employed (other) Purplebricks
Australia Australia
All articles are supplied as-is, as a howto on a particular task that worked for me in the past. None of the articles are supposed to be out-of-the-box freeware controls and nor should they be treated as such. Caveat emptor.

Now living and working in Australia, trying to be involved in the local .NET and Agile communities when I can.

I spend a good chunk of my spare time building OpenCover and maintaining PartCover both of which are Code Coverage utilities for .NET.

Comments and Discussions

 
GeneralOnInitialUpdate Pin
hellogany25-Apr-10 20:49
hellogany25-Apr-10 20:49 
GeneralRe: OnInitialUpdate Pin
Shaun Wilde27-Apr-10 1:34
Shaun Wilde27-Apr-10 1:34 
GeneralUse of ReplaceView from Inside of worker thread generate crasing. Pin
Le@rner13-Oct-09 19:03
Le@rner13-Oct-09 19:03 
GeneralRe: Use of ReplaceView from Inside of worker thread generate crasing. Pin
Shaun Wilde14-Oct-09 8:18
Shaun Wilde14-Oct-09 8:18 
GeneralRe: Use of ReplaceView from Inside of worker thread generate crasing. Pin
Le@rner14-Oct-09 18:10
Le@rner14-Oct-09 18:10 
GeneralRe: Use of ReplaceView from Inside of worker thread generate crasing. Pin
Shaun Wilde15-Oct-09 8:28
Shaun Wilde15-Oct-09 8:28 
GeneralOnInitialUpdate Function not working after replacing view. Pin
Le@rner3-Apr-08 19:12
Le@rner3-Apr-08 19:12 
GeneralRe: OnInitialUpdate Function not working after replacing view. Pin
sheeba.ph16-Jun-08 19:59
sheeba.ph16-Jun-08 19:59 
GeneralRe: OnInitialUpdate Function not working after replacing view. Pin
Shaun Wilde17-Jun-08 8:50
Shaun Wilde17-Jun-08 8:50 
AnswerRe: OnInitialUpdate Function not working after replacing view. Pin
Aletheuein10-Aug-08 4:04
Aletheuein10-Aug-08 4:04 
AnswerRe: OnInitialUpdate Function not working after replacing view. Pin
wct7-Jan-09 19:22
wct7-Jan-09 19:22 
GeneralRe: OnInitialUpdate Function not working after replacing view. Pin
Shaun Wilde7-Jan-09 20:34
Shaun Wilde7-Jan-09 20:34 
GeneralRe: OnInitialUpdate Function not working after replacing view. Pin
wct10-Jan-09 4:13
wct10-Jan-09 4:13 
GeneralRe: OnInitialUpdate Function not working after replacing view. Pin
Víctor Rodriguez-Doncel17-Jul-09 4:07
Víctor Rodriguez-Doncel17-Jul-09 4:07 
GeneralSplit it into more parts [modified] Pin
neha.agarwal2716-Nov-06 20:15
neha.agarwal2716-Nov-06 20:15 
GeneralRe: Split it into more parts Pin
Shaun Wilde17-Nov-06 8:56
Shaun Wilde17-Nov-06 8:56 
GeneralCFormView from a DLL Pin
Ajay L D5-Nov-06 18:26
Ajay L D5-Nov-06 18:26 
GeneralRe: CFormView from a DLL Pin
Shaun Wilde17-Nov-06 8:53
Shaun Wilde17-Nov-06 8:53 
GeneralCSplitterWnd in SDI Pin
Bhushan19806-Jul-06 20:36
Bhushan19806-Jul-06 20:36 
GeneralRe: CSplitterWnd in SDI Pin
Shaun Wilde6-Jul-06 21:03
Shaun Wilde6-Jul-06 21:03 
QuestionHow to create a PaneView, the Form is in a DLL. Pin
HFHero.William28-May-06 20:10
HFHero.William28-May-06 20:10 
AnswerRe: How to create a PaneView, the Form is in a DLL. Pin
Shaun Wilde29-May-06 0:35
Shaun Wilde29-May-06 0:35 
GeneralRe: How to create a PaneView, the Form is in a DLL. [modified] Pin
HFHero.William29-May-06 5:55
HFHero.William29-May-06 5:55 
GeneralRe: How to create a PaneView, the Form is in a DLL. [modified] Pin
Shaun Wilde29-May-06 9:06
Shaun Wilde29-May-06 9:06 
Ah I don't think I understand your problem domain enough to help.

From your original post I think you are trying to do the following and I'll answer based on these assumptions.

#1) You have an application that loads forms into a frame dynamically.
#2) You are loading these forms from a DLL dynamically - i.e. these classes are not known about at compile time.

I think you need to understand more about CRuntimeClass and what it is and how it is implemented.
CRuntimeClass is not a class but a structure (or was when I last made an MFC program - a long long time ago) and is implemented by MACROS and hence every class you wish to load needs to be known about at compile/linker time.

You could get round this by having a common base class (CFormView may suffice)that you use to load and manipulate the class fom a DLL and you could use a DLL function (same name in every library that can be loaded and run using LoadLibrary/GetProcAddress[^]) that you could use to create the form (you could pass in a CDocument* should that be required) and then pass that as pointer to your code.

There is however an easier way to do all this - ActiveX (COM). Each of your forms is atomic, I guess, requiring no information for the main document and will therefore easily wrap into an ActiveX object. Now all you need to do is load and destroy ActiveX objects into the right view container when your icons are selected in the left view. If data is required to come from the document then you could create you own interface to pass this data to/from the ActiveX control. The added advantage of this is that you can host any control in that window that you wish and they don't all have to be written in C++ (e.g. VB, delphi, .NET, ...). MFC can act as a container foor COM objects very simply - CHtmlView or use this OleView sample[^] as a starter.

I hope this helps - if not then you'll either have to explain the problem more thoroughly and maybe even send code that shows what you are trying to do.

I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerry
www.many-monkeys.com

GeneralRe: How to create a PaneView, the Form is in a DLL. [modified] Pin
HFHero.William29-May-06 17:15
HFHero.William29-May-06 17:15 

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.