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: September 16, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you starting an on-premise-to-cloud data migration project? Have you thought about how much space you might need for your online platform or how to handle data that might be related to users who no longer exist? If these questions or any other concerns have been plaguing you about your migration project, check out this eSeminar. Join our speakers Betsy Bilhorn, VP, Product Management at Scribe, Mike Virnig, PowerSucess Manager and Michele …

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds