Toolbar Withnin Splitter Windows

xiaoxiao2021-03-06  53

34 MEMBERS HAVE RATED THIS ARTICLE. RESULT:

Popularity: 4.72. Rating: 3.08 Out of 5.

Introduction

Has anyone ever wondered how to dock a toolbar inside a splitter pane? Normally you can not do that, but you can alter your splitter pane so that it will look just like you placed a toolbar on one of its sides. The trick is to create a two-pane splitter where your initial pane was;. but not just any splitter, we will use our own, which does not allow resizing, and has different border settings There is one additional view to create, and we will derive a class from CFormView Since features provided by this class area closer to our goal.

The code

First Goes The Custom Splitter Window:

// Class Definition

Class CsmartSplitterWnd: Public CSPLitterWnd

{

PUBLIC:

CSmartSplitterWnd ();

Virtual ~ csmartsplitterwnd ();

INTHITTEST (CPOINT PT) Const;

protected:

Declare_message_map ()

}

// Class Implementation

CSmartSplitterWnd :: csmartsplitterwnd ()

{

// put your owes here, to make the splitter fit your needs

m_cxsplitter = 3;

m_Cysplitter = 3;

m_cxbordershare = 0;

m_cybordershare = 0;

m_cxsplittergap = 3;

m_Cysplittergap = 3;

}

CsmartsplitterWnd :: ~ csmartsplitterwnd ()

{

}

Begin_MESSAGE_MAP (CSmartSplitterWnd, CSPLitterWnd)

// {{AFX_MSG_MAP (csmartsplitterwnd)

//}} AFX_MSG_MAP

END_MESSAGE_MAP ()

INTCSMARTSPLITTERWND :: Hittest (cpoint pt) const

{

Assert_Valid (this);

// do not allow caller to see mouse hits

Return 0;

}

Next, we must create a simple CFormView using the resource editor and ClassWizard. You can add any controls to your form view, but you must keep in mind that handling the WM_SIZE message may help you improve the look of your view. There are several ways to update your buttons and other controls inside the view; you may need to implement one of them to update, enable or disable the controls.The last step is to create the splitter itself and the views The code below matches a SDI application that accommodates. The Code Above Inside A Splitter Pane, But You Can Easily Adjust It To Fit Your Needs.

First, Add A Member to The CMAINFRAME CLASS OF TY CSMARTSPLITTERWND:

Class CMAINFRAME: PUBLIC CFRAMEWND

{

[...]

PUBLIC:

CSmartSplitterWnd M_Barsplitter;

In the oncreateclient member of the cmainframe class, add code to create the splitter inside the right pane:

// Create the splitter window

IF (! m_barsplitter.createstatic (& m_parentsplitter, 2, 1,

WS_CHILD | WS_VISIBLE | WS_BORDER,

m_parentsplitter.idfromrowcol (1, 0))) Return False;

// Create the views

M_barsplitter.createview (0, 0, Runtime_Class (CBARVIEW), CSIZE (0, 0), PCONText);

M_barsplitter.createView (1, 0, Runtime_Class (CTheView), CSIZE (0, 0), PCONText);

// Then Set Heights

The code is quite easy to follow and change to meet your needs, but if you need assistance, contact me. Also please send me bugs or updates, to keep this solution up-to-date. For more details on the sample application, contact ME.

About Stefan UnguReanu

... COMING IN A Short While Click Here To View Stefan UnguReanu's Online Profile.

Other Popular Splitter Windows Articles:

转载请注明原文地址:https://www.9cbs.com/read-115710.html

New Post(0)