Splitter Dialog

Environment: VC6 SP3, NT4 SP5

The CSplitterDialog class adds splitter capabilities to a dialog, much like the MFC CSplitterWnd class does to a child frame. Derive your CDialog-derived class from CSplitterDialog and call InitDialog() from your OnInitDialog() override.
Here's the prototype:

void CSplitterDialog::InitDialog( LPCTRLINFO pLeftCtrl, LPCTRLINFO pRightCtrl, UINT nPerc );

The first two parameters are pointers to CTRLINFO structure which describes the controls (targets) managed by the splitter, the third is the initial horizontal dimension of the left control (expressed in percentage of dialog's total dimension).

If the dialog is resizable, the controls are automatically resized to keep the settings of the dialog. It is also possible to define an area on the dialog surface not used by the target controls: at the left of left control, at the right of right control and above or below each control (e.g. to add buttons or bitmaps on the dialog in addition to target controls).
Target controls must belong to a CWnd-derived class (CListCtrl, CTreeCtrl, CButton, CEdit, CStatic, ...)

Below are listed CTRLINFO structure members:

  • CWnd* m_pWnd: pointer to the control;
  • CSize m_sizeMin: specifies minimum allowable size of the control (pixels);
  • UINT m_nOffX: specifies offset (pixels) at the left of the control, for left control, or at the right of the control, for right control;
  • UINT m_nOffY: specifies offset (pixels) above or below the control;
  • UINT m_nHowY: specifies if m_nOffY is an offset above (CSplitterDialog::TOP) or below (CSplitterDialog::BOTTOM) the control.

How to use this class:

  • use resource editor to create a dialog with two target controls and additional controls if you need them. The target controls are resized and repositioned by CSplitterDialog::InitDialog(); the other controls must be managed by the developer (place them in the free area - see the CTRLINFO structure previously described);
  • set the dialog style to resizable if you want a resizable dialog. Warning: the non-target controls, placed on the dialog, should be managed by developer during the resizing phase (i.e. should be correctly repositioned);
  • define the class that manage the dialog, must derive from CSplitterDialog;
  • add a member variable for each target control and add the WM_INITDIALOG message map with Class Wizard, for example:
    CListCtrl m_ctrlLeft;
    CTreeCtrl m_ctrlRight;
  • in your OnInitDialog() override initialize CTRLINFO structure for each target control and call CSplitterDialog::InitDialog().

Thanks to Matteo Benzoni and Diego Perrotta

Downloads

Download demo project - 33 Kb
Download source - 4 Kb


Comments

  • Your own double turn on adidas

    Posted by Updatatweda on 05/05/2013 10:00pm

    J [url=http://www.adidaskutuja.com/]アディダス スニーカー[/url] jnUgh NafDud HtpHjm ZolI [url=http://www.adidaskutuja.com/adidas-originals-c-4.html]アディダス ランニングシューズ[/url] akIrhIwe EkhWxwVbnQ [url=http://www.adidaskutuja.com/adidas-superstar-c-2.html]アディダス シューズ[/url] hp MarOso [url=http://www.adidaskutuja.com/jeremy-scott-c-5.html]アディダス 通販[/url]CweFza LmgMiw

    Reply
  • WndProc failure

    Posted by Legacy on 11/19/2002 12:00am

    Originally posted by: Vilmos Schnedarek

    There is a bug in the implementation of the WndProc hooking (NewWndProc). The old WndProc is saved in the m_MFCWndProc static variable. But what is happening if there are several different instances of this CSplitterDialog? In this case all these instances will use as the default WndProc the first one, which was saved into the m_MFCWndProc.
    This is totaly wrong, because every instance should use its window procedure.
    It can be corrected in two ways:

    1, make the m_MFCWndProc variable to be non-static and correct to code.

    2, delete everything related this window procedure hooking and create with the classwizard a message handler for the WM_SIZING then place there the following code:

    void CSplitterDialog::OnSizing(UINT fwSide, LPRECT pRect)
    {
    // Verify that the controls size are correct: if are not correct set the value
    // to make it correct
    LPRECT rect = (LPRECT)pRect;
    if ( rect->right - rect->left - m_rectSplitter.right -
    (int)m_infoRight->m_nOffX - 8 < m_infoRight->m_sizeMin.cx )
    rect->right = m_infoRight->m_sizeMin.cx + rect->left +
    m_rectSplitter.right + m_infoRight->m_nOffX + 8;

    int max = max(
    m_infoLeft->m_sizeMin.cy + m_infoLeft->m_nOffY,
    m_infoRight->m_sizeMin.cy + m_infoRight->m_nOffY);
    if ( rect->bottom - rect->top - 8 < max )
    rect->bottom = max + rect->top + 8;
    }

    Vilmos

    Reply
  • How can I set a based CView in a splitted window

    Posted by Legacy on 07/28/2001 12:00am

    Originally posted by: Mohamed KHADRAOUI

    I think that is very useful to give the possibility of attaching a CView based in a splitted area

    Thanks

    Reply
  • Is there any way to split horizontally?

    Posted by Legacy on 01/24/2000 12:00am

    Originally posted by: Karen Gamble

    This is great. What I need is to be able to split horizontally. Actually I need 2 trees on the left, one on top of the other, and a report on the right the size of both trees.
    Thanks.

    Reply
  • Why not an arbitrary offset value for both top and bottom?

    Posted by Legacy on 01/04/2000 12:00am

    Originally posted by: Martin Amandusson

    The CSplitterDialog::InitDialog() takes two CTRLINFO structs as parameters. The CTRLINFO has a m_nHowY member that is used to tell wether the offset should displace the controls up or down. Why?

    It could in fact be useful to offset the splitter from top and bottom of the dialog at the same time. The CTRLINFO struct could be changed to hold the offsets from both top and bottom of the dialog.

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

Top White Papers and Webcasts

  • 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 …

  • 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 …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds