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

界面编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "ThemeColorizer.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. IMPLEMENT_SERIAL( CColorizedThemeOffice2003, CExtPaintManagerOffice2003, VERSIONABLE_SCHEMA|1 );
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CMainFrame
  14. IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
  15. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  16. //{{AFX_MSG_MAP(CMainFrame)
  17. ON_WM_CREATE()
  18. ON_WM_SETFOCUS()
  19. //}}AFX_MSG_MAP
  20. ON_COMMAND_EX( ID_VIEW_MENUBAR, OnBarCheck )
  21. ON_UPDATE_COMMAND_UI( ID_VIEW_MENUBAR, OnUpdateControlBarMenu )
  22. ON_COMMAND_EX( ID_VIEW_TOOLBAR, OnBarCheck )
  23. ON_UPDATE_COMMAND_UI( ID_VIEW_TOOLBAR, OnUpdateControlBarMenu )
  24. ON_COMMAND_EX( IDR_TOOLBAR_SEEK, OnBarCheck )
  25. ON_UPDATE_COMMAND_UI( IDR_TOOLBAR_SEEK, OnUpdateControlBarMenu )
  26. ON_COMMAND_EX( IDR_TOOLBAR_ZOOM, OnBarCheck )
  27. ON_UPDATE_COMMAND_UI( IDR_TOOLBAR_ZOOM, OnUpdateControlBarMenu )
  28. ON_COMMAND_EX(ID_VIEW_IEDBAR, OnBarCheck )
  29. ON_UPDATE_COMMAND_UI(ID_VIEW_IEDBAR, OnUpdateControlBarMenu)
  30. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_0, OnBarCheck )
  31. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_0, OnUpdateControlBarMenu)
  32. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_1, OnBarCheck )
  33. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_1, OnUpdateControlBarMenu)
  34. ON_COMMAND_EX(ID_VIEW_RESIZABLE_BAR_2, OnBarCheck )
  35. ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLE_BAR_2, OnUpdateControlBarMenu)
  36. ON_REGISTERED_MESSAGE(
  37. CExtControlBar::g_nMsgDrawTrackedArea,
  38. OnDrawControlBarTrackedArea
  39. )
  40. END_MESSAGE_MAP()
  41. static UINT indicators[] =
  42. {
  43. ID_SEPARATOR,           // status line indicator
  44. ID_INDICATOR_CAPS,
  45. ID_INDICATOR_NUM,
  46. ID_INDICATOR_SCRL,
  47. };
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMainFrame construction/destruction
  50. CMainFrame::CMainFrame()
  51. : m_pPaintManager(NULL)
  52. , m_rcTrackerEntireArea( 0, 0, 0, 0 )
  53. {
  54. CWinApp * pApp = ::AfxGetApp();
  55. ASSERT( pApp != NULL );
  56. ASSERT( pApp->m_pszRegistryKey != NULL );
  57. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  58. ASSERT( pApp->m_pszProfileName != NULL );
  59. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  60. if( ! g_PaintManager.PaintManagerStateLoad(
  61. pApp->m_pszRegistryKey,
  62. pApp->m_pszProfileName,
  63. pApp->m_pszProfileName
  64. )
  65. )
  66. {
  67. m_pPaintManager = new CColorizedThemeOffice2003;
  68. g_PaintManager.InstallPaintManager( m_pPaintManager );
  69. }
  70. else
  71. {
  72. m_pPaintManager =
  73. STATIC_DOWNCAST(
  74. CColorizedThemeOffice2003,
  75. g_PaintManager.GetPM()
  76. );
  77. }
  78. // window placement persistence
  79. ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
  80. m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
  81. m_dataFrameWP.showCmd = SW_HIDE;
  82. m_pWndView = NULL;
  83. CBitmap _bmpPattern;
  84. if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  85. {
  86. VERIFY(
  87. m_brushTracker.CreatePatternBrush(
  88. &_bmpPattern
  89. )
  90. );
  91. } // if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  92. #ifdef _DEBUG
  93. else
  94. {
  95. ASSERT( FALSE );
  96. } // else from if( _bmpPattern.LoadBitmap(IDB_BITMAP_TRACKER_PATTERN) )
  97. #endif // _DEBUG
  98. }
  99. CMainFrame::~CMainFrame()
  100. {
  101. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  102. m_bmpTrackerCache.DeleteObject();
  103. }
  104. void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
  105. {
  106. // CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
  107. CExtControlBar::DoFrameBarCheckUpdate(
  108. this,
  109. pCmdUI,
  110. false
  111. );
  112. }
  113. BOOL CMainFrame::OnBarCheck(UINT nID)
  114. {
  115. // return CFrameWnd::OnBarCheck( nID );
  116. return
  117. CExtControlBar::DoFrameBarCheckCmd(
  118. this,
  119. nID,
  120. false
  121. );
  122. }
  123. static UINT g_statBasicCommands[] =
  124. {
  125. ID_APP_ABOUT,
  126. ID_APP_EXIT,
  127. ID_FILE_NEW,
  128. ID_FILE_OPEN,
  129. ID_FILE_SAVE,
  130. ID_EDIT_CUT,
  131. ID_EDIT_COPY,
  132. ID_EDIT_PASTE,
  133. ID_VIEW_MENUBAR,
  134. ID_VIEW_TOOLBAR,
  135. ID_VIEW_STATUS_BAR,
  136. IDR_TOOLBAR_SEEK,
  137. IDR_TOOLBAR_ZOOM,
  138. ID_VIEW_IEDBAR,
  139. ID_IED_TOOL_RECT_SELECTION,
  140. ID_IED_TOOL_COLOR_SELECTION,
  141. ID_IED_TOOL_FILL,
  142. ID_IED_TOOL_MAGNIFICATION,
  143. ID_IED_TOOL_PENCIL,
  144. ID_IED_TOOL_BRUSH,
  145. ID_IED_TOOL_AIR_BRUSH,
  146. ID_IED_TOOL_LINE,
  147. ID_IED_TOOL_RECTANGLE,
  148. ID_IED_TOOL_ROUNDED_RECTANGLE,
  149. ID_IED_TOOL_ELLIPSE,            
  150. ID_IED_TOOL_MAGNIFICATION_01X,  
  151. ID_IED_TOOL_MAGNIFICATION_02X,  
  152. ID_IED_TOOL_MAGNIFICATION_03X,  
  153. ID_IED_TOOL_MAGNIFICATION_04X,  
  154. ID_IED_TOOL_MAGNIFICATION_05X,  
  155. ID_IED_TOOL_MAGNIFICATION_06X,  
  156. ID_IED_TOOL_MAGNIFICATION_07X,  
  157. ID_IED_TOOL_MAGNIFICATION_08X,  
  158. ID_IED_TOOL_MAGNIFICATION_09X,  
  159. ID_IED_TOOL_MAGNIFICATION_10X,  
  160. ID_IED_TOOL_MAGNIFICATION_11X,  
  161. ID_IED_TOOL_MAGNIFICATION_12X,  
  162. ID_IED_TOOL_MAGNIFICATION_13X,  
  163. ID_IED_TOOL_MAGNIFICATION_14X,  
  164. ID_IED_TOOL_MAGNIFICATION_15X,  
  165. ID_IED_TOOL_MAGNIFICATION_16X,  
  166. ID_IED_TOOL_BRUSH_CIRCLE_SMALL, 
  167. ID_IED_TOOL_BRUSH_CIRCLE_MEDIUM,
  168. ID_IED_TOOL_BRUSH_SQUARE_SMALL, 
  169. ID_IED_TOOL_BRUSH_SQUARE_MEDIUM,
  170. ID_IED_TOOL_BRUSH_LINE_LD_SMALL,
  171. ID_IED_TOOL_BRUSH_LINE_LD_MEDIUM,
  172. ID_IED_TOOL_BRUSH_LINE_LD_LARGE, 
  173. ID_IED_TOOL_BRUSH_LINE_RD_SMALL, 
  174. ID_IED_TOOL_BRUSH_LINE_RD_MEDIUM,
  175. ID_IED_TOOL_BRUSH_LINE_RD_LARGE, 
  176. ID_IED_TOOL_AIR_BRUSH_SMALL,     
  177. ID_IED_TOOL_AIR_BRUSH_MEDIUM,    
  178. ID_IED_TOOL_AIR_BRUSH_LARGE,     
  179. ID_IED_TOOL_LINE_CIRCLE_SMALL,   
  180. ID_IED_TOOL_LINE_CIRCLE_MEDIUM,  
  181. ID_IED_TOOL_LINE_SQUARE_SMALL,   
  182. ID_IED_TOOL_LINE_SQUARE_MEDIUM,  
  183. ID_IED_TOOL_LINE_LINE_LD_SMALL,  
  184. ID_IED_TOOL_LINE_LINE_LD_MEDIUM, 
  185. ID_IED_TOOL_LINE_LINE_LD_LARGE,  
  186. ID_IED_TOOL_LINE_LINE_RD_SMALL,  
  187. ID_IED_TOOL_LINE_LINE_RD_MEDIUM, 
  188. ID_IED_TOOL_LINE_LINE_RD_LARGE,  
  189. ID_IED_TOOL_RECTANGLE_SMALLER,   
  190. ID_IED_TOOL_RECTANGLE_SMALL,     
  191. ID_IED_TOOL_RECTANGLE_LARGE,     
  192. ID_IED_TOOL_OUTLINED_RECTANGLE_SMALLER,
  193. ID_IED_TOOL_OUTLINED_RECTANGLE_SMALL,
  194. ID_IED_TOOL_OUTLINED_RECTANGLE_LARGE,
  195. ID_IED_TOOL_ROUNDED_RECTANGLE_SMALLER,
  196. ID_IED_TOOL_ROUNDED_RECTANGLE_SMALL,
  197. ID_IED_TOOL_ROUNDED_RECTANGLE_LARGE,
  198. ID_IED_TOOL_ELLIPSE_SMALLER,
  199. ID_IED_TOOL_ELLIPSE_SMALL,
  200. ID_IED_TOOL_ELLIPSE_LARGE,  
  201. ID_IED_TOOL_OUTLINED_ROUNDED_RECTANGLE_SMALLER,
  202. ID_IED_TOOL_OUTLINED_ROUNDED_RECTANGLE_SMALL,
  203. ID_IED_TOOL_OUTLINED_ROUNDED_RECTANGLE_LARGE,
  204. ID_IED_TOOL_OUTLINED_ELLIPSE_SMALLER,
  205. ID_IED_TOOL_OUTLINED_ELLIPSE_SMALL,
  206. ID_IED_TOOL_OUTLINED_ELLIPSE_LARGE,
  207. ID_VIEW_RESIZABLE_BAR_0,
  208. ID_VIEW_RESIZABLE_BAR_1,
  209. ID_VIEW_RESIZABLE_BAR_2,
  210. 0, // end of list
  211. };
  212. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  213. {
  214. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  215. return -1;
  216. // create a view to occupy the client area of the frame
  217. m_pWndView = new CChildFormView;
  218. if (!m_pWndView->Create(
  219. NULL, 
  220. NULL, 
  221. AFX_WS_DEFAULT_VIEW, 
  222. CRect(0, 0, 0, 0), 
  223. this, 
  224. AFX_IDW_PANE_FIRST, 
  225. NULL)
  226. )
  227. {
  228. TRACE0("Failed to create view windown");
  229. return -1;
  230. }
  231. CWinApp * pApp = ::AfxGetApp();
  232. ASSERT( pApp != NULL );
  233. ASSERT( pApp->m_pszRegistryKey != NULL );
  234. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  235. ASSERT( pApp->m_pszProfileName != NULL );
  236. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  237. ASSERT( pApp->m_pszProfileName != NULL );
  238. HICON hIcon = pApp->LoadIcon( IDR_MAINFRAME );
  239. ASSERT( hIcon != NULL );
  240. SetIcon( hIcon, TRUE );
  241. SetIcon( hIcon, FALSE );
  242. g_CmdManager->ProfileSetup(
  243. pApp->m_pszProfileName,
  244. GetSafeHwnd()
  245. );
  246. VERIFY(
  247. g_CmdManager->UpdateFromMenu(
  248. pApp->m_pszProfileName,
  249. IDR_MAINFRAME
  250. )
  251. );
  252. VERIFY(
  253. g_CmdManager->UpdateFromMenu(
  254. pApp->m_pszProfileName,
  255. IDR_IED_MENU_MAGNIFICATION
  256. )
  257. );
  258. VERIFY(
  259. g_CmdManager->UpdateFromMenu(
  260. pApp->m_pszProfileName,
  261. IDR_IED_MENU_BRUSH
  262. )
  263. );
  264. VERIFY(
  265. g_CmdManager->UpdateFromMenu(
  266. pApp->m_pszProfileName,
  267. IDR_IED_MENU_AIR_BRUSH
  268. )
  269. );
  270. VERIFY(
  271. g_CmdManager->UpdateFromMenu(
  272. pApp->m_pszProfileName,
  273. IDR_IED_MENU_LINE
  274. )
  275. );
  276. VERIFY(
  277. g_CmdManager->UpdateFromMenu(
  278. pApp->m_pszProfileName,
  279. IDR_IED_MENU_RECTANGLE
  280. )
  281. );
  282. VERIFY(
  283. g_CmdManager->UpdateFromMenu(
  284. pApp->m_pszProfileName,
  285. IDR_IED_MENU_OUTLINED_RECTANGLE
  286. )
  287. );
  288. VERIFY(
  289. g_CmdManager->UpdateFromMenu(
  290. pApp->m_pszProfileName,
  291. IDR_IED_MENU_ROUNDED_RECTANGLE
  292. )
  293. );
  294. VERIFY(
  295. g_CmdManager->UpdateFromMenu(
  296. pApp->m_pszProfileName,
  297. IDR_IED_MENU_ROUNDED_OUTLINED_RECTANGLE
  298. )
  299. );
  300. VERIFY(
  301. g_CmdManager->UpdateFromMenu(
  302. pApp->m_pszProfileName,
  303. IDR_IED_MENU_ELLIPSE
  304. )
  305. );
  306. VERIFY(
  307. g_CmdManager->UpdateFromMenu(
  308. pApp->m_pszProfileName,
  309. IDR_IED_MENU_OUTLINED_ELLIPSE
  310. )
  311. );
  312. VERIFY(
  313. g_CmdManager->UpdateFromToolBar(
  314. pApp->m_pszProfileName,
  315. IDR_TOOLBAR_HELPER_ICONS
  316. )
  317. );
  318. //////////////////////////////////////////////////////////////////////////
  319. if( !m_wndMenuBar.Create(
  320. NULL,
  321. this,
  322. ID_VIEW_MENUBAR
  323. )
  324. )
  325.     {
  326.         TRACE0("Failed to create menubarn");
  327.         return -1;      // failed to create
  328.     }
  329. if( !m_wndToolBar.Create(
  330. _T("ToolBar"),
  331. this,
  332. ID_VIEW_TOOLBAR
  333. )
  334. ||
  335. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)
  336. )
  337. {
  338. TRACE0("Failed to create toolbarn");
  339. return -1;      // fail to create
  340. }
  341. /////////////////////////////////////////////////////////////////
  342. if( !m_wndToolBarSeek.Create(
  343. _T("Seek Slider"),
  344. this,
  345. IDR_TOOLBAR_SEEK)
  346. )
  347. {
  348. TRACE0("Failed to create toolbar m_wndToolBarSeek n");
  349. return -1;      // fail to create
  350. }
  351. m_wndToolBarSeek.InitContentExpandButton();
  352. if( !m_wndToolBarZoom.Create(
  353. _T("Zoom Slider"),
  354. this,
  355. IDR_TOOLBAR_ZOOM)
  356. )
  357. {
  358. TRACE0("Failed to create toolbar m_wndToolBarZoom n");
  359. return -1;      // fail to create
  360. }
  361. m_wndToolBarZoom.InitContentExpandButton();
  362. CExtCmdItem * pCmdItemSlider =
  363. g_CmdManager->CmdAllocPtr(
  364. pApp->m_pszProfileName,
  365. ID_MYEXTBTN_SLIDER
  366. );
  367. ASSERT( pCmdItemSlider != NULL );
  368. pCmdItemSlider->m_sToolbarText = _T("Zoom:");
  369. pCmdItemSlider->m_sMenuText = _T("Zoom slider");
  370. pCmdItemSlider->m_sTipTool
  371. = pCmdItemSlider->m_sTipStatus
  372. = _T("Zoom slider");
  373. CExtCmdItem * pCmdItemScroller =
  374. g_CmdManager->CmdAllocPtr(
  375. pApp->m_pszProfileName,
  376. ID_MYEXTBTN_SCROLLER
  377. );
  378. ASSERT( pCmdItemScroller != NULL );
  379. pCmdItemScroller->m_sToolbarText = _T("Seek:");
  380. pCmdItemScroller->m_sMenuText = _T("Seek slider");
  381. pCmdItemScroller->m_sTipTool
  382. = pCmdItemScroller->m_sTipStatus
  383. = _T("Seek slider");
  384. CExtBarSliderButton *pZoomSliderTBB =
  385. new CExtBarSliderButton(
  386. /////////////////
  387. // standard CExtBarButton parms
  388. /////////////////
  389. &m_wndToolBarZoom,
  390. ID_MYEXTBTN_SLIDER,
  391. 0,
  392. /////////////////
  393. // CExtBarSliderButton specific parms
  394. /////////////////
  395. //
  396. // scroll total/pos/page
  397. 50, 20, 0,
  398. // button extent horz(left/right)/vert(up/down) in pixels
  399. // (if zeros - use slider-like layout instead of scrollbar-like)
  400. 0, 0,
  401. // total slider control extent horz/vert in pixels
  402. 80, 80
  403. );
  404. VERIFY(
  405. m_wndToolBarZoom.InsertSpecButton(
  406. -1,
  407. pZoomSliderTBB,
  408. FALSE
  409. )
  410. );
  411. CExtBarSliderButton *pSeekScrollerTBB = new CExtBarSliderButton(
  412. /////////////////
  413. // standard CExtBarButton parms
  414. /////////////////
  415. &m_wndToolBarSeek,
  416. ID_MYEXTBTN_SCROLLER,
  417. 0,
  418. /////////////////
  419. // CExtBarScrollerButton specific parms
  420. /////////////////
  421. //
  422. // scroll total/pos/page
  423. 50, 20, 0,
  424. // button extent horz(left/right)/vert(up/down) in pixels
  425. // (if zeros - use slider-like layout instead of scrollbar-like)
  426. 10, 10,
  427. // total slider control extent horz/vert in pixels
  428. 150, 150
  429. );
  430. VERIFY(
  431. m_wndToolBarSeek.InsertSpecButton(
  432. -1,
  433. pSeekScrollerTBB,
  434. FALSE
  435. )
  436. );
  437. //////////////////////////////////////////////////////////////////////////
  438. if( !m_wndToolBarIed.Create(
  439. NULL,
  440. this,
  441. ID_VIEW_IEDBAR
  442. )
  443. ||
  444. !m_wndToolBarIed.LoadToolBar( ID_VIEW_IEDBAR )
  445. )
  446. {
  447. TRACE0("Failed to create image editor toolbarn");
  448. return -1;      // fail to create
  449. }
  450. CMenu _menu;
  451. CExtBarButton * pTBB;
  452. int nBtnIdx;
  453. VERIFY( _menu.LoadMenu(IDR_IED_MENU_MAGNIFICATION) );
  454. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_MAGNIFICATION);
  455. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  456. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  457. ASSERT_VALID( pTBB );
  458. pTBB->SetNoRotateVerticalLayout();
  459. pTBB->SetSeparatedDropDown();
  460. VERIFY( _menu.LoadMenu(IDR_IED_MENU_BRUSH) );
  461. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_BRUSH);
  462. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  463. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  464. ASSERT_VALID( pTBB );
  465. pTBB->SetNoRotateVerticalLayout();
  466. pTBB->SetSeparatedDropDown();
  467. VERIFY( _menu.LoadMenu(IDR_IED_MENU_AIR_BRUSH) );
  468. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_AIR_BRUSH);
  469. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  470. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  471. ASSERT_VALID( pTBB );
  472. pTBB->SetNoRotateVerticalLayout();
  473. pTBB->SetSeparatedDropDown();
  474. VERIFY( _menu.LoadMenu(IDR_IED_MENU_LINE) );
  475. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_LINE);
  476. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  477. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  478. ASSERT_VALID( pTBB );
  479. pTBB->SetNoRotateVerticalLayout();
  480. pTBB->SetSeparatedDropDown();
  481. VERIFY( _menu.LoadMenu(IDR_IED_MENU_RECTANGLE) );
  482. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_RECTANGLE);
  483. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  484. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  485. ASSERT_VALID( pTBB );
  486. pTBB->SetNoRotateVerticalLayout();
  487. pTBB->SetSeparatedDropDown();
  488. VERIFY( _menu.LoadMenu(IDR_IED_MENU_OUTLINED_RECTANGLE) );
  489. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_OUTLINED_RECTANGLE);
  490. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  491. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  492. ASSERT_VALID( pTBB );
  493. pTBB->SetNoRotateVerticalLayout();
  494. pTBB->SetSeparatedDropDown();
  495. VERIFY( _menu.LoadMenu(IDR_IED_MENU_ROUNDED_RECTANGLE) );
  496. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_ROUNDED_RECTANGLE);
  497. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  498. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  499. ASSERT_VALID( pTBB );
  500. pTBB->SetNoRotateVerticalLayout();
  501. pTBB->SetSeparatedDropDown();
  502. VERIFY( _menu.LoadMenu(IDR_IED_MENU_ROUNDED_OUTLINED_RECTANGLE) );
  503. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_ROUNDED_OUTLINED_RECTANGLE);
  504. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  505. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  506. ASSERT_VALID( pTBB );
  507. pTBB->SetNoRotateVerticalLayout();
  508. pTBB->SetSeparatedDropDown();
  509. VERIFY( _menu.LoadMenu(IDR_IED_MENU_ELLIPSE) );
  510. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_ELLIPSE);
  511. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  512. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  513. ASSERT_VALID( pTBB );
  514. pTBB->SetNoRotateVerticalLayout();
  515. pTBB->SetSeparatedDropDown();
  516. VERIFY( _menu.LoadMenu(IDR_IED_MENU_OUTLINED_ELLIPSE) );
  517. nBtnIdx = m_wndToolBarIed.CommandToIndex(ID_IED_TOOL_OUTLINED_ELLIPSE);
  518. m_wndToolBarIed.SetButtonMenu( nBtnIdx, _menu.Detach() );
  519. pTBB = m_wndToolBarIed.GetButton(nBtnIdx);
  520. ASSERT_VALID( pTBB );
  521. pTBB->SetNoRotateVerticalLayout();
  522. pTBB->SetSeparatedDropDown();
  523. /////////////////////////////////////////////////////////////////
  524. if( !m_wndResizableBar0.Create(
  525. _T("Resizable Bar 0"),
  526. this,
  527. ID_VIEW_RESIZABLE_BAR_0
  528. )
  529. || !m_wndResizableBar1.Create(
  530. _T("Resizable Bar 1"),
  531. this,
  532. ID_VIEW_RESIZABLE_BAR_1
  533. )
  534. || !m_wndResizableBar2.Create(
  535. _T("Resizable Bar 2"),
  536. this,
  537. ID_VIEW_RESIZABLE_BAR_2
  538. )
  539. )
  540. {
  541. TRACE0("Failed to create "m_wndResizableBar"sn");
  542. return -1; // fail to create
  543. }
  544. //////////////////////////////////////////////////////////////////////////
  545. m_wndStatusBar.m_bDrawPaneSeparatorsInsteadOfBorders = true;
  546. if( !m_wndStatusBar.Create(this)
  547. || !m_wndStatusBar.SetIndicators(
  548. indicators,
  549. sizeof(indicators) / sizeof(UINT)
  550. )
  551. )
  552. {
  553. TRACE0("Failed to create status barn");
  554. return -1;      // fail to create
  555. }
  556.     m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  557. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  558. m_wndToolBarZoom.EnableDocking(CBRS_ALIGN_ANY);
  559. m_wndToolBarSeek.EnableDocking(CBRS_ALIGN_ANY);
  560. m_wndToolBarIed.EnableDocking( CBRS_ALIGN_ANY );
  561. m_wndResizableBar0.EnableDocking(CBRS_ALIGN_ANY);
  562. m_wndResizableBar1.EnableDocking(CBRS_ALIGN_ANY);
  563. m_wndResizableBar2.EnableDocking(CBRS_ALIGN_ANY);
  564. if( !CExtControlBar::FrameEnableDocking(this) )
  565. {
  566. ASSERT( FALSE );
  567. return -1;
  568. }
  569. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  570. if( !CExtControlBar::FrameInjectAutoHideAreas(this) )
  571. {
  572. ASSERT( FALSE );
  573. return -1;
  574. }
  575. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  576. VERIFY(
  577. g_CmdManager->SetBasicCommands(
  578. pApp->m_pszProfileName,
  579. g_statBasicCommands
  580. )
  581. );
  582. if( !CExtControlBar::ProfileBarStateLoad(
  583. this,
  584. pApp->m_pszRegistryKey,
  585. pApp->m_pszProfileName,
  586. pApp->m_pszProfileName,
  587. &m_dataFrameWP
  588. )
  589. )
  590. {
  591. DockControlBar( &m_wndMenuBar );
  592. DockControlBar( &m_wndToolBar );
  593. DockControlBar( &m_wndToolBarIed );
  594. DockControlBar( &m_wndToolBarZoom );
  595. RecalcLayout();
  596. CRect wrAlreadyDockedBar;
  597. m_wndToolBarZoom.GetWindowRect( &wrAlreadyDockedBar );
  598. wrAlreadyDockedBar.OffsetRect( 1, 0 );
  599. DockControlBar( &m_wndToolBarSeek, AFX_IDW_DOCKBAR_TOP, &wrAlreadyDockedBar );
  600. RecalcLayout();
  601. static CSize
  602. _sizeInitH( 150, 80  ),
  603. _sizeInitV( 80,  150 ),
  604. _sizeInitF( 150, 150 );
  605. m_wndResizableBar0.SetInitDesiredSizeHorizontal( _sizeInitH );
  606. m_wndResizableBar0.SetInitDesiredSizeVertical( _sizeInitV );
  607. m_wndResizableBar0.SetInitDesiredSizeFloating( _sizeInitF );
  608. m_wndResizableBar1.SetInitDesiredSizeHorizontal( _sizeInitH );
  609. m_wndResizableBar1.SetInitDesiredSizeVertical( _sizeInitV );
  610. m_wndResizableBar1.SetInitDesiredSizeFloating( _sizeInitF );
  611. m_wndResizableBar2.SetInitDesiredSizeHorizontal( _sizeInitH );
  612. m_wndResizableBar2.SetInitDesiredSizeVertical( _sizeInitV );
  613. m_wndResizableBar2.SetInitDesiredSizeFloating( _sizeInitF );
  614. m_wndResizableBar0.DockControlBar(
  615. AFX_IDW_DOCKBAR_LEFT, 
  616. 1,
  617. this 
  618. );
  619. m_wndResizableBar1.DockControlBar( 
  620. AFX_IDW_DOCKBAR_LEFT, 
  621. 1,
  622. this 
  623. );
  624. m_wndResizableBar2.DockControlBar(
  625. AFX_IDW_DOCKBAR_LEFT, 
  626. 1,
  627. this 
  628. );
  629. RecalcLayout();
  630. }
  631. g_CmdManager->SerializeState(
  632. pApp->m_pszProfileName,
  633. pApp->m_pszRegistryKey,
  634. pApp->m_pszProfileName,
  635. false
  636. );
  637. return 0;
  638. }
  639. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  640. {
  641. if( ! CFrameWnd::PreCreateWindow(cs) )
  642. return FALSE;
  643. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  644. cs.lpszClass = AfxRegisterWndClass(0);
  645. return TRUE;
  646. }
  647. /////////////////////////////////////////////////////////////////////////////
  648. // CMainFrame diagnostics
  649. #ifdef _DEBUG
  650. void CMainFrame::AssertValid() const
  651. {
  652. CFrameWnd::AssertValid();
  653. }
  654. void CMainFrame::Dump(CDumpContext& dc) const
  655. {
  656. CFrameWnd::Dump(dc);
  657. }
  658. #endif //_DEBUG
  659. /////////////////////////////////////////////////////////////////////////////
  660. // CMainFrame message handlers
  661. void CMainFrame::OnSetFocus(CWnd* pOldWnd)
  662. {
  663. pOldWnd;
  664. // forward focus to the view window
  665. m_pWndView->SetFocus();
  666. }
  667. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  668. {
  669. // // TEST FOR INDETERIMINATE BUTTON STATE IN RIBBONs
  670. // if( nID == ID_EDIT_PASTE
  671. // || nID == ID_FILE_OPEN
  672. // )
  673. // {
  674. // if( nCode == CN_UPDATE_COMMAND_UI )
  675. // {
  676. // ((CCmdUI*)pExtra)->Enable();
  677. // ((CCmdUI*)pExtra)->SetCheck( 2 );
  678. // }
  679. // return TRUE;
  680. // }
  681. // let the view have first crack at the command
  682. if (m_pWndView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  683. return TRUE;
  684. // otherwise, do default handling
  685. return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  686. }
  687. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  688. {
  689. if( m_wndMenuBar.TranslateMainFrameMessage(pMsg) )
  690. return TRUE;
  691. return CFrameWnd::PreTranslateMessage(pMsg);
  692. }
  693. BOOL CMainFrame::DestroyWindow() 
  694. {
  695. CWinApp * pApp = ::AfxGetApp();
  696. ASSERT( pApp != NULL );
  697. ASSERT( pApp->m_pszRegistryKey != NULL );
  698. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  699. ASSERT( pApp->m_pszProfileName != NULL );
  700. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  701. VERIFY(
  702. CExtControlBar::ProfileBarStateSave(
  703. this,
  704. pApp->m_pszRegistryKey,
  705. pApp->m_pszProfileName,
  706. pApp->m_pszProfileName
  707. )
  708. );
  709. VERIFY(
  710. g_CmdManager->SerializeState(
  711. pApp->m_pszProfileName,
  712. pApp->m_pszRegistryKey,
  713. pApp->m_pszProfileName,
  714. true
  715. )
  716. );
  717. VERIFY(
  718. g_PaintManager.PaintManagerStateSave(
  719. pApp->m_pszRegistryKey,
  720. pApp->m_pszProfileName,
  721. pApp->m_pszProfileName
  722. )
  723. );
  724. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  725. return CFrameWnd::DestroyWindow();
  726. }
  727. void CMainFrame::ActivateFrame(int nCmdShow) 
  728. {
  729. // window placement persistence
  730. if( m_dataFrameWP.showCmd != SW_HIDE )
  731. {
  732. SetWindowPlacement( &m_dataFrameWP );
  733. CFrameWnd::ActivateFrame( m_dataFrameWP.showCmd );
  734. m_dataFrameWP.showCmd = SW_HIDE;
  735. return;
  736. }
  737. CFrameWnd::ActivateFrame(nCmdShow);
  738. }
  739. LRESULT CMainFrame::OnDrawControlBarTrackedArea(WPARAM wParam, LPARAM lParam)
  740. {
  741. lParam;
  742. CExtControlBar::MsgDrawTrackedAreaData_t * pMsgDrawTrackedAreaData =
  743. (CExtControlBar::MsgDrawTrackedAreaData_t *)wParam;
  744. ASSERT( pMsgDrawTrackedAreaData != NULL );
  745. ASSERT_VALID( (&(pMsgDrawTrackedAreaData->m_wndBar)) );
  746. ASSERT(
  747. pMsgDrawTrackedAreaData->m_wndBar.GetSafeHwnd() != NULL
  748. && ::IsWindow( pMsgDrawTrackedAreaData->m_wndBar.GetSafeHwnd() )
  749. );
  750. ASSERT( pMsgDrawTrackedAreaData->m_dcDraw.GetSafeHdc() != NULL );
  751. pMsgDrawTrackedAreaData->m_bMessageHandled = true;
  752. if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  753. {
  754. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  755. {
  756. CDC dcSrc;
  757. if( dcSrc.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  758. {
  759. CBitmap * pOldBitmap = dcSrc.SelectObject( &m_bmpTrackerCache );
  760. pMsgDrawTrackedAreaData->m_dcDraw.BitBlt(
  761. m_rcTrackerEntireArea.left,
  762. m_rcTrackerEntireArea.top,
  763. m_rcTrackerEntireArea.Width(),
  764. m_rcTrackerEntireArea.Height(),
  765. &dcSrc,
  766. 0,
  767. 0,
  768. SRCCOPY
  769. );
  770. dcSrc.SelectObject( pOldBitmap );
  771. dcSrc.DeleteDC();
  772. } // if( dcSrc.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  773. m_bmpTrackerCache.DeleteObject(); // no longer needed
  774. } // if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  775. } // if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  776. else
  777. {
  778. m_rcTrackerEntireArea = pMsgDrawTrackedAreaData->m_rcDrawArea;
  779. if( m_bmpTrackerCache.GetSafeHandle() != NULL )
  780. m_bmpTrackerCache.DeleteObject();
  781. CDC dcDst;
  782. if( dcDst.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  783. {
  784. if( m_bmpTrackerCache.CreateCompatibleBitmap(
  785. &(pMsgDrawTrackedAreaData->m_dcDraw),
  786. m_rcTrackerEntireArea.Width(),
  787. m_rcTrackerEntireArea.Height()
  788. )
  789. )
  790. {
  791. CBitmap * pOldBitmap = dcDst.SelectObject( &m_bmpTrackerCache );
  792. dcDst.BitBlt(
  793. 0,
  794. 0,
  795. m_rcTrackerEntireArea.Width(),
  796. m_rcTrackerEntireArea.Height(),
  797. &(pMsgDrawTrackedAreaData->m_dcDraw),
  798. m_rcTrackerEntireArea.left,
  799. m_rcTrackerEntireArea.top,
  800. SRCCOPY
  801. );
  802. dcDst.SelectObject( pOldBitmap );
  803. } // if( m_bmpTrackerCache.CreateCompatibleBitmap( ...
  804. dcDst.DeleteDC();
  805. } // if( dcDst.CreateCompatibleDC( &(pMsgDrawTrackedAreaData->m_dcDraw) ) )
  806. HBRUSH hBrush = (HBRUSH)
  807. m_brushTracker.GetSafeHandle();
  808. if( hBrush == NULL )
  809. hBrush = (HBRUSH)
  810. ::GetStockObject( WHITE_BRUSH );
  811. pMsgDrawTrackedAreaData->Draw(
  812. hBrush,
  813. PATCOPY
  814. );
  815. } // else from if( pMsgDrawTrackedAreaData->m_bErasingPrevious )
  816. return 0L;
  817. }