1
|
CBCGPDialogBar m_wndDialogBar;
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#define IDW_DIALOGBAR
161
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CBCGPMDIChildWnd::OnCreate(lpCreateStruct) == - 1) return - 1; if (!m_wndDialogBar.Create (_T( "Dialog Bar"), this, TRUE, MAKEINTRESOURCE (IDD_DIALOG_BAR), WS_VISIBLE | WS_CHILD | CBRS_RIGHT, IDW_DIALOGBAR)) { TRACE0( "Failed to create dialogbar\n"); return - 1; } EnableDocking(CBRS_ALIGN_ANY); //让bar能够在任何边界停靠 EnableAutoHideBars(CBRS_ALIGN_RIGHT); //让右边bar能够自动隐藏 GetDockManager()->EnableDockBarMenu(TRUE); //让bar有下拉箭头菜单 m_wndDialogBar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndDialogBar); return 0; } |
1
2 3 4 |
void CChildFrame::OnBnClickedButton1()
{ AfxMessageBox(_T( "测试")); } |
1
|
m_wndDialogBar.EnableScrolling(FALSE);
|
1
2 |
m_wndDialogBar.ShowControlBar(FALSE, FALSE, FALSE);
m_wndDialogBar.ShowControlBar(TRUE, FALSE, FALSE); |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#pragma once
////////////////////////////////////////////////////////////////////////// // COutputDialogBar 对话框 class COutputDialogBar : public CBCGPDialogBar { DECLARE_DYNAMIC(COutputDialogBar) public: COutputDialogBar(); virtual ~COutputDialogBar(); // 对话框数据 enum { IDD = IDD_DIALOG_BAR }; CBCGPEdit m_edtOutput; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM); DECLARE_MESSAGE_MAP() }; |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include
"stdafx.h"
#include "TestMDIBars.h" #include "OutputDialogBar.h" ////////////////////////////////////////////////////////////////////////// // COutputDialogBar 对话框 IMPLEMENT_DYNAMIC(COutputDialogBar, CBCGPDialogBar) COutputDialogBar::COutputDialogBar() { EnableLayout(); EnableScrolling(FALSE); } COutputDialogBar::~COutputDialogBar() { } void COutputDialogBar::DoDataExchange(CDataExchange* pDX) { CBCGPDialogBar::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT1, m_edtOutput); } BEGIN_MESSAGE_MAP(COutputDialogBar, CBCGPDialogBar) ON_MESSAGE(WM_INITDIALOG, HandleInitDialog) END_MESSAGE_MAP() LRESULT COutputDialogBar::HandleInitDialog( WPARAM wParam, LPARAM lParam ) { LRESULT lRes = CBCGPDialogBar::HandleInitDialog(wParam, lParam); CBCGPStaticLayout *pLayout = (CBCGPStaticLayout*)GetLayout(); if (pLayout != NULL) { pLayout->AddAnchor(m_edtOutput, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth); pLayout->AddAnchor(IDC_BUTTON1, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeNone); } return lRes; } |
1
2 3 4 5 6 7 8 9 10 |
#include
"OutputDialogBar.h"
class CChildFrame : public CBCGPMDIChildWnd { public: COutputDialogBar m_wndDialogBar; void SetDialogBarSize(UINT nSize); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //........ } |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ if (CBCGPMDIChildWnd::OnCreate(lpCreateStruct) == - 1) return - 1; if (!m_wndDialogBar.Create (_T( "Dialog Bar"), this, TRUE, MAKEINTRESOURCE (IDD_DIALOG_BAR), WS_VISIBLE | WS_CHILD | CBRS_BOTTOM, IDW_DIALOGBAR)) { TRACE0( "Failed to create dialogbar\n"); return - 1; } EnableDocking(CBRS_ALIGN_BOTTOM); EnableAutoHideBars(CBRS_ALIGN_BOTTOM); GetDockManager()->EnableDockBarMenu(TRUE); m_wndDialogBar.EnableDocking(CBRS_ALIGN_BOTTOM); DockControlBar(&m_wndDialogBar); SetDialogBarSize( 170); m_wndDialogBar.ShowControlBar(FALSE, FALSE, FALSE); return 0; } void CChildFrame::SetDialogBarSize(UINT nSize) { CBCGPSlider *pDefaultSlider = m_wndDialogBar.GetDefaultSlider(); if (pDefaultSlider == NULL) { return; } BOOL bLeftBar = FALSE; CBCGPBarContainer *pContainer = pDefaultSlider->FindContainer(&m_wndDialogBar, bLeftBar); while (pContainer->GetParentContainer() != NULL) { pContainer = pContainer->GetParentContainer(); } CRect rectContainer; pContainer->GetWindowRect(rectContainer, FALSE); DWORD dwSliderStyle = pDefaultSlider->GetCurrentAlignment(); CPoint ptOffset( 0, 0); switch (dwSliderStyle) { case CBRS_ALIGN_TOP: ptOffset.y = nSize - rectContainer.Height(); break; case CBRS_ALIGN_BOTTOM: ptOffset.y = rectContainer.Height() - nSize; break; case CBRS_ALIGN_LEFT: ptOffset.x = nSize - rectContainer.Width(); break; case CBRS_ALIGN_RIGHT: ptOffset.x = rectContainer.Width() - nSize; break; } pDefaultSlider->MoveSlider(ptOffset); } |
1
2 3 4 5 6 7 8 |
void CTestMDIBarsView::OnTestbutton()
{ CChildFrame *pParentFrame = ((CChildFrame *)GetParentFrame()); if (pParentFrame != NULL) { pParentFrame->m_wndDialogBar.ShowControlBar(TRUE, FALSE, FALSE); } } |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#pragma once
////////////////////////////////////////////////////////////////////////// // COutputViewBar class COutputViewBar : public CBCGPDockingControlBar { public: COutputViewBar(); virtual ~COutputViewBar(); protected: CBCGPEdit m_edtOutput; DECLARE_MESSAGE_MAP() afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnPaint(); afx_msg void OnSetFocus(CWnd* pOldWnd); }; |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#include
"stdafx.h"
#include "OutputViewBar.h" ////////////////////////////////////////////////////////////////////////// // COutputViewBar COutputViewBar::COutputViewBar() { } COutputViewBar::~COutputViewBar() { } BEGIN_MESSAGE_MAP(COutputViewBar, CBCGPDockingControlBar) ON_WM_CREATE() ON_WM_SIZE() ON_WM_PAINT() ON_WM_SETFOCUS() END_MESSAGE_MAP() int COutputViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CBCGPDockingControlBar::OnCreate(lpCreateStruct) == - 1) return - 1; CRect rectClient( 0, 0, lpCreateStruct->cx, lpCreateStruct->cy); const DWORD dwStyle = ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL | WS_CHILD | WS_VISIBLE; if (!m_edtOutput.Create(dwStyle, rectClient, this, 1)) { TRACE0( "Failed to create output window\n"); return - 1; } m_edtOutput.SetFont(&globalData.fontRegular); return 0; } void COutputViewBar::OnSize(UINT nType, int cx, int cy) { CBCGPDockingControlBar::OnSize(nType, cx, cy); CRect rc; GetClientRect(rc); m_edtOutput.SetWindowPos( NULL, 1, 1, rc.Width() - 2, rc.Height() - 2, SWP_NOACTIVATE | SWP_NOZORDER); } void COutputViewBar::OnPaint() { CPaintDC dc( this); CRect rectEdit; m_edtOutput.GetWindowRect(rectEdit); ScreenToClient(rectEdit); rectEdit.InflateRect( 1, 1); dc.Draw3dRect(rectEdit, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); } void COutputViewBar::OnSetFocus(CWnd* pOldWnd) { CBCGPDockingControlBar::OnSetFocus(pOldWnd); m_edtOutput.SetFocus(); } |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ if (CBCGPMDIChildWnd::OnCreate(lpCreateStruct) == - 1) return - 1; if (!m_wndOutput.Create(_T( "输出"), this, CRect( 0, 0, 200, 100), TRUE, ID_OUTPUT_BAR, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM)) { TRACE(_T( "Failed to create output bar\n")); return FALSE; } EnableDocking(CBRS_ALIGN_ANY); EnableAutoHideBars(CBRS_ALIGN_ANY); GetDockManager()->EnableDockBarMenu(TRUE); m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndOutput); return 0; } |