MainFrm.h
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:8k
源码类别:

界面编程

开发平台:

Visual C++

  1. // MainFrm.h : interface of the CMainFrame class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_)
  5. #define AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "ChildFormView.h"
  10. //#define ID_MYEXTBTN_SLIDER 5005
  11. #define ID_MYEXTBTN_SCROLLER 5006
  12. #define GetMainFrame() (DYNAMIC_DOWNCAST(CMainFrame,AfxGetMainWnd())) 
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMainFrame
  15. class CMainFrame
  16. : public CExtNCW < CFrameWnd >
  17. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  18. , public CExtCustomizeSite
  19. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  20. {
  21. public:
  22. CMainFrame();
  23. DECLARE_DYNAMIC(CMainFrame)
  24. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  25. CExtBarButton *  OnCreateToolbarButton(
  26. CExtToolControlBar * pBar,
  27. CExtCustomizeCmdTreeNode * pNodeI,
  28. CExtCustomizeCmdTreeNode * pNodeC
  29. );
  30. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  31. // Attributes
  32. public:
  33. CAviPlayer *m_pAviPlayer;
  34. CAviView  *m_pWndView;
  35. private:
  36. // window placement persistence
  37. WINDOWPLACEMENT m_dataFrameWP;
  38. // Operations
  39. public:
  40. // Overrides
  41. // ClassWizard generated virtual function overrides
  42. //{{AFX_VIRTUAL(CMainFrame)
  43. public:
  44. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  45. virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  46. virtual BOOL PreTranslateMessage(MSG* pMsg);
  47. virtual BOOL DestroyWindow();
  48. virtual void ActivateFrame(int nCmdShow = -1);
  49. //}}AFX_VIRTUAL
  50. // Implementation
  51. public:
  52. virtual ~CMainFrame();
  53. #ifdef _DEBUG
  54. virtual void AssertValid() const;
  55. virtual void Dump(CDumpContext& dc) const;
  56. #endif
  57. protected:  // control bar embedded members
  58. CExtMenuControlBar    m_wndMenuBar;
  59. CExtToolControlBar    m_wndToolBar;
  60. CExtThemeSwitcherToolControlBar    m_wndToolBarUiLook;
  61. CExtToolControlBar    m_wndToolBarPlayer;
  62. CExtToolControlBar    m_wndToolBarSeek;
  63. CExtToolControlBar    m_wndToolBarZoom;
  64. public:
  65. CExtStatusControlBar  m_wndStatusBar;
  66. class CZoomBarSliderButton: public CExtBarSliderButton
  67. {
  68. static BOOL g_bSynchronizing; 
  69. public:
  70. static CTypedPtrArray< CPtrArray, CZoomBarSliderButton* > g_arrButtons;
  71. CZoomBarSliderButton(
  72. CExtToolControlBar * pBar = NULL,
  73. UINT nCmdID = ID_SEPARATOR,
  74. UINT nStyle = 0,
  75. ULONG nScrollTotalRange = 0L,
  76. ULONG nScrollPos = 0L,
  77. ULONG nScrollPageSize = 0L,
  78. INT nScrollButtonExtentH = 0,
  79. INT nScrollButtonExtentV = 0,
  80. INT nScrollControlExtentH = 50,
  81. INT nScrollControlExtentV = 50
  82. )
  83. : CExtBarSliderButton(
  84. pBar,
  85. nCmdID,
  86. nStyle,
  87. nScrollTotalRange,
  88. nScrollPos,
  89. nScrollPageSize,
  90. nScrollButtonExtentH,
  91. nScrollButtonExtentV,
  92. nScrollControlExtentH,
  93. nScrollControlExtentV
  94. )
  95. {
  96. g_arrButtons.Add(this);
  97. }
  98. ~CZoomBarSliderButton()
  99. {
  100. for(int i=0; i< g_arrButtons.GetSize(); i++){
  101. if( this == g_arrButtons[i] ){
  102. g_arrButtons.RemoveAt(i);
  103. break;
  104. }
  105. }
  106. }
  107. ULONG ScrollPosSet( ULONG nScrollPos )
  108. {
  109. ULONG ulRet = CExtBarSliderButton::ScrollPosSet( nScrollPos );
  110. RedrawButton();
  111. if( g_bSynchronizing )
  112. return ulRet;
  113. g_bSynchronizing = TRUE;
  114. for(int i=0; i< g_arrButtons.GetSize(); i++){
  115. CZoomBarSliderButton *pZoomSliderTBB = g_arrButtons[i];
  116. ASSERT_VALID(pZoomSliderTBB);
  117. pZoomSliderTBB->ScrollPosSet(nScrollPos);
  118. }
  119. g_bSynchronizing = FALSE;
  120. CMainFrame *pFrame = GetMainFrame();
  121. if(pFrame->m_pAviPlayer){
  122. int nZoomPercent = 100;
  123. switch(nScrollPos) {
  124. case 0:
  125. nZoomPercent = 10;
  126. pFrame->m_wndStatusBar.SetPaneText(1,_T("10 %"));
  127. break;
  128. case 1:
  129. nZoomPercent = 25;
  130. pFrame->m_wndStatusBar.SetPaneText(1,_T("25 %"));
  131. break;
  132. case 2:
  133. nZoomPercent = 50;
  134. pFrame->m_wndStatusBar.SetPaneText(1,_T("50 %"));
  135. break;
  136. case 3:
  137. nZoomPercent = 75;
  138. pFrame->m_wndStatusBar.SetPaneText(1,_T("75 %"));
  139. break;
  140. case 4:
  141. nZoomPercent = 100;
  142. pFrame->m_wndStatusBar.SetPaneText(1,_T("100 %"));
  143. break;
  144. case 5:
  145. nZoomPercent = 150;
  146. pFrame->m_wndStatusBar.SetPaneText(1,_T("150 %"));
  147. break;
  148. case 6:
  149. nZoomPercent = 200;
  150. pFrame->m_wndStatusBar.SetPaneText(1,_T("200 %"));
  151. break;
  152. case 7:
  153. nZoomPercent = 250;
  154. pFrame->m_wndStatusBar.SetPaneText(1,_T("250 %"));
  155. break;
  156. case 8:
  157. nZoomPercent = 300;
  158. pFrame->m_wndStatusBar.SetPaneText(1,_T("300 %"));
  159. break;
  160. case 9:
  161. nZoomPercent = 350;
  162. pFrame->m_wndStatusBar.SetPaneText(1,_T("350 %"));
  163. break;
  164. case 10:
  165. nZoomPercent = 400;
  166. pFrame->m_wndStatusBar.SetPaneText(1,_T("400 %"));
  167. break;
  168. case 11:
  169. nZoomPercent = 450;
  170. pFrame->m_wndStatusBar.SetPaneText(1,_T("450 %"));
  171. break;
  172. }
  173. pFrame->m_pAviPlayer->SetZoom( nZoomPercent );
  174. if( !pFrame->m_pAviPlayer->IsPlaying() )
  175. pFrame->m_pWndView->Invalidate();
  176. pFrame->m_pWndView->OnSwUpdateScrollBars();
  177. }
  178. return ulRet;
  179. }
  180. }; // class CZoomBarSliderButton
  181. class CSeekBarSliderButton: public CExtBarSliderButton
  182. {
  183. static BOOL g_bSynchronizing; 
  184. public:
  185. static CTypedPtrArray< CPtrArray, CSeekBarSliderButton* > g_arrButtons;
  186. CSeekBarSliderButton(
  187. CExtToolControlBar * pBar = NULL,
  188. UINT nCmdID = ID_SEPARATOR,
  189. UINT nStyle = 0,
  190. ULONG nScrollTotalRange = 0L,
  191. ULONG nScrollPos = 0L,
  192. ULONG nScrollPageSize = 0L,
  193. INT nScrollButtonExtentH = 0,
  194. INT nScrollButtonExtentV = 0,
  195. INT nScrollControlExtentH = 50,
  196. INT nScrollControlExtentV = 50
  197. )
  198. : CExtBarSliderButton(
  199. pBar,
  200. nCmdID,
  201. nStyle,
  202. nScrollTotalRange,
  203. nScrollPos,
  204. nScrollPageSize,
  205. nScrollButtonExtentH,
  206. nScrollButtonExtentV,
  207. nScrollControlExtentH,
  208. nScrollControlExtentV
  209. )
  210. {
  211. g_bSynchronizing = FALSE;
  212. g_arrButtons.Add(this);
  213. }
  214. ~CSeekBarSliderButton()
  215. {
  216. for(int i=0; i< g_arrButtons.GetSize(); i++){
  217. if( this == g_arrButtons[i] ){
  218. g_arrButtons.RemoveAt(i);
  219. break;
  220. }
  221. }
  222. }
  223. ULONG ScrollPosSet( ULONG nScrollPos)
  224. {
  225. ULONG ulRet = CExtBarSliderButton::ScrollPosSet( nScrollPos );
  226. RedrawButton();
  227. if( g_bSynchronizing )
  228. return ulRet;
  229. g_bSynchronizing = TRUE;
  230. for(int i=0; i < g_arrButtons.GetSize(); i++){
  231. CSeekBarSliderButton *pSeekScrollerTBB = g_arrButtons[i];
  232. ASSERT_VALID(pSeekScrollerTBB);
  233. pSeekScrollerTBB->ScrollPosSet( nScrollPos );
  234. }
  235. g_bSynchronizing = FALSE;
  236. CMainFrame *pFrame = GetMainFrame();
  237. if(pFrame->m_pAviPlayer){
  238. pFrame->m_pAviPlayer->SetCurrentFrameNumber( nScrollPos );
  239. if( !pFrame->m_pAviPlayer->IsPlaying() && !pFrame->m_pAviPlayer->GetTempPause())
  240. pFrame->m_pWndView->Invalidate();
  241. }
  242. return ulRet;
  243. }
  244. virtual void OnClick(
  245. CPoint point,
  246. bool bDown
  247. )
  248. {
  249. CMainFrame *pFrame = GetMainFrame();
  250. pFrame->m_pAviPlayer->SetTempPause(TRUE);
  251. CExtBarSliderButton::OnClick(point,bDown);
  252. pFrame->m_pAviPlayer->SetTempPause(FALSE);
  253. pFrame->m_pAviPlayer->m_nStartFrameNumber = 0;
  254. pFrame->m_pWndView->Invalidate();
  255. }
  256. };// class CSeekBarSliderButton
  257. // Generated message map functions
  258. protected:
  259. //{{AFX_MSG(CMainFrame)
  260. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  261. afx_msg void OnSetFocus(CWnd *pOldWnd);
  262. afx_msg void OnPlay();
  263. afx_msg void OnUpdatePlay(CCmdUI* pCmdUI);
  264. afx_msg void OnStop();
  265. afx_msg void OnUpdateStop(CCmdUI* pCmdUI);
  266. afx_msg void OnPause();
  267. afx_msg void OnUpdatePause(CCmdUI* pCmdUI);
  268. afx_msg void OnFileOpen();
  269. afx_msg void OnTimer(__EXT_MFC_UINT_PTR nIDEvent);
  270. afx_msg void OnSlider();
  271. afx_msg void OnScroller();
  272. //}}AFX_MSG
  273. DECLARE_MESSAGE_MAP()
  274. private:
  275. };
  276. /////////////////////////////////////////////////////////////////////////////
  277. //{{AFX_INSERT_LOCATION}}
  278. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  279. #endif // !defined(AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_)