Click here to Skip to main content
Click here to Skip to main content

Highlight view with focus

, 10 Jan 2000
Rate this:
Please Sign up or sign in to vote.
Adding visual feedback on which pane in a split view currently has the focus
<!-- Article Starts -->

Many times it would be nice to have some visual feedback as to which pane in a split view currently has the focus. This is very useful if you have multiple view types and different keyboard strokes cause different actions in each.

NOTE: This uses an undocumented feature in MFC so be careful in the future.

Step 1) Derive your own SplitterWnd class.
Step 2) Override the undocumented OnDrawSplitter function.
Step 3) Replace the CSplitterWnd instance in the child frame with your splitter.

This example draws in red but you can adjust the color and width of the frame by altering the define values.

// MySplitterWnd.h

class MySplitterWnd : public CSplitterWnd
    int cRow;
    int cCol; 
    void OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg);
    void RefreshSplitBars(void);

// MySplitterWnd.cpp

#include "StdAfx.h"
#include "MySplitterWnd.h"

#define FOCUS_HILIGHT_COLOR_ULO RGB(180, 75, 25)
#define FOCUS_HILIGHT_COLOR_LRO RGB(245, 5, 25)
#define FOCUS_HILIGHT_COLOR_ULI RGB(145, 95, 75)
#define FOCUS_HILIGHT_COLOR_LRI RGB(220, 65, 40)


#define SPLITTER_CX 4
#define SPLITTER_CY 4

void MySplitterWnd::RefreshSplitBars(void)
    CRect rectInside;

    DrawAllSplitBars(NULL, rectInside.right, rectInside.bottom);

    cRow = 0;
    cCol = 0;

    m_cxSplitter = SPLITTER_CX;
    m_cySplitter = SPLITTER_CY;
    m_cxSplitterGap = SPLITTER_GAPX;
    m_cySplitterGap = SPLITTER_GAPY;

void MySplitterWnd::OnDrawSplitter(CDC* pDC, ESplitType nType,
                                   const CRect& rectArg)
    if ((FOCUS_HILIGHT_SHOW) && ((GetRowCount() > 1) || 
        (GetColumnCount() > 1)) && (nType == splitBorder))
        int pRow = 0;
        int pCol = 0;
        if (
            pRow = 1;
        if (rectArg.left)
            pCol = 1;
        if ((cRow == pRow) && (cCol == pCol))
            if (pDC == NULL)
                RedrawWindow(rectArg, NULL, RDW_INVALIDATE|RDW_NOCHILDREN);
            CRect rect = rectArg;



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

About the Author

Randy More

United States United States
No Biography provided

Comments and Discussions

General3 static splitter window Pinsussweilun31-Aug-04 20:01 
hi,your article is very good Smile | :)
but I have a question.. When I make a 2 static splitter it works well
but when I make a 3 static splitter window,just like the way "powerpoint". It does'nt work! >"< Could you help me!? thanks!
some codes like that..
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) {
!m_wndSplitter2.CreateStatic(&m_wndSplitter, 2, 1,WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0, 1))
!m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CView3),CSize(0, 0), pContext)
AfxMessageBox("Create View Failed!");
return FALSE;
return TRUE;
1.the left window
2.the top-right window
3.the bottom-right window


GeneralMFC7 unhandled exception PinmemberNate Strandberg9-Jul-03 17:16 
GeneralStatic Splits PinmemberDavid Jones17-Jan-02 4:06 
Questionhow to access these protected functions PinsussDarren Schroeder9-May-00 5:46 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140718.1 | Last Updated 11 Jan 2000
Article Copyright 2000 by Randy More
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid