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

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • QA teams don't have time to test everything yet they can't afford to ship buggy code. Learn how Coverity can help organizations shrink their testing cycles and reduce regression risk by focusing their manual and automated testing based on the impact of change.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds