Creating Thin-Framed Splitter Windows


This article was contributed by Jens Winslow.

Environment: Windows and Dialogs, VC++

The credit for this solution goes to Markus Plaum, who was the one who actually figured out how to do this. Thanks, Markus.

While creating a program to draw a data view with a scale, using a splitter window with scale in top of the pane, and data in the bottom, I was frustrated in my inability to avoid the "fat" splitter border between the two view panes (and I did not want user to resize the scale view). After trying many approaches based on examples from books and CodeGuru, I was ready to give up. Luckily, a friend of mine had solved this problem in the past.

Somehow, he had determined that the CSplitterWnd class has several member variables that determine the frame of the splitter border. These do not appear to be documented, but if one steps through the constructor CSplitterWnd::CSplitterWnd() in ...MFC/Src\Winsplit.cpp, they are right there.

All I needed to do was to derive my own splitter class and modify these member variables to achieve my desired effect.

CThinFrameSplitterWnd : CSplitterWnd

CThinFrameSplitterWnd::CPaneSplitter()
{
  m_cxSplitter=PANE_BORDER;     // = 1
  m_cySplitter=PANE_BORDER;     // = 1
  m_cxBorderShare=PANE_SHARE;   // = 0
  m_cyBorderShare=PANE_SHARE;   // = 0
  m_cxSplitterGap=PANE_GAP;     // = 1
  m_cySplitterGap=PANE_GAP;     // = 1

}

Replacing the CSplitterWnd::HitTest(CPoint pt) const function allowed me to ignore the mouse position over the frame to avoid user resizing, which was both desired and necessary—my changes to m_cxSplitter and so forth cause an assertion if the user tries to resize.

int CThinFrameSplitterWnd::HitTest(CPoint /*pt*/) const
{
  ASSERT_VALID (this);
  return 0;       // don't let the user see the mouse hits
}

Below is an example where I have created a horizontal split frame (CChildFrame), with the left-hand frame having a scale_data splitter window, and the right-hand frame having two splitter windows, each with a scale_data splitter window. The right picture shows the effect of using CThinFrameSplitter instead of CSplitterWnd in a scale_data splitter window.



Click here for a larger image.

I hope this may save someone the time it took Markus and me to figure this out.

Jens Winslow



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Due to internal controls and regulations, the amount of long term archival data is increasing every year. Since magnetic tape does not need to be periodically operated or connected to a power source, there will be no data loss because of performance degradation due to the drive actuator. Read this white paper to learn about a series of tests that determined magnetic tape is a reliable long-term storage solution for up to 30 years.

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

Most Popular Programming Stories

More for Developers

RSS Feeds