• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            鐵觀音

            C++編程寶典

               ::  ::  ::  ::  :: 管理 ::
              1 隨筆 :: 19 文章 :: 0 評論 :: 0 Trackbacks
            ?

            Had this problem before. I guess there are some more interested in a solution.

            It seems CSplitterWnd is designed to be used in document/view-based applications only.
            But by overriding some virtual methods in a derived class, you can make splitter windows based on CSplitterWnd be used in dialog based application, ActiveX-Controls using MFC:

            All virtual methods that call GetParentFrame() in its implementation have to be overridden.
            I have done this by using existing code except
            - that I replaced the call to GetParentFrame() by a call to GetParent().
            - all references or pointers to CFrameWnd were changed to references or pointers to CWnd.

            I derived a class CxSplitterWnd from the class CSplitterWnd and proceeded as stated above.
            Then I used this class in a dialog based application in the same way as any other CWnd derived class.
            For example:

            class CSampleDialog : public CDialog
            {
            	...
            	CxSplitterWnd m_wndSplitter;
            	....
            }
            
            BOOL CSampleDlg::OnInitDialog()
            {
            ...
            	// TODO: Add extra initialization here
            	m_wndSplitter.CreateStatic(this, 1, 2);
            	m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CSampleView), CSize(50,0), NULL);
            	m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CSampleView), CSize(0,0), NULL);
            
            	CRect rect = ...;
            	m_wndSplitter.MoveWindow(&rect);
            	...
            }
            

            The sample attached is a dialog based application and demonstrates the use of CxSplitterWnd. It does
            nothing useful.

            This is the new class declaration:

            // SplitWnd.h : implementation file// class CxSplitterWnd : public CSplitterWnd
            {
            	// Constructionpublic:
            	CxSplitterWnd() {};
            	virtual ~CxSplitterWnd() {};
            
            	// Operationspublic:
            	// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CxSplitterWnd)//}}AFX_VIRTUAL // Implementationpublic:
            	// These are the methods to be overriddenvirtualvoid StartTracking(int ht);
            	virtual CWnd* GetActivePane(int* pRow = NULL, int* pCol = NULL);
            	virtualvoid SetActivePane( int row, int col, CWnd* pWnd = NULL );
            	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
            	virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
            	virtual BOOL OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult );
            
            	// Generated message map functionsprotected:
            	//{{AFX_MSG(CxSplitterWnd)// NOTE - the ClassWizard will add and remove member functions here.//}}AFX_MSG
            	DECLARE_MESSAGE_MAP()
            };
            
            
            And here the implementation file:
            // SplitWnd.cpp : implementation file// #include "stdafx.h"
            #include "SplitWnd.h"
            
            #ifdef _DEBUG
            #definenew DEBUG_NEW
            #undef THIS_FILE
            staticchar THIS_FILE[] = __FILE__;
            #endif
            
            // HitTest return values (values and spacing between values is important)// Had to adopt this because it has module scope enum HitTestValue
            {
            	noHit = 0,
            	vSplitterBox = 1,
            	hSplitterBox = 2,
            	bothSplitterBox = 3, // just for keyboard
            	vSplitterBar1 = 101,
            	vSplitterBar15 = 115,
            	hSplitterBar1 = 201,
            	hSplitterBar15 = 215,
            	splitterIntersection1 = 301,
            	splitterIntersection225 = 525
            };
            
            /////////////////////////////////////////////////////////////////////////////// CxSplitterWnd 
            
            BEGIN_MESSAGE_MAP(CxSplitterWnd, CSplitterWnd)
            //{{AFX_MSG_MAP(CxSplitterWnd)// NOTE - the ClassWizard will add and remove mapping macros here.//}}AFX_MSG_MAP
            END_MESSAGE_MAP()
            
            CWnd* CxSplitterWnd::GetActivePane(int* pRow, int* pCol)
            {
            	ASSERT_VALID(this);
            	CWnd* pView = GetFocus();
            	// make sure the pane is a child pane of the splitterif (pView != NULL && !IsChildPane(pView, pRow, pCol))
            	pView = NULL;
            	return pView;
            }
            
            void CxSplitterWnd::SetActivePane( int row, int col, CWnd* pWnd)
            {
            	// set the focus to the pane
            	CWnd* pPane = pWnd == NULL ? GetPane(row, col) : pWnd;
            	pPane->SetFocus();
            }
            
            void CxSplitterWnd::StartTracking(int ht)
            {
            ASSERT_VALID(this);
            	if (ht == noHit)
            		return;
            	// GetHitRect will restrict 'm_rectLimit' as appropriate
            	GetInsideRect(m_rectLimit);
            	if (ht >= splitterIntersection1 && ht <= splitterIntersection225)
            	{
            		// split two directions (two tracking rectangles)int row = (ht - splitterIntersection1) / 15;
            		int col = (ht - splitterIntersection1) % 15;
            		GetHitRect(row + vSplitterBar1, m_rectTracker);
            		int yTrackOffset = m_ptTrackOffset.y;
            		m_bTracking2 = TRUE;
            		GetHitRect(col + hSplitterBar1, m_rectTracker2);
            		m_ptTrackOffset.y = yTrackOffset;
            	}
            	elseif (ht == bothSplitterBox)
            	{
            		// hit on splitter boxes (for keyboard)
            		GetHitRect(vSplitterBox, m_rectTracker);
            		int yTrackOffset = m_ptTrackOffset.y;
            		m_bTracking2 = TRUE;
            		GetHitRect(hSplitterBox, m_rectTracker2);
            		m_ptTrackOffset.y = yTrackOffset;
            		// center it
            		m_rectTracker.OffsetRect(0, m_rectLimit.Height()/2);
            		m_rectTracker2.OffsetRect(m_rectLimit.Width()/2, 0);
            	}
            	else
            	{
            		// only hit one bar
            		GetHitRect(ht, m_rectTracker);
            	}
            
            	// steal focus and capture
            	SetCapture();
            	SetFocus();
            	// make sure no updates are pending
            	RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
            	// set tracking state and appropriate cursor
            	m_bTracking = TRUE;
            	OnInvertTracker(m_rectTracker);
            	if (m_bTracking2)
            	OnInvertTracker(m_rectTracker2);
            	m_htTrack = ht;
            	SetSplitCursor(ht);
            }
            
            /////////////////////////////////////////////////////////////////////////////// CSplitterWnd command routing 
            BOOL CxSplitterWnd::OnCommand(WPARAM wParam, LPARAM lParam)
            {
            	if (CWnd::OnCommand(wParam, lParam))
            	return TRUE;
            	// route commands to the splitter to the parent frame windowreturn GetParent()->SendMessage(WM_COMMAND, wParam, lParam);
            }
            
            BOOL CxSplitterWnd::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult )
            {
            	if (CWnd::OnNotify(wParam, lParam, pResult))
            	return TRUE;
            	// route commands to the splitter to the parent frame window
            	*pResult = GetParent()->SendMessage(WM_NOTIFY, wParam, lParam);
            	return TRUE;
            }
            
            BOOL CxSplitterWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
            {
            	// The code line below is necessary ifusing CxSplitterWnd in a regular dll// AFX_MANAGE_STATE(AfxGetStaticModuleState()); return CWnd::OnWndMsg(message, wParam, lParam, pResult);
            }
            
            posted on 2006-10-14 10:42 鐵觀音 閱讀(1100) 評論(0)  編輯 收藏 引用 所屬分類: VC界面控件類
            久久综合综合久久综合| 亚洲精品第一综合99久久 | 久久精品中文字幕一区| 狠狠色丁香久久婷婷综合蜜芽五月| 色诱久久av| 久久久久99精品成人片欧美| 久久婷婷综合中文字幕| 亚洲精品国产自在久久| 99久久精品国产综合一区| 99精品久久久久久久婷婷| 久久久久无码专区亚洲av| 日韩人妻无码精品久久久不卡| 国产精品一久久香蕉国产线看| 精品国产VA久久久久久久冰| 麻豆精品久久久久久久99蜜桃| 国内精品久久久久伊人av| 精品人妻伦九区久久AAA片69 | 亚洲欧洲精品成人久久曰影片 | 久久av免费天堂小草播放| 久久WWW免费人成一看片| 夜夜亚洲天天久久| 99久久国语露脸精品国产| 亚洲精品乱码久久久久久| 伊人色综合九久久天天蜜桃| 老司机国内精品久久久久| 亚洲成色www久久网站夜月| 久久久久亚洲av成人无码电影| 四虎国产精品免费久久5151| 粉嫩小泬无遮挡久久久久久 | 国产一级持黄大片99久久| 一本一本久久a久久综合精品蜜桃| 精品久久久久中文字幕一区| 国产产无码乱码精品久久鸭| 国产成人精品免费久久久久| 久久久久久亚洲AV无码专区| 色狠狠久久AV五月综合| 久久亚洲私人国产精品| 久久久久99精品成人片直播| 久久精品国产亚洲精品2020 | 精品久久久无码21p发布| 亚洲人成网站999久久久综合|