gusucode.com > 基于VC编程界面编程高级应用技术源码程序 > VC界面编程高级应用技术/code/1/MyExplorer/Left.cpp
// Left.cpp : implementation file // #include "stdafx.h" #include "MyExplorer.h" #include "Left.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CLeft IMPLEMENT_DYNCREATE(CLeft, CView) CLeft::CLeft() { } CLeft::~CLeft() { } BEGIN_MESSAGE_MAP(CLeft, CView) //{{AFX_MSG_MAP(CLeft) ON_WM_CREATE() ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLeft drawing void CLeft::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CLeft diagnostics #ifdef _DEBUG void CLeft::AssertValid() const { CView::AssertValid(); } void CLeft::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CLeft message handlers int CLeft::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; m_ImageList.Create( IDB_PUSHPIN, 16, 1, RGB( 255, 0, 255 )); // 建立目录树的标题 if (!m_Caption.Create(this, _T("文件夹"))) { TRACE0(_T("Unable to create caption.\n")); return -1; } // 建立目录树的标题按钮 if (!m_CaptionButton.Create(NULL, WS_VISIBLE|BS_ICON|BS_OWNERDRAW|BS_CENTER|BS_VCENTER, CRect(0,0,0,0), this, IDC_CAPT_BUTTON)) { TRACE0(_T("Unable to create caption button.\n")); return -1; } // 建立目录树的标题按钮的图标 m_CaptionButton.SetIcon( m_ImageList.ExtractIcon(2), CSize( 16, 15 )); if( !m_ShellTree.Create(WS_VISIBLE, CRect(0,0,0,0), this, IDC_SHELL_TREE)) { TRACE0(_T("Unable to create tree control.\n")); return -1; } return 0; } void CLeft::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); //定位目录树的标题 if( m_Caption.GetSafeHwnd()) { m_Caption.MoveWindow( 0, 0, cx, 19 ); } //定位目录树的按钮 if( m_CaptionButton.GetSafeHwnd()) { m_CaptionButton.MoveWindow( cx-18, 2, 16, 15 ); } //定位目录树 if( m_ShellTree.GetSafeHwnd()) { m_ShellTree.MoveWindow( 0, 19, cx, cy-19 ); } }