MainFrm.cpp
上传用户:gzboli
上传日期:2013-04-10
资源大小:471k
文件大小:5k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "QuickImage.h"
- #include "MainFrm.h"
- #include "DirFrm.h"
- #include "ImgFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code !
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_SEPARATOR,
- ID_SEPARATOR,
- // ID_INDICATOR_CAPS,
- // ID_INDICATOR_NUM,
- // ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // m_muToolBars[0] = FALSE;
-
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- /* if (!m_tbMap.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_tbMap.LoadToolBar(IDR_TB_MAP))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- m_tbMap.EnableDocking(CBRS_ALIGN_ANY);
- */ // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- m_wndStatusBar.SetPaneInfo(1, ID_SEPARATOR, SBPS_NORMAL, 150);
- m_wndStatusBar.SetPaneInfo(2, ID_SEPARATOR, SBPS_NORMAL, 80);
- SetStatusText(0);
- // ShowControlBar(&m_tbMap,FALSE,FALSE);
- CenterWindow();
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CMDIFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- CRect rcDesktop;
- ::GetWindowRect(::GetDesktopWindow(),&rcDesktop);
- cs.cx=rcDesktop.Width();
- cs.cy=rcDesktop.Height()-30;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- BOOL CMainFrame::UpdateUIs(BOOL bActivate, const CWnd* pActivateWnd, const CWnd* pDeactivateWnd)
- {
- /* DWORD dwStyle = m_tbMap.GetBarStyle();
- UINT nDockBarID = 0;
- nDockBarID = (dwStyle & CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : nDockBarID;
- nDockBarID = (dwStyle & CBRS_ALIGN_BOTTOM && nDockBarID==0) ? AFX_IDW_DOCKBAR_BOTTOM : nDockBarID;
- nDockBarID = (dwStyle & CBRS_ALIGN_LEFT && nDockBarID==0) ? AFX_IDW_DOCKBAR_LEFT : nDockBarID;
- nDockBarID = (dwStyle & CBRS_ALIGN_RIGHT && nDockBarID==0) ? AFX_IDW_DOCKBAR_RIGHT : nDockBarID;
- //Modify Toolbar
- if(NULL == pActivateWnd)
- {
- m_tbMap.ShowWindow(SW_HIDE);
- m_muToolBars[0] = FALSE;
- RecalcLayout();
- return TRUE;
- }
- else if(pActivateWnd->IsKindOf(RUNTIME_CLASS(CDirFrame)))
- {
- m_tbMap.ShowWindow(SW_HIDE);
- m_muToolBars[0] = TRUE;
- }
- else if(pActivateWnd->IsKindOf(RUNTIME_CLASS(CImgFrame)))
- {
- m_tbMap.ShowWindow(SW_SHOW);
- DockControlBar(&m_tbMap, nDockBarID);
- m_muToolBars[0] = TRUE;
- }
- else
- {
- m_tbMap.ShowWindow(SW_HIDE);
- m_muToolBars[0] = FALSE;
- }
- RecalcLayout();
- */
- /////////////Modify Menu
- return TRUE;
- }
- int CMainFrame::FindMenuItem(const CMenu *Menu, LPCTSTR MenuString)
- {
- ASSERT(Menu);
- ASSERT(::IsMenu(Menu->GetSafeHmenu()));
- int count = Menu->GetMenuItemCount();
- for (int i = 0; i < count; i++)
- {
- CString str;
- if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
- (strcmp(str, MenuString) == 0))
- return i;
- }
- return -1;
- }
- void CMainFrame::SetStatusText(int iPane, LPCTSTR lpszText)
- {
- // ASSERT(iPane > -1 && m_wndStatusBar
- if(NULL == lpszText)
- {
- m_wndStatusBar.SetPaneText(1, _T("Image Size: "));
- m_wndStatusBar.SetPaneText(2, _T("Zoom: "));
- }
- else
- {
- m_wndStatusBar.SetPaneText(iPane, lpszText);
- }
- }