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

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds