📄 mainfrm.cpp
字号:
// This file is part of Ambulant Player, www.ambulantplayer.org.//// Copyright (C) 2003-2007 Stichting CWI, // Kruislaan 413, 1098 SJ Amsterdam, The Netherlands.//// Ambulant Player is free software; you can redistribute it and/or modify// it under the terms of the GNU Lesser General Public License as published by// the Free Software Foundation; either version 2.1 of the License, or// (at your option) any later version.//// Ambulant Player is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public License// along with Ambulant Player; if not, write to the Free Software// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA// MainFrm.cpp : implementation of the CMainFrame class//#include "stdafx.h"#include "afxpriv.h"#include "AmbulantPlayer.h"#include "MainFrm.h"#ifdef _DEBUG#define new DEBUG_NEW#endifstatic CMainFrame *theMainFrame;// CMainFrameIMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() ON_MESSAGE(WM_SETMESSAGESTRING, OnSetMessageString) ON_MESSAGE(WM_APP, OnSetStatusLine) ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullScreen)END_MESSAGE_MAP()static UINT indicators[] ={ ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL,};// CMainFrame construction/destructionCMainFrame::CMainFrame(): m_fullScreen(FALSE){ // TODO: add member initialization code here theMainFrame = this;}CMainFrame::~CMainFrame(){ theMainFrame = NULL;}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){ SetStatusLine("No document open"); if (CFrameWnd::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 toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // 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); return 0;}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs){ // DO NOT ADD DOCUMENT NAME TO TITLE cs.style &= ~FWS_ADDTOTITLE; if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs // Set the startup dimensions for MMS //cs.cx = 176 + 28; //cs.cy = 216 + 108; return TRUE;}// CMainFrame diagnostics#ifdef _DEBUGvoid CMainFrame::AssertValid() const{ CFrameWnd::AssertValid();}void CMainFrame::Dump(CDumpContext& dc) const{ CFrameWnd::Dump(dc);}#endif //_DEBUGvoidCMainFrame::SetStatusLine(char *message){ USES_CONVERSION; m_statusline = message; CFrameWnd::OnSetMessageString(0, (LPARAM)A2CT(m_statusline.c_str()));}LRESULTCMainFrame::OnSetStatusLine(WPARAM wParam, LPARAM lParam){ SetStatusLine((char *)lParam); return 0;}LRESULTCMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam){ USES_CONVERSION; if (wParam == AFX_IDS_IDLEMESSAGE) return CFrameWnd::OnSetMessageString(0, (LPARAM)A2CT(m_statusline.c_str())); return CFrameWnd::OnSetMessageString(wParam, lParam);}afx_msg void CMainFrame::OnViewFullScreen(){ WINDOWPLACEMENT wp; wp.showCmd = SW_SHOWNORMAL;#if 0 // Disable child window positioning within mainframe, because // apparently I (Jack) don't have a clue what I'm doing. CView *child = GetActiveView(); RECT childPos; if (child) child->GetWindowRect(&childPos);#endif m_fullScreen = !m_fullScreen; if (m_fullScreen) { // Entering fullscreen mode m_wndStatusBar.ShowWindow(SW_HIDE); m_wndToolBar.ShowWindow(SW_HIDE); // Calculate new frame position GetWindowRect(&m_origRect); ::GetWindowRect(::GetDesktopWindow(), &wp.rcNormalPosition); ::AdjustWindowRectEx(&wp.rcNormalPosition, GetStyle(), TRUE, GetExStyle()); } else { // Leaving fullscreen mode m_wndStatusBar.ShowWindow(SW_SHOW); m_wndToolBar.ShowWindow(SW_SHOW); wp.rcNormalPosition = m_origRect; } SetWindowPlacement(&wp);#if 0 // Center the child document if (child) { int dx = (wp.rcNormalPosition.right - wp.rcNormalPosition.left) / 2 - (childPos.right - childPos.left) / 2; int dy = (wp.rcNormalPosition.bottom - wp.rcNormalPosition.top) / 2 - (childPos.bottom - childPos.top) / 2; child->SetWindowPos(NULL, dx, dy, 0, 0, SWP_NOZORDER); }#endif}voidset_status_line(const char *message){ if (theMainFrame) theMainFrame->PostMessage(WM_APP, 0, (LPARAM)message);}// CMainFrame message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -