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

界面编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "FullScreenState.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. // uncomment this to remove thin border if the main-frame in the fullscreen mode
  12. // (please do not forget to remove the app state in the system registry folder
  13. // HKEY_CURRENT_USERSoftwareFossFullScreenState)
  14. //#define __REMOVE_THIN_FULLSCREEN_BORDER
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainFrame
  17. IMPLEMENT_DYNAMIC( CMainFrame, CMDIFrameWnd )
  18. BEGIN_MESSAGE_MAP( CMainFrame, CMDIFrameWnd )
  19. //{{AFX_MSG_MAP(CMainFrame)
  20. ON_WM_CREATE()
  21. ON_COMMAND(ID_VIEW_FULL_SCREEN, OnViewFullScreen)
  22. ON_UPDATE_COMMAND_UI(ID_VIEW_FULL_SCREEN, OnUpdateViewFullScreen)
  23. ON_WM_SYSCOMMAND()
  24. //}}AFX_MSG_MAP
  25. ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
  26. ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)
  27. ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck )
  28. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu)
  29. ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck )
  30. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu)
  31. ON_COMMAND_EX(IDR_TOOLBAR3, OnBarCheck )
  32. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR3, OnUpdateControlBarMenu)
  33. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_0, OnBarCheck )
  34. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_0, OnUpdateControlBarMenu)
  35. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_1, OnBarCheck )
  36. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_1, OnUpdateControlBarMenu)
  37. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_2, OnBarCheck )
  38. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_2, OnUpdateControlBarMenu)
  39. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_3, OnBarCheck )
  40. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_3, OnUpdateControlBarMenu)
  41. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_4, OnBarCheck )
  42. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_4, OnUpdateControlBarMenu)
  43. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_5, OnBarCheck )
  44. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_5, OnUpdateControlBarMenu)
  45. ON_REGISTERED_MESSAGE(
  46. CExtPopupMenuWnd::g_nMsgPrepareMenu,
  47. OnExtMenuPrepare
  48. )
  49. ON_REGISTERED_MESSAGE(
  50. CExtControlBar::g_nMsgDrawTrackedArea,
  51. OnDrawControlBarTrackedArea
  52. )
  53. END_MESSAGE_MAP()
  54. static UINT indicators[] =
  55. {
  56. ID_SEPARATOR,           // status line indicator
  57. ID_INDICATOR_CAPS,
  58. ID_INDICATOR_NUM,
  59. ID_INDICATOR_SCRL,
  60. };
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CMainFrame construction/destruction
  63. CMainFrame::CMainFrame()
  64. : m_rcTrackerEntireArea( 0, 0, 0, 0 )
  65. {
  66. CWinApp * pApp = ::AfxGetApp();
  67. ASSERT( pApp != NULL );
  68. ASSERT( pApp->m_pszRegistryKey != NULL );
  69. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  70. ASSERT( pApp->m_pszProfileName != NULL );
  71. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  72. if( ! g_PaintManager.PaintManagerStateLoad(
  73. pApp->m_pszRegistryKey,
  74. pApp->m_pszProfileName,
  75. pApp->m_pszProfileName
  76. )
  77. )
  78. g_PaintManager.InstallPaintManager(
  79. RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue)
  80. );
  81. // window placement persistence
  82. ::memset( &m_wpInitial, 0, sizeof(WINDOWPLACEMENT) );
  83. m_wpInitial.length = sizeof(WINDOWPLACEMENT);
  84. m_wpInitial.showCmd = SW_HIDE;
  85. CExtPopupMenuWnd::g_bMenuExpanding = false;
  86. CExtPopupMenuWnd::g_bMenuHighlightRarely = false;
  87. CBitmap _bmpPattern;
  88. if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  89. {
  90. VERIFY(
  91. m_brushTracker.CreatePatternBrush(
  92. &_bmpPattern
  93. )
  94. );
  95. } // if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  96. #ifdef _DEBUG
  97. else
  98. {
  99. ASSERT( FALSE );
  100. } // else from if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  101. #endif // _DEBUG
  102. }
  103. CMainFrame::~CMainFrame()
  104. {
  105. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  106. m_bmpTrackerCache.DeleteObject();
  107. }
  108. void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
  109. {
  110. // CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
  111. CExtControlBar::DoFrameBarCheckUpdate(
  112. this,
  113. pCmdUI,
  114. false
  115. );
  116. }
  117. BOOL CMainFrame::OnBarCheck(UINT nID)
  118. {
  119. // return CFrameWnd::OnBarCheck( nID );
  120. return
  121. CExtControlBar::DoFrameBarCheckCmd(
  122. this,
  123. nID,
  124. false
  125. );
  126. }
  127. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  128. {
  129. if( CExtNCW < CMDIFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
  130. return -1;
  131. CWinApp * pApp = ::AfxGetApp();
  132. ASSERT( pApp != NULL );
  133. ASSERT( pApp->m_pszRegistryKey != NULL );
  134. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  135. ASSERT( pApp->m_pszProfileName != NULL );
  136. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  137. ASSERT( pApp->m_pszProfileName != NULL );
  138. g_CmdManager->ProfileSetup(
  139. pApp->m_pszProfileName,
  140. GetSafeHwnd()
  141. );
  142. VERIFY(
  143. g_CmdManager->UpdateFromMenu(
  144. pApp->m_pszProfileName,
  145. IDR_MAINFRAME
  146. )
  147. );
  148. VERIFY(
  149. g_CmdManager->UpdateFromMenu(
  150. pApp->m_pszProfileName,
  151. IDR_MDITYPE
  152. )
  153. );
  154. m_wndMenuBar.SetMdiWindowPopupName( _T("Window") );
  155. if( !m_wndMenuBar.Create(
  156. NULL, // _T("Menu Bar"),
  157. this,
  158. ID_VIEW_MENUBAR
  159. )
  160. )
  161.     {
  162.         TRACE0("Failed to create menubarn");
  163.         return -1;      // failed to create
  164.     }
  165. if( !m_wndToolBar.Create(
  166. _T("Standard"),
  167. this,
  168. AFX_IDW_TOOLBAR
  169. )
  170. ||
  171. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)
  172. )
  173. {
  174. TRACE0("Failed to create toolbarn");
  175. return -1;      // fail to create
  176. }
  177. if( !m_wndToolBar1.Create(
  178. _T("ToolBar 1"),
  179. this,
  180. IDR_TOOLBAR1
  181. )
  182. ||
  183. !m_wndToolBar1.LoadToolBar(IDR_TOOLBAR1)
  184. )
  185. {
  186. TRACE0("Failed to create toolbar1n");
  187. return -1;      // fail to create
  188. }
  189. if( !m_wndToolBar2.Create(
  190. NULL,
  191. this,
  192. IDR_TOOLBAR2
  193. )
  194. ||
  195. !m_wndToolBar2.ThemeSwitcherInit()
  196. )
  197. {
  198. TRACE0("Failed to create toolbar2n");
  199. return -1;      // fail to create
  200. }
  201. if( !m_wndToolBar3.Create(
  202. _T("ToolBar 3"),
  203. this,
  204. IDR_TOOLBAR3
  205. )
  206. ||
  207. !m_wndToolBar3.LoadToolBar(IDR_TOOLBAR3)
  208. )
  209. {
  210. TRACE0("Failed to create toolbar3n");
  211. return -1;      // fail to create
  212. }
  213. if( !m_wndResizableBar0.Create(
  214. _T("Resizable Bar 0"),
  215. this,
  216. ID_VIEW_RESIZABLE_BAR_0
  217. )
  218. || !m_wndResizableBar1.Create(
  219. _T("Resizable Bar 1"),
  220. this,
  221. ID_VIEW_RESIZABLE_BAR_1
  222. )
  223. || !m_wndResizableBar2.Create(
  224. _T("Resizable Bar 2"),
  225. this,
  226. ID_VIEW_RESIZABLE_BAR_2
  227. )
  228. || !m_wndResizableBar3.Create(
  229. _T("Resizable Bar 3"),
  230. this,
  231. ID_VIEW_RESIZABLE_BAR_3
  232. )
  233. || !m_wndResizableBar4.Create(
  234. _T("Resizable Bar 4"),
  235. this,
  236. ID_VIEW_RESIZABLE_BAR_4
  237. )
  238. || !m_wndResizableBar5.Create(
  239. _T("Resizable Bar 5"),
  240. this,
  241. ID_VIEW_RESIZABLE_BAR_5
  242. )
  243. )
  244. {
  245. TRACE0("Failed to create "m_wndResizableBar"sn");
  246. return -1; // fail to create
  247. }
  248. if (!m_wndStatusBar.Create(this) ||
  249. !m_wndStatusBar.SetIndicators(indicators,
  250.   sizeof(indicators)/sizeof(UINT)))
  251. {
  252. TRACE0("Failed to create status barn");
  253. return -1;      // fail to create
  254. }
  255. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  256. if( !m_wndMdiTabs.Create(this) )
  257. {
  258. ASSERT( FALSE );
  259. return -1;
  260. }
  261. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  262.     m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  263. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  264. m_wndToolBar1.EnableDocking(CBRS_ALIGN_ANY);
  265. m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
  266. m_wndToolBar3.EnableDocking(CBRS_ALIGN_ANY);
  267. m_wndResizableBar0.EnableDocking(CBRS_ALIGN_ANY);
  268. m_wndResizableBar1.EnableDocking(CBRS_ALIGN_ANY);
  269. m_wndResizableBar2.EnableDocking(CBRS_ALIGN_ANY);
  270. m_wndResizableBar3.EnableDocking(CBRS_ALIGN_ANY);
  271. m_wndResizableBar4.EnableDocking(CBRS_ALIGN_ANY);
  272. m_wndResizableBar5.EnableDocking(CBRS_ALIGN_ANY);
  273. if( !CExtControlBar::FrameEnableDocking(this) )
  274. {
  275. ASSERT( FALSE );
  276. return -1;
  277. }
  278. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  279. if( !CExtControlBar::FrameInjectAutoHideAreas(this) )
  280. {
  281. ASSERT( FALSE );
  282. return -1;
  283. }
  284. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  285. bool bInitialFullScreenMode =
  286. pApp->GetProfileInt(
  287. _T("Full-Screen-Settings"),
  288. _T("Full-Screen-Mode"),
  289. 0
  290. )
  291. ? true : false;
  292. ASSERT( ! CExtPopupMenuWnd::g_bFullScreenMode );
  293. if( bInitialFullScreenMode )
  294. {
  295. _DoViewFullScreen( false );
  296. ASSERT( CExtPopupMenuWnd::g_bFullScreenMode );
  297. } // if( bInitialFullScreenMode )
  298. else
  299. {
  300. VERIFY( _DoBarStateSerialization(bInitialFullScreenMode,false,true) );
  301. } // else from if( bInitialFullScreenMode )
  302. return 0;
  303. }
  304. /////////////////////////////////////////////////////////////////////////////
  305. // CMainFrame diagnostics
  306. #ifdef _DEBUG
  307. void CMainFrame::AssertValid() const
  308. {
  309. CExtNCW < CMDIFrameWnd > :: AssertValid();
  310. }
  311. void CMainFrame::Dump(CDumpContext& dc) const
  312. {
  313. CExtNCW < CMDIFrameWnd > :: Dump( dc );
  314. }
  315. #endif //_DEBUG
  316. /////////////////////////////////////////////////////////////////////////////
  317. // CMainFrame message handlers
  318. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  319. {
  320. if( m_wndToolBar2.PreTranslateMessage( pMsg ) )
  321. return TRUE;
  322. if( m_wndMenuBar.TranslateMainFrameMessage( pMsg ) )
  323. return TRUE;
  324. return CExtNCW < CMDIFrameWnd > :: PreTranslateMessage( pMsg );
  325. }
  326. BOOL CMainFrame::DestroyWindow() 
  327. {
  328. CWinApp * pApp = ::AfxGetApp();
  329. ASSERT( pApp != NULL );
  330. ASSERT( pApp->m_pszRegistryKey != NULL );
  331. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  332. ASSERT( pApp->m_pszProfileName != NULL );
  333. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  334. bool bFinalFullScreenMode =
  335. CExtPopupMenuWnd::g_bFullScreenMode ? true : false;
  336. VERIFY(
  337. pApp->WriteProfileInt(
  338. _T("Full-Screen-Settings"),
  339. _T("Full-Screen-Mode"),
  340. bFinalFullScreenMode ? 1 : 0
  341. )
  342. );
  343. VERIFY( _DoBarStateSerialization(bFinalFullScreenMode,true) );
  344. VERIFY(
  345. g_PaintManager.PaintManagerStateSave(
  346. pApp->m_pszRegistryKey,
  347. pApp->m_pszProfileName,
  348. pApp->m_pszProfileName
  349. )
  350. );
  351. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  352. return CExtNCW < CMDIFrameWnd > :: DestroyWindow();
  353. }
  354. void CMainFrame::ActivateFrame(int nCmdShow) 
  355. {
  356. // window placement persistence
  357. if( m_wpInitial.showCmd != SW_HIDE )
  358. {
  359. SetWindowPlacement( &m_wpInitial );
  360. CExtNCW < CMDIFrameWnd > :: ActivateFrame( m_wpInitial.showCmd );
  361. m_wpInitial.showCmd = SW_HIDE;
  362. return;
  363. }
  364. CExtNCW < CMDIFrameWnd > :: ActivateFrame( nCmdShow );
  365. }
  366. void CMainFrame::OnViewFullScreen() 
  367. {
  368. _DoViewFullScreen( true );
  369. }
  370. void CMainFrame::_DoViewFullScreen( bool bSavePrevLayout )
  371. {
  372. if( CExtPopupMenuWnd::g_bFullScreenMode )
  373. {
  374. CExtPopupMenuWnd::g_bFullScreenMode = false;
  375. if( bSavePrevLayout )
  376. {
  377. VERIFY( _DoBarStateSerialization(true,true) );
  378. }
  379. SetWindowPlacement( &m_wpSavedBeforeFullScreen );
  380. VERIFY( _DoBarStateSerialization(false,false) );
  381. } // if( CExtPopupMenuWnd::g_bFullScreenMode )
  382. else
  383. {
  384. m_wpSavedBeforeFullScreen.length = sizeof(WINDOWPLACEMENT);
  385. GetWindowPlacement( &m_wpSavedBeforeFullScreen );
  386. CRect rcDesktop;
  387.   ::GetWindowRect( ::GetDesktopWindow(), &rcDesktop );
  388. //  CExtPaintManager::monitor_parms_t _mp;
  389. //  CExtPaintManager::stat_GetMonitorParms( _mp, m_hWnd );
  390. //  rcDesktop = _mp.m_rcMonitor;
  391. CRect rcMdiClient;
  392. GetClientRect( &rcMdiClient );
  393. ClientToScreen( &rcMdiClient );
  394. CRect rcMdiFrame;
  395. GetWindowRect( &rcMdiFrame );
  396. rcMdiFrame.InflateRect(
  397. rcMdiClient.left-rcDesktop.left,
  398. rcMdiClient.top-rcDesktop.top,
  399. rcDesktop.right-rcMdiClient.right,
  400. rcDesktop.bottom-rcMdiClient.bottom
  401. );
  402. WINDOWPLACEMENT wpFullScreen;
  403. ::memcpy( &wpFullScreen, &m_wpSavedBeforeFullScreen, sizeof(WINDOWPLACEMENT) );
  404. wpFullScreen.showCmd = SW_SHOWNORMAL;
  405. #if (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  406. CSize _sizeFrameBorder(
  407. ::GetSystemMetrics(SM_CXFIXEDFRAME)-1,
  408. ::GetSystemMetrics(SM_CYFIXEDFRAME)-1
  409. );
  410. rcMdiFrame.InflateRect( _sizeFrameBorder );
  411. #endif // (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  412. wpFullScreen.rcNormalPosition = rcMdiFrame;
  413. wpFullScreen.ptMaxPosition = rcMdiFrame.TopLeft();
  414. m_sizeFullScreenDesktopDifference =
  415. rcMdiFrame.Size() - rcDesktop.Size();
  416. CExtPopupMenuWnd::g_bFullScreenMode = true;
  417. if( bSavePrevLayout )
  418. {
  419. VERIFY( _DoBarStateSerialization(false,true) );
  420. }
  421. VERIFY( _DoBarStateSerialization(true,false) );
  422. SetWindowPlacement( &wpFullScreen );
  423.   //SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOSENDCHANGING|SWP_NOREDRAW );
  424.   //SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
  425. } // else from if( CExtPopupMenuWnd::g_bFullScreenMode )
  426. RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN );
  427. }
  428. void CMainFrame::OnUpdateViewFullScreen(CCmdUI* pCmdUI) 
  429. {
  430. pCmdUI->SetCheck( CExtPopupMenuWnd::g_bFullScreenMode );
  431. }
  432. LRESULT CMainFrame::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
  433. {
  434. switch( message )
  435. {
  436. case WM_GETMINMAXINFO:
  437. if( CExtPopupMenuWnd::g_bFullScreenMode )
  438. {
  439. LPMINMAXINFO pMMI = (LPMINMAXINFO)lParam;
  440. ASSERT( pMMI != NULL );
  441. _DoFullScreenGetMinMaxInfo( pMMI );
  442. return 0;
  443. }
  444. break;
  445. }
  446. LRESULT lResult = CExtNCW < CMDIFrameWnd > :: WindowProc( message, wParam, lParam );
  447. return lResult;
  448. }
  449. bool CMainFrame::_DoBarStateSerialization(
  450. bool bFullScreenState,
  451. bool bSaveState,
  452. bool bInitialLoad // = false
  453. )
  454. {
  455. CWinApp * pApp = ::AfxGetApp();
  456. ASSERT( pApp != NULL );
  457. ASSERT( pApp->m_pszRegistryKey != NULL );
  458. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  459. ASSERT( pApp->m_pszProfileName != NULL );
  460. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  461. CString sSpan = pApp->m_pszProfileName;
  462. sSpan += _T("\");
  463. sSpan +=
  464. bFullScreenState
  465. ? _T("BarPos-FullScreen")
  466. : _T("BarPos-Normal")
  467. ;
  468. RecalcLayout();
  469. bool bRetVal = false;
  470. if( bSaveState )
  471. bRetVal =
  472. CExtControlBar::ProfileBarStateSave(
  473. this,
  474. pApp->m_pszRegistryKey,
  475. pApp->m_pszProfileName,
  476. (LPCTSTR)sSpan
  477. );
  478. else
  479. bRetVal =
  480. CExtControlBar::ProfileBarStateLoad(
  481. this,
  482. pApp->m_pszRegistryKey,
  483. pApp->m_pszProfileName,
  484. (LPCTSTR)sSpan,
  485. &m_wpInitial
  486. );
  487. if( !bSaveState )
  488. {
  489. if( !bRetVal )
  490. {
  491. _DoInitialDock( bFullScreenState );
  492. bRetVal = true;
  493. } // if( !bRetVal )
  494. else if( (!bInitialLoad) && (!CExtPopupMenuWnd::g_bFullScreenMode) )
  495. {
  496. ActivateFrame( m_wpInitial.showCmd );
  497. RedrawWindow( NULL, NULL,
  498. RDW_INVALIDATE|RDW_UPDATENOW
  499. |RDW_ERASE|RDW_ERASENOW
  500. |RDW_FRAME|RDW_ALLCHILDREN
  501. );
  502. } // else if( (!bInitialLoad) && (!CExtPopupMenuWnd::g_bFullScreenMode) )
  503. if( !bInitialLoad )
  504. m_wpInitial.showCmd = SW_HIDE;
  505. } // if( !bSaveState )
  506. return bRetVal;
  507. }
  508. void CMainFrame::_DoInitialDock(
  509. bool bFullScreenState
  510. )
  511. {
  512. if( bFullScreenState )
  513. {
  514. CRect wrAlreadyDockedBar;
  515. DockControlBar(&m_wndMenuBar);
  516. DockControlBar(&m_wndToolBar);
  517. DockControlBar(&m_wndToolBar1,AFX_IDW_DOCKBAR_LEFT);
  518. DockControlBar(&m_wndToolBar2,AFX_IDW_DOCKBAR_RIGHT);
  519. RecalcLayout();
  520. FloatControlBar(&m_wndToolBar3,CPoint(400,50));
  521. RecalcLayout();
  522. static CSize
  523. _sizeInitH( 250, 100 ),
  524. _sizeInitV( 100, 250 ),
  525. _sizeInitF( 250, 250 );
  526. m_wndResizableBar0.SetInitDesiredSizeHorizontal( _sizeInitH );
  527. m_wndResizableBar0.SetInitDesiredSizeVertical( _sizeInitV );
  528. m_wndResizableBar0.SetInitDesiredSizeFloating( _sizeInitF );
  529. m_wndResizableBar1.SetInitDesiredSizeHorizontal( _sizeInitH );
  530. m_wndResizableBar1.SetInitDesiredSizeVertical( _sizeInitV );
  531. m_wndResizableBar1.SetInitDesiredSizeFloating( _sizeInitF );
  532. m_wndResizableBar2.SetInitDesiredSizeHorizontal( _sizeInitH );
  533. m_wndResizableBar2.SetInitDesiredSizeVertical( _sizeInitV );
  534. m_wndResizableBar2.SetInitDesiredSizeFloating( _sizeInitF );
  535. m_wndResizableBar3.SetInitDesiredSizeHorizontal( _sizeInitH );
  536. m_wndResizableBar3.SetInitDesiredSizeVertical( _sizeInitV );
  537. m_wndResizableBar3.SetInitDesiredSizeFloating( _sizeInitF );
  538. m_wndResizableBar4.SetInitDesiredSizeHorizontal( _sizeInitH );
  539. m_wndResizableBar4.SetInitDesiredSizeVertical( _sizeInitV );
  540. m_wndResizableBar4.SetInitDesiredSizeFloating( _sizeInitF );
  541. m_wndResizableBar5.SetInitDesiredSizeHorizontal( _sizeInitH );
  542. m_wndResizableBar5.SetInitDesiredSizeVertical( _sizeInitV );
  543. m_wndResizableBar5.SetInitDesiredSizeFloating( _sizeInitF );
  544. m_wndResizableBar0.DockControlBar(AFX_IDW_DOCKBAR_RIGHT, 1,this);
  545. m_wndResizableBar1.DockControlBar(AFX_IDW_DOCKBAR_BOTTOM,2,this);
  546. m_wndResizableBar2.DockControlBar(AFX_IDW_DOCKBAR_RIGHT, 3,this);
  547. m_wndResizableBar3.DockControlBar(AFX_IDW_DOCKBAR_BOTTOM,4,this);
  548. m_wndResizableBar4.DockControlBar(AFX_IDW_DOCKBAR_RIGHT, 5,this);
  549. m_wndResizableBar5.DockControlBar(AFX_IDW_DOCKBAR_BOTTOM,6,this);
  550. ShowControlBar(&m_wndStatusBar,FALSE,TRUE);
  551. ShowControlBar(&m_wndMenuBar,FALSE,TRUE);
  552. ShowControlBar(&m_wndToolBar,FALSE,TRUE);
  553. ShowControlBar(&m_wndToolBar1,FALSE,TRUE);
  554. ShowControlBar(&m_wndToolBar2,FALSE,TRUE);
  555. ShowControlBar(&m_wndResizableBar0,FALSE,TRUE);
  556. ShowControlBar(&m_wndResizableBar1,FALSE,TRUE);
  557. ShowControlBar(&m_wndResizableBar2,FALSE,TRUE);
  558. ShowControlBar(&m_wndResizableBar3,FALSE,TRUE);
  559. ShowControlBar(&m_wndResizableBar4,FALSE,TRUE);
  560. ShowControlBar(&m_wndResizableBar5,FALSE,TRUE);
  561. RecalcLayout();
  562. } // if( bFullScreenState )
  563. else
  564. {
  565. CRect wrAlreadyDockedBar;
  566. DockControlBar(&m_wndMenuBar);
  567. DockControlBar(&m_wndToolBar);
  568. RecalcLayout();
  569. m_wndToolBar.GetWindowRect( &wrAlreadyDockedBar );
  570. wrAlreadyDockedBar.OffsetRect( 1, 0 );
  571. DockControlBar(&m_wndToolBar1,AFX_IDW_DOCKBAR_TOP,&wrAlreadyDockedBar);
  572. DockControlBar(&m_wndToolBar2,AFX_IDW_DOCKBAR_RIGHT);
  573. RecalcLayout();
  574. m_wndToolBar1.GetWindowRect( &wrAlreadyDockedBar );
  575. wrAlreadyDockedBar.OffsetRect( 1, 0 );
  576. DockControlBar(&m_wndToolBar3,AFX_IDW_DOCKBAR_TOP,&wrAlreadyDockedBar);
  577. RecalcLayout();
  578. static CSize
  579. _sizeInitH( 250, 100 ),
  580. _sizeInitV( 100, 250 ),
  581. _sizeInitF( 250, 250 );
  582. m_wndResizableBar0.SetInitDesiredSizeHorizontal( _sizeInitH );
  583. m_wndResizableBar0.SetInitDesiredSizeVertical( _sizeInitV );
  584. m_wndResizableBar0.SetInitDesiredSizeFloating( _sizeInitF );
  585. m_wndResizableBar1.SetInitDesiredSizeHorizontal( _sizeInitH );
  586. m_wndResizableBar1.SetInitDesiredSizeVertical( _sizeInitV );
  587. m_wndResizableBar1.SetInitDesiredSizeFloating( _sizeInitF );
  588. m_wndResizableBar2.SetInitDesiredSizeHorizontal( _sizeInitH );
  589. m_wndResizableBar2.SetInitDesiredSizeVertical( _sizeInitV );
  590. m_wndResizableBar2.SetInitDesiredSizeFloating( _sizeInitF );
  591. m_wndResizableBar3.SetInitDesiredSizeHorizontal( _sizeInitH );
  592. m_wndResizableBar3.SetInitDesiredSizeVertical( _sizeInitV );
  593. m_wndResizableBar3.SetInitDesiredSizeFloating( _sizeInitF );
  594. m_wndResizableBar4.SetInitDesiredSizeHorizontal( _sizeInitH );
  595. m_wndResizableBar4.SetInitDesiredSizeVertical( _sizeInitV );
  596. m_wndResizableBar4.SetInitDesiredSizeFloating( _sizeInitF );
  597. m_wndResizableBar5.SetInitDesiredSizeHorizontal( _sizeInitH );
  598. m_wndResizableBar5.SetInitDesiredSizeVertical( _sizeInitV );
  599. m_wndResizableBar5.SetInitDesiredSizeFloating( _sizeInitF );
  600. m_wndResizableBar0.DockControlBar(AFX_IDW_DOCKBAR_LEFT,1,this,false);
  601. m_wndResizableBar0.DockControlBar(&m_wndResizableBar1,true,true);
  602. m_wndResizableBar2.DockControlBar(AFX_IDW_DOCKBAR_RIGHT,1,this,false);
  603. m_wndResizableBar2.DockControlBar(&m_wndResizableBar3,false,true);
  604. m_wndResizableBar2.GetParentFrame()->RecalcLayout();
  605. m_wndResizableBar3.DockControlBar(&m_wndResizableBar4,false,true);
  606. m_wndResizableBar2.GetParentFrame()->RecalcLayout();
  607. m_wndResizableBar0.DockControlBar(&m_wndResizableBar5,false,true);
  608. RecalcLayout();
  609. } // else from if( bFullScreenState )
  610. }
  611. void CMainFrame::_DoFullScreenGetMinMaxInfo( LPMINMAXINFO lpMMI )
  612. {
  613. ASSERT( CExtPopupMenuWnd::g_bFullScreenMode );
  614. CRect rcDesktop;
  615. ::GetWindowRect( ::GetDesktopWindow(), &rcDesktop );
  616. //  CExtPaintManager::monitor_parms_t _mp;
  617. //  CExtPaintManager::stat_GetMonitorParms( _mp, m_hWnd );
  618. //  rcDesktop = _mp.m_rcMonitor;
  619. #if (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  620. CSize _sizeFrameBorder(
  621. ::GetSystemMetrics(SM_CXFIXEDFRAME)-1,
  622. ::GetSystemMetrics(SM_CYFIXEDFRAME)-1
  623. );
  624. #endif // (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  625. CSize _size =
  626. rcDesktop.Size()
  627. + m_sizeFullScreenDesktopDifference
  628. #if (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  629. + _sizeFrameBorder + _sizeFrameBorder
  630. #endif // (defined __REMOVE_THIN_FULLSCREEN_BORDER)
  631. ;
  632. lpMMI->ptMaxSize.x = _size.cx;
  633. lpMMI->ptMaxSize.y = _size.cy;
  634. lpMMI->ptMaxTrackSize.x = _size.cx;
  635. lpMMI->ptMaxTrackSize.y = _size.cy;
  636. }
  637. void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) 
  638. {
  639. if( CExtPopupMenuWnd::g_bFullScreenMode )
  640. {
  641. switch( nID )
  642. {
  643. case SC_SIZE:
  644. case SC_MOVE:
  645. case SC_MAXIMIZE:
  646. {
  647. CMenu * pSysMenu =
  648. GetSystemMenu( FALSE );
  649. if( pSysMenu == NULL )
  650. return;
  651. CString strMenuText;
  652. pSysMenu->GetMenuString( nID, strMenuText, MF_BYCOMMAND );
  653. strMenuText.Replace( _T("&"), _T("") );
  654. CString strMsg;
  655. strMsg.Format(
  656. _T("The "%s" system command is not available in the Full-Screen mode."),
  657. strMenuText
  658. );
  659. ::AfxMessageBox( strMsg, MB_OK|MB_ICONINFORMATION );
  660. }
  661. return;
  662. } // switch( nID )
  663. } // if( CExtPopupMenuWnd::g_bFullScreenMode )
  664. CExtNCW < CMDIFrameWnd > :: OnSysCommand( nID, lParam );
  665. }
  666. LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
  667. {
  668. wParam;
  669. lParam;
  670. //////////////////////////////////////////////////////////////////////////
  671. // Add "Windows..." command
  672. //////////////////////////////////////////////////////////////////////////
  673. CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
  674. reinterpret_cast
  675. < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
  676. ( wParam );
  677. ASSERT( pData != NULL );
  678. CExtPopupMenuWnd * pPopup = pData->m_pPopup;
  679. ASSERT( pPopup != NULL );
  680. INT nItemPos;
  681. INT nNewPos = -1;
  682. nItemPos = pPopup->ItemFindPosForCmdID( __ID_MDIWND_DLGWINDOWS );
  683. if( nItemPos > 0 )
  684. {
  685. // "More Windows..." command found
  686. pPopup->ItemRemove( nItemPos );
  687. nNewPos = nItemPos;
  688. }
  689. else
  690. {
  691. int nMaxCmdID = 0;
  692. for( int nCmdID = __ID_MDIWNDLIST_FIRST; nCmdID <= __ID_MDIWNDLIST_LAST; nCmdID++ ){
  693. nItemPos = pPopup->ItemFindPosForCmdID( nCmdID );
  694. if( nItemPos > 0 ){
  695. if( nCmdID > nMaxCmdID ){
  696. nMaxCmdID = nCmdID;
  697. nNewPos = nItemPos;
  698. }
  699. }
  700. }
  701. if( nNewPos > 0 ){
  702. pPopup->ItemInsert(
  703. (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR,
  704. ++nNewPos
  705. );
  706. nNewPos++;
  707. }
  708. }
  709. if( nNewPos > 0 )
  710. {
  711. UINT nCmdID = ID_WINDOWS_LIST;
  712. CExtCmdItem * pCmdItem =
  713. g_CmdManager->CmdGetPtr(
  714. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ),
  715. nCmdID
  716. );
  717. if( pCmdItem == NULL ){
  718. pCmdItem = 
  719. g_CmdManager->CmdAllocPtr( 
  720. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), 
  721. nCmdID 
  722. );
  723. }
  724. ASSERT( pCmdItem != NULL );
  725. if( pCmdItem != NULL )
  726. {
  727. CExtSafeString sMoreWindows(_T("Windows..."));
  728. CExtSafeString sManageWindows(_T("Manages the currently open windows"));
  729. pCmdItem->m_sMenuText = sMoreWindows;
  730. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  731. pCmdItem->m_sTipTool = sManageWindows;
  732. pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
  733. pCmdItem->StateSetBasic( true );
  734. pPopup->ItemInsert(
  735. nCmdID,
  736. nNewPos,
  737. sMoreWindows,
  738. NULL,
  739. m_hWnd
  740. );
  741. }
  742. }
  743. return 1;
  744. }
  745. LRESULT CMainFrame::OnDrawControlBarTrackedArea(WPARAM wParam, LPARAM lParam)
  746. {
  747. lParam;
  748. CExtControlBar::MsgDrawTrackedAreaData_t * pMsgDrawTrackedAreaData =
  749. (CExtControlBar::MsgDrawTrackedAreaData_t *)wParam;
  750. ASSERT( pMsgDrawTrackedAreaData != NULL );
  751. ASSERT_VALID( (&(pMsgDrawTrackedAreaData->m_wndBar)) );
  752. ASSERT(
  753. pMsgDrawTrackedAreaData->m_wndBar.GetSafeHwnd() != NULL
  754. && ::IsWindow( pMsgDrawTrackedAreaData->m_wndBar.GetSafeHwnd() )
  755. );
  756. ASSERT( pMsgDrawTrackedAreaData->m_dcDraw.GetSafeHdc() != NULL );
  757. pMsgDrawTrackedAreaData->m_bMessageHandled = true;
  758. if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  759. {
  760. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  761. {
  762. CDC dcSrc;
  763. if( dcSrc.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  764. {
  765. CBitmap * pOldBitmap = dcSrc.SelectObject( &m_bmpTrackerCache );
  766. pMsgDrawTrackedAreaData->m_dcDraw.BitBlt(
  767. m_rcTrackerEntireArea.left,
  768. m_rcTrackerEntireArea.top,
  769. m_rcTrackerEntireArea.Width(),
  770. m_rcTrackerEntireArea.Height(),
  771. &dcSrc,
  772. 0,
  773. 0,
  774. SRCCOPY
  775. );
  776. dcSrc.SelectObject( pOldBitmap );
  777. dcSrc.DeleteDC();
  778. } // if( dcSrc.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  779. m_bmpTrackerCache.DeleteObject(); // no longer needed
  780. } // if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  781. } // if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  782. else
  783. {
  784. m_rcTrackerEntireArea = pMsgDrawTrackedAreaData->m_rcDrawArea;
  785. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  786. m_bmpTrackerCache.DeleteObject();
  787. CDC dcDst;
  788. if( dcDst.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  789. {
  790. if( m_bmpTrackerCache.CreateCompatibleBitmap(
  791. &(pMsgDrawTrackedAreaData->m_dcDraw),
  792. m_rcTrackerEntireArea.Width(),
  793. m_rcTrackerEntireArea.Height()
  794. )
  795. )
  796. {
  797. CBitmap * pOldBitmap = dcDst.SelectObject( &m_bmpTrackerCache );
  798. dcDst.BitBlt(
  799. 0,
  800. 0,
  801. m_rcTrackerEntireArea.Width(),
  802. m_rcTrackerEntireArea.Height(),
  803. &(pMsgDrawTrackedAreaData->m_dcDraw),
  804. m_rcTrackerEntireArea.left,
  805. m_rcTrackerEntireArea.top,
  806. SRCCOPY
  807. );
  808. dcDst.SelectObject( pOldBitmap );
  809. } // if( m_bmpTrackerCache.CreateCompatibleBitmap( ...
  810. dcDst.DeleteDC();
  811. } // if( dcDst.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  812. HBRUSH hBrush = (HBRUSH)
  813. m_brushTracker.GetSafeHandle();
  814. if( hBrush == NULL )
  815. hBrush = (HBRUSH)
  816. ::GetStockObject( WHITE_BRUSH );
  817. pMsgDrawTrackedAreaData->Draw(
  818. hBrush,
  819. PATCOPY
  820. );
  821. } // else from if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  822. return 0L;
  823. }
  824. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  825. {
  826. if( nCode == CN_COMMAND )
  827. {
  828. if( nID == ID_WINDOWS_LIST )
  829. {
  830. CMyMdiWindowsListDlg dlgMdiWindowsList( this );
  831. dlgMdiWindowsList.DoModal();
  832. return TRUE;
  833. }
  834. }
  835. return CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
  836. }