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

界面编程

开发平台:

Visual C++

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #include "stdafx.h"
  13. #include "drawcli.h"
  14. #include "mainfrm.h"
  15. #include "drawdoc.h"
  16. #include "drawvw.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CMainFrame
  23. IMPLEMENT_DYNAMIC( CMainFrame, CMDIFrameWnd )
  24. BEGIN_MESSAGE_MAP( CMainFrame, CMDIFrameWnd )
  25. //{{AFX_MSG_MAP(CMainFrame)
  26. ON_WM_CREATE()
  27. ON_COMMAND(ID_MDITABS_TOP, OnMditabsTop)
  28. ON_UPDATE_COMMAND_UI(ID_MDITABS_TOP, OnUpdateMditabsTop)
  29. ON_COMMAND(ID_MDITABS_BOTTOM, OnMditabsBottom)
  30. ON_UPDATE_COMMAND_UI(ID_MDITABS_BOTTOM, OnUpdateMditabsBottom)
  31. ON_COMMAND(ID_MDITABS_LEFT, OnMditabsLeft)
  32. ON_UPDATE_COMMAND_UI(ID_MDITABS_LEFT, OnUpdateMditabsLeft)
  33. ON_COMMAND(ID_MDITABS_RIGHT, OnMditabsRight)
  34. ON_UPDATE_COMMAND_UI(ID_MDITABS_RIGHT, OnUpdateMditabsRight)
  35. ON_COMMAND(ID_MDITABS_SHOW_CLOSE, OnMditabsShowClose)
  36. ON_UPDATE_COMMAND_UI(ID_MDITABS_SHOW_CLOSE, OnUpdateMditabsShowClose)
  37. ON_COMMAND(ID_MDITABS_SHOW_CTX_HELP, OnMditabsShowCtxHelp)
  38. ON_UPDATE_COMMAND_UI(ID_MDITABS_SHOW_CTX_HELP, OnUpdateMditabsShowCtxHelp)
  39. ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)
  40. ON_UPDATE_COMMAND_UI(ID_CONTEXT_HELP, OnUpdateContextHelp)
  41. ON_COMMAND(ID_CUSTOMIZE, OnCustomize)
  42. ON_UPDATE_COMMAND_UI(ID_CUSTOMIZE, OnUpdateCustomize)
  43. //}}AFX_MSG_MAP
  44. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  45. ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
  46. ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)
  47. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  48. ON_COMMAND_EX(ID_VIEW_TOOLBAR2, OnBarCheck )
  49. ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR2, OnUpdateControlBarMenu)
  50. ON_COMMAND_EX(ID_VIEW_PALETTE, OnBarCheck )
  51. ON_UPDATE_COMMAND_UI(ID_VIEW_PALETTE, OnUpdateControlBarMenu)
  52. ON_COMMAND_EX(ID_VIEW_UI_LOOK_BAR, OnBarCheck )
  53. ON_UPDATE_COMMAND_UI(ID_VIEW_UI_LOOK_BAR, OnUpdateControlBarMenu)
  54. ON_REGISTERED_MESSAGE(
  55. CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel,
  56. OnExtMenuPrepare
  57. )
  58. ON_REGISTERED_MESSAGE(
  59. CExtPopupMenuWnd::g_nMsgPopupDrawItem,
  60. OnDrawPopupMenuItem
  61. )
  62. // color popup menu
  63. ON_REGISTERED_MESSAGE(
  64. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  65. OnColorChangedFinally
  66. )
  67. ON_REGISTERED_MESSAGE(
  68. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  69. OnColorSelectCustom
  70. )
  71. END_MESSAGE_MAP()
  72. static UINT BASED_CODE indicators[] =
  73. {
  74. ID_SEPARATOR,           // status line indicator
  75. ID_INDICATOR_CAPS,
  76. ID_INDICATOR_NUM,
  77. ID_INDICATOR_SCRL,
  78. };
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CMainFrame construction/destruction
  81. CMainFrame::CMainFrame()
  82. {
  83. CWinApp * pApp = ::AfxGetApp();
  84. ASSERT( pApp != NULL );
  85. ASSERT( pApp->m_pszRegistryKey != NULL );
  86. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  87. ASSERT( pApp->m_pszProfileName != NULL );
  88. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  89. if( ! g_PaintManager.PaintManagerStateLoad(
  90. pApp->m_pszRegistryKey,
  91. pApp->m_pszProfileName,
  92. pApp->m_pszProfileName
  93. )
  94. )
  95. g_PaintManager.InstallPaintManager(
  96. RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue)
  97. );
  98. #if (defined __EXT_MFC_NO_CUSTOMIZE)
  99. m_pBtnColorFillS = m_pBtnColorOutlineS = NULL;
  100. #endif // (defined __EXT_MFC_NO_CUSTOMIZE)
  101. m_pBtnColorFillP = m_pBtnColorOutlineP = NULL;
  102. // window placement persistence
  103. ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
  104. m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
  105. m_dataFrameWP.showCmd = SW_HIDE;
  106. }
  107. CMainFrame::~CMainFrame()
  108. {
  109. }
  110. static UINT g_statBasicCommands[] =
  111. {
  112. ID_APP_ABOUT,
  113. ID_APP_EXIT,
  114. ID_FILE_NEW,
  115. ID_FILE_OPEN,
  116. ID_FILE_SAVE,
  117. ID_FILE_PRINT,
  118. ID_FILE_PRINT_PREVIEW,
  119. ID_EDIT_CUT,
  120. ID_EDIT_COPY,
  121. ID_EDIT_PASTE,
  122. ID_EDIT_SELECT_ALL,
  123. ID_EDIT_PROPERTIES,
  124. ID_OLE_INSERT_NEW,
  125. ID_OLE_EDIT_LINKS,
  126. ID_DRAW_SELECT,
  127. ID_DRAW_LINE,
  128. ID_DRAW_RECT,
  129. ID_DRAW_ROUNDRECT,
  130. ID_DRAW_ELLIPSE,
  131. ID_DRAW_POLYGON,
  132. ID_OBJECT_LINECOLOR,
  133. ID_OBJECT_FILLCOLOR,
  134. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  135. ID_VIEW_MENUBAR,
  136. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  137. ID_VIEW_TOOLBAR,
  138. ID_VIEW_TOOLBAR2,
  139. ID_VIEW_UI_LOOK_BAR,
  140. ID_VIEW_PALETTE,
  141. ID_VIEW_STATUS_BAR,
  142. ID_MDITABS_TOP,
  143. ID_MDITABS_BOTTOM,
  144. ID_MDITABS_LEFT,
  145. ID_MDITABS_RIGHT,
  146. ID_MDITABS_SHOW_CLOSE,
  147. ID_MDITABS_SHOW_CTX_HELP,
  148. ID_EDIT_COPY,
  149. ID_EDIT_CUT,
  150. ID_EDIT_PASTE,
  151. ID_WINDOW_NEW,
  152. ID_WINDOW_CASCADE,
  153. ID_WINDOW_TILE_HORZ,
  154. ID_WINDOW_ARRANGE,
  155. ID_LINE_WIDTH_OTHER,
  156. ID_LINE_WIDTH_0,
  157. ID_LINE_WIDTH_1,
  158. ID_LINE_WIDTH_2,
  159. ID_LINE_WIDTH_3,
  160. ID_LINE_WIDTH_4,
  161. ID_LINE_WIDTH_5,
  162. ID_LINE_WIDTH_6,
  163. ID_LINE_WIDTH_7,
  164. ID_LINE_WIDTH_8,
  165. ID_LINE_WIDTH_9,
  166. ID_LINE_WIDTH_10,
  167. 0, // end of list
  168. };
  169. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  170. {
  171. if( CExtNCW < CMDIFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
  172. return -1;
  173. HINSTANCE hInstResource =
  174. AfxFindResourceHandle(
  175. MAKEINTRESOURCE( IDR_MAINFRAME ),
  176. RT_GROUP_ICON
  177. );
  178. ASSERT( hInstResource != NULL );
  179. HICON hIcon = (HICON)
  180. ::LoadImage(
  181. hInstResource,
  182. MAKEINTRESOURCE( IDR_MAINFRAME ),
  183. IMAGE_ICON,
  184. 16,
  185. 16,
  186. 0
  187. );
  188. ASSERT( hIcon != NULL );
  189. SetIcon( hIcon, FALSE );
  190. CWinApp * pApp = ::AfxGetApp();
  191. ASSERT( pApp != NULL );
  192. hIcon = pApp->LoadIcon(IDR_MAINFRAME);
  193. ASSERT( hIcon != NULL );
  194. SetIcon( hIcon, TRUE );
  195. ASSERT( pApp->m_pszRegistryKey != NULL );
  196. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  197. ASSERT( pApp->m_pszProfileName != NULL );
  198. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  199. ASSERT( pApp->m_pszProfileName != NULL );
  200. g_CmdManager->ProfileSetup(
  201. pApp->m_pszProfileName,
  202. GetSafeHwnd()
  203. );
  204. VERIFY( g_CmdManager->UpdateFromMenu( pApp->m_pszProfileName, IDR_MAINFRAME ) );
  205. VERIFY( g_CmdManager->UpdateFromMenu( pApp->m_pszProfileName, IDR_DRAWCLTYPE ) );
  206. VERIFY( g_CmdManager->UpdateFromToolBar( pApp->m_pszProfileName, IDR_TOOLBAR_HELPER_ICONS ) );
  207. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  208. //m_wndMenuBar.m_bCustomizationAllowed = false;
  209. m_wndMenuBar.SetMdiWindowPopupName( _T("Window") );
  210. if( ! m_wndMenuBar.Create(
  211. NULL,
  212. this,
  213. ID_VIEW_MENUBAR
  214. )
  215. )
  216.     {
  217.         TRACE0("Failed to create menubarn");
  218.         return -1;      // failed to create
  219.     }
  220. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  221. if( (! m_wndToolBarStandard.Create( NULL, this, AFX_IDW_TOOLBAR ) )
  222. || (! m_wndToolBarStandard.LoadToolBar( IDR_MAINFRAME ) )
  223. )
  224. {
  225. TRACE0("Failed to create standard toolbarn");
  226. return -1;      // fail to create
  227. }
  228. if( (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )
  229. || (! m_wndToolBarUiLook.ThemeSwitcherInit() )
  230. )
  231. {
  232. TRACE0("Failed to create UI look switcher toolbarn");
  233. return -1;      // fail to create
  234. }
  235. LPCTSTR strProfileName =
  236. g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() );
  237. ASSERT( strProfileName != NULL );
  238. CExtCmdItem * pCmdItem =
  239. g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_FILLCOLOR );
  240. ASSERT( pCmdItem != NULL );
  241. pCmdItem->StateSetPersistentIcon();
  242. pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
  243. pCmdItem->StateSetColor();
  244. pCmdItem->StateSetColorBtnDefault();
  245. pCmdItem->StateSetColorBtnCustom();
  246. pCmdItem->StateSetNoRotateVL();
  247. pCmdItem->StateSetSeparatedDD();
  248. pCmdItem =
  249. g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_LINECOLOR );
  250. ASSERT( pCmdItem != NULL );
  251. pCmdItem->StateSetPersistentIcon();
  252. pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
  253. pCmdItem->StateSetColor();
  254. pCmdItem->StateSetColorBtnDefault();
  255. pCmdItem->StateSetColorBtnCustom();
  256. pCmdItem->StateSetNoRotateVL();
  257. pCmdItem =
  258. g_CmdManager->CmdGetPtr( strProfileName, ID_DOC_LINE_WIDTH );
  259. ASSERT( pCmdItem != NULL );
  260. pCmdItem->m_sMenuText = _T("Line &Width");
  261. pCmdItem->StateSetPersistentIcon();
  262. INT nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_DOC_LINE_WIDTH);
  263. ASSERT( nBtnIdx >= 0 );
  264. CMenu _line_menu;
  265. VERIFY( _line_menu.LoadMenu(IDR_MENU_LW) );
  266. VERIFY( m_wndToolBarStandard.SetButtonMenu( nBtnIdx, _line_menu.Detach() ) );
  267. CExtBarButton * pTBB = m_wndToolBarStandard.GetButton(nBtnIdx);
  268. ASSERT_VALID( pTBB );
  269. pTBB->SetNoRotateVerticalLayout();
  270. pTBB->SetSeparatedDropDown();
  271. pTBB->SetAutoChangeID();
  272. pTBB->SetCmdID(ID_LINE_WIDTH_1,true); // set default effective command
  273. CString sNoFill;
  274. VERIFY( sNoFill.LoadString( IDS_STRING_NO_COLOR_FILL ) );
  275. CString sNoOutline;
  276. VERIFY( sNoOutline.LoadString( IDS_STRING_NO_COLOR_OUTLINE ) );
  277. #if (defined __EXT_MFC_NO_CUSTOMIZE)
  278. nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_FILLCOLOR);
  279. VERIFY(
  280. m_wndToolBarStandard.RemoveButton(
  281. nBtnIdx,
  282. FALSE
  283. )
  284. );
  285. m_pBtnColorFillS =
  286. new CExtBarColorButton(
  287. &m_wndToolBarStandard,
  288. ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
  289. ID_OBJECT_FILLCOLOR, true, true,
  290. (LPCTSTR)sNoFill, NULL,
  291. CExtBarColorButton::__DIT_CHAR_2007
  292. );
  293. m_pBtnColorFillS->SetSeparatedDropDown();
  294. VERIFY(
  295. m_wndToolBarStandard.InsertSpecButton(
  296. nBtnIdx,
  297. m_pBtnColorFillS,
  298. FALSE
  299. )
  300. );
  301. nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_LINECOLOR);
  302. m_wndToolBarStandard.SetButtonCtrlVisibleVertically( nBtnIdx, true );
  303. VERIFY(
  304. m_wndToolBarStandard.RemoveButton(
  305. nBtnIdx,
  306. FALSE
  307. )
  308. );
  309. m_pBtnColorOutlineS =
  310. new CExtBarColorButton(
  311. &m_wndToolBarStandard,
  312. ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
  313. ID_OBJECT_LINECOLOR, true, true,
  314. (LPCTSTR)sNoOutline, NULL,
  315. CExtBarColorButton::__DIT_FRAME
  316. );
  317. VERIFY(
  318. m_wndToolBarStandard.InsertSpecButton(
  319. nBtnIdx,
  320. m_pBtnColorOutlineS,
  321. FALSE
  322. )
  323. );
  324. #endif // (defined __EXT_MFC_NO_CUSTOMIZE)
  325. if( !m_wndToolBarCustom.Create(
  326. NULL,
  327. this,
  328. ID_VIEW_TOOLBAR2
  329. )
  330. || !m_wndToolBarCustom.InitContentExpandButton()
  331. )
  332. {
  333. TRACE0("Failed to create custom toolbarn");
  334. return -1;      // fail to create
  335. }
  336. static struct
  337. {
  338. UINT m_nCmdID;
  339. LPCTSTR m_sToolbarText;
  340. }
  341. custom_toolbar_cmds[] =
  342. {
  343. { ID_OBJECT_MOVETOFRONT, _T("Move to front") },
  344. { ID_OBJECT_MOVETOBACK, _T("Move to back") },
  345. { ID_SEPARATOR, NULL },
  346. { ID_OBJECT_MOVEFORWARD, NULL },
  347. { ID_OBJECT_MOVEBACK, NULL },
  348. };
  349. for( INT nCustBarIdx = 0;
  350. nCustBarIdx < sizeof(custom_toolbar_cmds)/sizeof(custom_toolbar_cmds[0]);
  351. nCustBarIdx++
  352. )
  353. { // add buttons to custom toolbar
  354. UINT nCmdID = custom_toolbar_cmds[nCustBarIdx].m_nCmdID;
  355. if( nCmdID != ID_SEPARATOR )
  356. {
  357. LPCTSTR sToolBarBtnText =
  358. custom_toolbar_cmds[nCustBarIdx].m_sToolbarText;
  359. if( sToolBarBtnText != NULL )
  360. {
  361. CExtCmdItem * pCmdItem =
  362. g_CmdManager->CmdGetPtr(
  363. strProfileName,
  364. nCmdID
  365. );
  366. ASSERT( pCmdItem != NULL );
  367. pCmdItem->m_sToolbarText = sToolBarBtnText;
  368. } // if( sToolBarBtnText != NULL )
  369. HICON hIcon = (HICON)
  370. ::LoadImage(
  371. hInstResource,
  372. MAKEINTRESOURCE( nCmdID ),
  373. IMAGE_ICON,
  374. 16,
  375. 16,
  376. 0
  377. );
  378. if( hIcon != NULL )
  379. {
  380. VERIFY(
  381. g_CmdManager->CmdSetIcon(
  382. g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),
  383. nCmdID,
  384. hIcon,
  385. false
  386. )
  387. );
  388. } // if( hIcon != NULL )
  389. } // if( nCmdID != ID_SEPARATOR )
  390. m_wndToolBarCustom.InsertButton( -1, nCmdID, FALSE );
  391. } // add buttons to custom toolbar
  392. m_wndPalette.m_bPaletteMode = true;
  393. if( !m_wndPalette.Create(
  394. NULL,
  395. this,
  396. ID_VIEW_PALETTE
  397. )
  398. ||
  399. !m_wndPalette.LoadToolBar(IDR_TOOLBAR_HELPER_ICONS)
  400. )
  401. {
  402. TRACE0("Failed to create m_wndPalette toolbarn");
  403. return -1;      // fail to create
  404. }
  405. m_wndPalette.InsertButton();
  406. nBtnIdx = m_wndPalette.GetButtonsCount();
  407. m_pBtnColorFillP =
  408. new CExtBarColorButton(
  409. &m_wndPalette,
  410. ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
  411. ID_OBJECT_FILLCOLOR, true, true,
  412. (LPCTSTR)sNoFill, NULL,
  413. CExtBarColorButton::__DIT_CHAR_2007
  414. );
  415. m_pBtnColorFillP->SetSeparatedDropDown();
  416. VERIFY(
  417. m_wndPalette.InsertSpecButton(
  418. nBtnIdx,
  419. m_pBtnColorFillP,
  420. FALSE
  421. )
  422. );
  423. nBtnIdx++;
  424. m_pBtnColorOutlineP =
  425. new CExtBarColorButton(
  426. &m_wndPalette,
  427. ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
  428. ID_OBJECT_LINECOLOR, true, true,
  429. (LPCTSTR)sNoOutline, NULL,
  430. CExtBarColorButton::__DIT_FRAME
  431. );
  432. VERIFY(
  433. m_wndPalette.InsertSpecButton(
  434. nBtnIdx,
  435. m_pBtnColorOutlineP,
  436. FALSE
  437. )
  438. );
  439. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_HORZ );
  440. m_wndPalette.GetButton(  8 )->SetWrap( CExtBarButton::__EVT_HORZ );
  441. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_HORZ );
  442. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_VERT );
  443. m_wndPalette.GetButton(  6 )->SetWrap( CExtBarButton::__EVT_VERT );
  444. m_wndPalette.GetButton(  9 )->SetWrap( CExtBarButton::__EVT_VERT );
  445. m_wndPalette.GetButton( 12 )->SetWrap( CExtBarButton::__EVT_VERT );
  446. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_VERT );
  447. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  448. m_wndPalette.GetButton(  5 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  449. m_wndPalette.GetButton(  7 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  450. m_wndPalette.GetButton(  9 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  451. m_wndPalette.GetButton( 11 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  452. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  453. m_wndStatusBar.m_bDrawPaneSeparatorsInsteadOfBorders = true;
  454. if( !m_wndStatusBar.Create(
  455. this,
  456. WS_CHILD|WS_VISIBLE|CBRS_BOTTOM|CBRS_HIDE_INPLACE
  457. )
  458. || !m_wndStatusBar.SetIndicators(
  459. indicators,
  460. sizeof(indicators) / sizeof(UINT)
  461. )
  462. )
  463. {
  464. TRACE0("Failed to create status barn");
  465. return -1;      // fail to create
  466. }
  467. EnableDocking(CBRS_ALIGN_ANY);
  468. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  469. m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  470. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  471. m_wndToolBarStandard.EnableDocking(CBRS_ALIGN_ANY);
  472. m_wndToolBarCustom.EnableDocking(CBRS_ALIGN_ANY);
  473. m_wndPalette.EnableDocking(CBRS_ALIGN_ANY);
  474. m_wndToolBarUiLook.EnableDocking(CBRS_ALIGN_ANY);
  475. if( ! CExtControlBar::FrameEnableDocking(this) )
  476. {
  477. ASSERT( FALSE );
  478. return -1;
  479. }
  480. VERIFY(
  481. g_CmdManager->SetBasicCommands(
  482. pApp->m_pszProfileName,
  483. g_statBasicCommands
  484. )
  485. );
  486. // g_CmdManager->CmdGetPtr(
  487. // pApp->m_pszProfileName,
  488. // ID_FILE_NEW
  489. // )->StateSetCannotHide();
  490. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  491. VERIFY(
  492. CExtCustomizeSite::MenuInfoAdd(
  493. this,
  494. _T("Default"),
  495. IDR_MAINFRAME,
  496. true,
  497. false,
  498. RUNTIME_CLASS( CMainFrame )
  499. )
  500. );
  501. VERIFY(
  502. CExtCustomizeSite::MenuInfoAdd(
  503. this,
  504. _T("Document"),
  505. IDR_DRAWCLTYPE,
  506. false,
  507. false,
  508. RUNTIME_CLASS( CMDIChildWnd ),
  509. RUNTIME_CLASS( CView ),
  510. RUNTIME_CLASS( CDocument )
  511. )
  512. );
  513. VERIFY(
  514. CExtCustomizeSite::MenuInfoLoadAccelTable(
  515. _T("Default"),
  516. IDR_MAINFRAME
  517. )
  518. );
  519. VERIFY(
  520. CExtCustomizeSite::MenuInfoLoadAccelTable(
  521. _T("Document"),
  522. IDR_MAINFRAME
  523. )
  524. );
  525. CExtCustomizeSite::MenuInfoGetByName( _T("Document") )
  526. -> GetNode( true )
  527. -> SearchNodeElement( _T("&Window"), 1 )
  528. -> ModifyFlags( __ECTN_TBB_APPEND_MDI_MENU );
  529. CExtCustomizeSite::MenuInfoGetByName( _T("Document") )
  530. -> GetNode( false )
  531. -> SearchNodeElement( _T("&Window"), 1 )
  532. -> ModifyFlags( __ECTN_TBB_APPEND_MDI_MENU );
  533. if( !CExtCustomizeSite::EnableCustomization( this ) )
  534. {
  535. ASSERT( FALSE );
  536. return -1;
  537. }
  538. CExtCustomizeSite::CategoryUpdate( IDR_DRAWCLTYPE );
  539. CExtCustomizeSite::CategoryUpdate( IDR_MENU_HELPER );
  540. CExtCustomizeSite::CategoryUpdate( IDR_MAINFRAME );
  541. CExtCustomizeCmdTreeNode * pObjectCategory = 
  542. CExtCustomizeSite::CategoryGetTreeByName( _T("Object") );
  543. ASSERT_VALID( pObjectCategory );
  544. CExtCustomizeCmdTreeNode * pMenu = 
  545. pObjectCategory->SearchNodeElement( ID_DOC_LINE_WIDTH );
  546. ASSERT_VALID( pMenu );
  547. VERIFY( pMenu->LoadMenuTree( this, this, IDR_MENU_LW ) );
  548. pMenu->ModifyFlags(
  549. __ECTN_TBB_SEPARATED_DROPDOWN
  550. |__ECTN_TBB_AUTOCHANGE_ID
  551. |__ECTN_TBB_NO_ROTATE_VL
  552. );
  553. pMenu->SetCmdID(ID_LINE_WIDTH_1,true); // set default effective command
  554. /*
  555. pMenu = 
  556. pObjectCategory->SearchNodeElement( ID_OBJECT_FILLCOLOR );
  557. ASSERT_VALID( pMenu );
  558. pMenu->ModifyFlags( __ECTN_AUTO_POPUP );
  559. pMenu = 
  560. pObjectCategory->SearchNodeElement( ID_OBJECT_LINECOLOR );
  561. ASSERT_VALID( pMenu );
  562. pMenu->ModifyFlags( __ECTN_AUTO_POPUP );
  563. */
  564. CExtCustomizeSite::CategoryMakeAllCmdsUnique();
  565. CExtCustomizeSite::CategoryAppendAllCommands();
  566. CExtCustomizeSite::CategoryAppendNewMenu();
  567. CExtCustomizeSite::CustomizeStateLoad(
  568. pApp->m_pszRegistryKey,
  569. pApp->m_pszProfileName,
  570. pApp->m_pszProfileName
  571. );
  572. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  573. if( ! CExtControlBar::ProfileBarStateLoad(
  574. this,
  575. pApp->m_pszRegistryKey,
  576. pApp->m_pszProfileName,
  577. pApp->m_pszProfileName,
  578. &m_dataFrameWP
  579. )
  580. )
  581. {
  582. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  583. DockControlBar( &m_wndMenuBar );
  584. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  585. DockControlBar( &m_wndToolBarStandard );
  586. DockControlBar( &m_wndToolBarCustom );
  587. DockControlBar( &m_wndPalette, AFX_IDW_DOCKBAR_LEFT );
  588. DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );
  589. }
  590. g_CmdManager->SerializeState(
  591. pApp->m_pszProfileName,
  592. pApp->m_pszRegistryKey,
  593. pApp->m_pszProfileName,
  594. false
  595. );
  596. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  597. if( !m_wndMdiTabs.Create( this ) )
  598. {
  599. ASSERT( FALSE );
  600. return -1;
  601. }
  602. m_wndMdiTabs.ModifyTabWndStyle(
  603. 0,
  604. __ETWS_ONENOTE_DEFAULT
  605. | __ETWS_SHOW_BTN_TAB_LIST
  606. | __ETWS_ENABLED_BTN_TAB_LIST
  607. | __ETWS_ITEM_DRAGGING
  608. | __ETWS_SHOW_BTN_CLOSE
  609. //|__ETWS_MULTI_ROW_COLUMN
  610. ,
  611. true
  612. );
  613. m_wndMdiTabs.ModifyTabWndStyleEx(
  614. 0,
  615. __ETWS_EX_CLOSE_ON_TABS|__ETWS_EX_CLOSE_ON_SELECTED_ONLY
  616. //|__ETWS_EX_EXTENDED_ITEM_DRAGGING|__ETWS_EX_TAB_SHAPE_ITEM_DRAGGING
  617. );
  618. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  619. return 0;
  620. }
  621. /////////////////////////////////////////////////////////////////////////////
  622. // CMainFrame diagnostics
  623. #ifdef _DEBUG
  624. void CMainFrame::AssertValid() const
  625. {
  626. CExtNCW < CMDIFrameWnd > :: AssertValid();
  627. }
  628. void CMainFrame::Dump(CDumpContext& dc) const
  629. {
  630. CExtNCW < CMDIFrameWnd > :: Dump(dc);
  631. }
  632. #endif //_DEBUG
  633. /////////////////////////////////////////////////////////////////////////////
  634. // CMainFrame message handlers
  635. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  636. {
  637. if( m_wndToolBarUiLook.PreTranslateMessage( pMsg ) )
  638. return TRUE;
  639. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  640. if( m_wndMenuBar.TranslateMainFrameMessage( pMsg ) )
  641. return TRUE;
  642. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  643. return CExtNCW < CMDIFrameWnd > :: PreTranslateMessage( pMsg );
  644. }
  645. BOOL CMainFrame::DestroyWindow() 
  646. {
  647. CWinApp * pApp = ::AfxGetApp();
  648. ASSERT( pApp != NULL );
  649. ASSERT( pApp->m_pszRegistryKey != NULL );
  650. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  651. ASSERT( pApp->m_pszProfileName != NULL );
  652. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  653. VERIFY(
  654. CExtControlBar::ProfileBarStateSave(
  655. this,
  656. pApp->m_pszRegistryKey,
  657. pApp->m_pszProfileName,
  658. pApp->m_pszProfileName
  659. )
  660. );
  661. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  662. VERIFY(
  663. CExtCustomizeSite::CustomizeStateSave(
  664. pApp->m_pszRegistryKey,
  665. pApp->m_pszProfileName,
  666. pApp->m_pszProfileName
  667. )
  668. );
  669. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  670. VERIFY(
  671. g_CmdManager->SerializeState(
  672. pApp->m_pszProfileName,
  673. pApp->m_pszRegistryKey,
  674. pApp->m_pszProfileName,
  675. true
  676. )
  677. );
  678. VERIFY(
  679. g_PaintManager.PaintManagerStateSave(
  680. pApp->m_pszRegistryKey,
  681. pApp->m_pszProfileName,
  682. pApp->m_pszProfileName
  683. )
  684. );
  685. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  686. return CExtNCW < CMDIFrameWnd > :: DestroyWindow();
  687. }
  688. void CMainFrame::ActivateFrame(int nCmdShow) 
  689. {
  690. // window placement persistence
  691. if( m_dataFrameWP.showCmd != SW_HIDE )
  692. {
  693. SetWindowPlacement( &m_dataFrameWP );
  694. CExtNCW < CMDIFrameWnd > :: ActivateFrame( m_dataFrameWP.showCmd );
  695. m_dataFrameWP.showCmd = SW_HIDE;
  696. return;
  697. }
  698. CExtNCW < CMDIFrameWnd > :: ActivateFrame(nCmdShow);
  699. }
  700. void CMainFrame::RecalcLayout(BOOL bNotify)
  701. {
  702. CExtNCW < CMDIFrameWnd > :: RecalcLayout(bNotify);
  703. }
  704. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  705. {
  706. if( ! CExtNCW < CMDIFrameWnd > :: PreCreateWindow( cs ) )
  707. return FALSE;
  708. cs.lpszClass = ::AfxRegisterWndClass(CS_DBLCLKS);
  709. ASSERT( cs.lpszClass != NULL );
  710. cs.style =
  711. WS_OVERLAPPED|WS_CAPTION|WS_THICKFRAME|WS_SYSMENU
  712. |WS_MINIMIZEBOX|WS_MAXIMIZEBOX
  713. |FWS_ADDTOTITLE
  714. ;
  715. cs.dwExStyle &= ~ (WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
  716. return TRUE;
  717. }
  718. LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
  719. {
  720. //////////////////////////////////////////////////////////////////////////
  721. // Add "Windows..." command
  722. //////////////////////////////////////////////////////////////////////////
  723. CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
  724. reinterpret_cast
  725. < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
  726. ( wParam );
  727. ASSERT( pData != NULL );
  728. CExtPopupMenuWnd * pPopup = pData->m_pPopup;
  729. ASSERT( pPopup != NULL );
  730. INT nItemPos;
  731. INT nNewPos = -1;
  732. nItemPos = pPopup->ItemFindPosForCmdID( __ID_MDIWND_DLGWINDOWS );
  733. if( nItemPos > 0 )
  734. {
  735. // "More Windows..." command found
  736. pPopup->ItemRemove( nItemPos );
  737. nNewPos = nItemPos;
  738. }
  739. else
  740. {
  741. int nMaxCmdID = 0;
  742. for( int nCmdID = __ID_MDIWNDLIST_FIRST; nCmdID <= __ID_MDIWNDLIST_LAST; nCmdID++ ){
  743. nItemPos = pPopup->ItemFindPosForCmdID( nCmdID );
  744. if( nItemPos > 0 ){
  745. if( nCmdID > nMaxCmdID ){
  746. nMaxCmdID = nCmdID;
  747. nNewPos = nItemPos;
  748. }
  749. }
  750. }
  751. if( nNewPos > 0 ){
  752. pPopup->ItemInsert(
  753. (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR,
  754. ++nNewPos
  755. );
  756. nNewPos++;
  757. }
  758. }
  759. if( nNewPos > 0 )
  760. {
  761. UINT nCmdID = ID_WINDOWS_LIST;
  762. CExtCmdItem * pCmdItem =
  763. g_CmdManager->CmdGetPtr(
  764. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ),
  765. nCmdID
  766. );
  767. if( pCmdItem == NULL ){
  768. pCmdItem = 
  769. g_CmdManager->CmdAllocPtr( 
  770. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), 
  771. nCmdID 
  772. );
  773. }
  774. ASSERT( pCmdItem != NULL );
  775. if( pCmdItem != NULL )
  776. {
  777. CString sMoreWindows(_T("Windows..."));
  778. CString sManageWindows(_T("Manages the currently open windows"));
  779. pCmdItem->m_sMenuText = sMoreWindows;
  780. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  781. pCmdItem->m_sTipTool = sManageWindows;
  782. pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
  783. pCmdItem->StateSetBasic( true );
  784. pPopup->ItemInsert(
  785. nCmdID,
  786. nNewPos,
  787. __EXT_MFC_SAFE_LPCTSTR(sMoreWindows),
  788. NULL,
  789. m_hWnd
  790. );
  791. }
  792. }
  793. //////////////////////////////////////////////////////////////////////////
  794. CFrameWnd * pFrame = GetActiveFrame();
  795. CView * pView = NULL;
  796. if( pFrame != this && pFrame != NULL )
  797. {
  798. ASSERT_VALID( pFrame );
  799. pView = pFrame->GetActiveView();
  800. }
  801. if( pView == NULL )
  802. {
  803. return FALSE;
  804. }
  805. ASSERT_VALID( pView );
  806. return
  807. pView->SendMessage(
  808. CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel,
  809. wParam,
  810. lParam
  811. );
  812. }
  813. LRESULT CMainFrame::OnDrawPopupMenuItem(WPARAM wParam, LPARAM lParam)
  814. {
  815. CFrameWnd * pFrame = GetActiveFrame();
  816. CView * pView = NULL;
  817. if( pFrame != this && pFrame != NULL )
  818. {
  819. ASSERT_VALID( pFrame );
  820. pView = pFrame->GetActiveView();
  821. }
  822. if( pView == NULL )
  823. {
  824. return FALSE;
  825. }
  826. ASSERT_VALID( pView );
  827. return
  828. pView->SendMessage(
  829. CExtPopupMenuWnd::g_nMsgPopupDrawItem,
  830. wParam,
  831. lParam
  832. );
  833. }
  834. LRESULT CMainFrame::OnColorChangedFinally(WPARAM wParam, LPARAM lParam)
  835. {
  836. CFrameWnd * pFrame = GetActiveFrame();
  837. CView * pView = NULL;
  838. if( pFrame != this && pFrame != NULL )
  839. {
  840. ASSERT_VALID( pFrame );
  841. pView = pFrame->GetActiveView();
  842. }
  843. if( pView == NULL )
  844. {
  845. return FALSE;
  846. }
  847. ASSERT_VALID( pView );
  848. return
  849. pView->SendMessage(
  850. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  851. wParam,
  852. lParam
  853. );
  854. }
  855. LRESULT CMainFrame::OnColorSelectCustom(WPARAM wParam, LPARAM lParam)
  856. {
  857. CFrameWnd * pFrame = GetActiveFrame();
  858. CView * pView = NULL;
  859. if( pFrame != this && pFrame != NULL )
  860. {
  861. ASSERT_VALID( pFrame );
  862. pView = pFrame->GetActiveView();
  863. }
  864. if( pView == NULL )
  865. {
  866. return FALSE;
  867. }
  868. ASSERT_VALID( pView );
  869. return
  870. pView->SendMessage(
  871. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  872. wParam,
  873. lParam
  874. );
  875. }
  876. void CMainFrame::OnMditabsTop() 
  877. {
  878. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  879. m_wndMdiTabs.OrientationSet( __ETWS_ORIENT_TOP );
  880. RecalcLayout();
  881. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  882. }
  883. void CMainFrame::OnUpdateMditabsTop(CCmdUI* pCmdUI) 
  884. {
  885. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  886. pCmdUI->Enable( FALSE );
  887. #else
  888. pCmdUI->SetRadio(
  889. (m_wndMdiTabs.OrientationGet() == __ETWS_ORIENT_TOP) ? TRUE : FALSE
  890. );
  891. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  892. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  893. }
  894. void CMainFrame::OnMditabsBottom() 
  895. {
  896. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  897. m_wndMdiTabs.OrientationSet( __ETWS_ORIENT_BOTTOM );
  898. RecalcLayout();
  899. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  900. }
  901. void CMainFrame::OnUpdateMditabsBottom(CCmdUI* pCmdUI) 
  902. {
  903. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  904. pCmdUI->Enable( FALSE );
  905. #else
  906. pCmdUI->SetRadio(
  907. (m_wndMdiTabs.OrientationGet() == __ETWS_ORIENT_BOTTOM) ? TRUE : FALSE
  908. );
  909. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  910. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  911. }
  912. void CMainFrame::OnMditabsLeft() 
  913. {
  914. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  915. m_wndMdiTabs.OrientationSet( __ETWS_ORIENT_LEFT );
  916. RecalcLayout();
  917. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  918. }
  919. void CMainFrame::OnUpdateMditabsLeft(CCmdUI* pCmdUI) 
  920. {
  921. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  922. pCmdUI->Enable( FALSE );
  923. #else
  924. pCmdUI->SetRadio(
  925. (m_wndMdiTabs.OrientationGet() == __ETWS_ORIENT_LEFT) ? TRUE : FALSE
  926. );
  927. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  928. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  929. }
  930. void CMainFrame::OnMditabsRight() 
  931. {
  932. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  933. m_wndMdiTabs.OrientationSet( __ETWS_ORIENT_RIGHT );
  934. RecalcLayout();
  935. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  936. }
  937. void CMainFrame::OnUpdateMditabsRight(CCmdUI* pCmdUI) 
  938. {
  939. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  940. pCmdUI->Enable( FALSE );
  941. #else
  942. pCmdUI->SetRadio(
  943. (m_wndMdiTabs.OrientationGet() == __ETWS_ORIENT_RIGHT) ? TRUE : FALSE
  944. );
  945. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  946. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  947. }
  948. void CMainFrame::OnMditabsShowClose() 
  949. {
  950. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  951. if( m_wndMdiTabs.GetTabWndStyle() & __ETWS_SHOW_BTN_CLOSE )
  952. m_wndMdiTabs.ModifyTabWndStyle( __ETWS_SHOW_BTN_CLOSE, 0, true );
  953. else
  954. m_wndMdiTabs.ModifyTabWndStyle( 0, __ETWS_SHOW_BTN_CLOSE, true );
  955. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  956. }
  957. void CMainFrame::OnUpdateMditabsShowClose(CCmdUI* pCmdUI) 
  958. {
  959. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  960. pCmdUI->Enable( FALSE );
  961. #else
  962. pCmdUI->SetCheck(
  963. (m_wndMdiTabs.GetTabWndStyle() & __ETWS_SHOW_BTN_CLOSE) ? TRUE : FALSE
  964. );
  965. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  966. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  967. }
  968. void CMainFrame::OnMditabsShowCtxHelp() 
  969. {
  970. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  971. if( m_wndMdiTabs.GetTabWndStyle() & __ETWS_SHOW_BTN_HELP )
  972. m_wndMdiTabs.ModifyTabWndStyle( __ETWS_SHOW_BTN_HELP, 0, true );
  973. else
  974. m_wndMdiTabs.ModifyTabWndStyle( 0, __ETWS_SHOW_BTN_HELP, true );
  975. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  976. }
  977. void CMainFrame::OnUpdateMditabsShowCtxHelp(CCmdUI* pCmdUI) 
  978. {
  979. #if (defined __EXT_MFC_NO_TABMDI_CTRL)
  980. pCmdUI->Enable( FALSE );
  981. #else
  982. pCmdUI->SetCheck(
  983. (m_wndMdiTabs.GetTabWndStyle() & __ETWS_SHOW_BTN_HELP) ? TRUE : FALSE
  984. );
  985. pCmdUI->Enable( m_wndMdiTabs.GetSafeHwnd() != NULL && m_wndMdiTabs.IsWindowVisible() );
  986. #endif // else from (defined __EXT_MFC_NO_TABMDI_CTRL)
  987. }
  988. void CMainFrame::OnContextHelp() 
  989. {
  990. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  991. if( CExtCustomizeSite::IsCustomizeMode() )
  992. return;
  993. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  994. theApp.DoContextHelp();
  995. }
  996. void CMainFrame::OnUpdateContextHelp(CCmdUI* pCmdUI) 
  997. {
  998. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  999. if( CExtCustomizeSite::IsCustomizeMode() )
  1000. {
  1001. pCmdUI->Enable( FALSE );
  1002. return;
  1003. } // if( CExtCustomizeSite::IsCustomizeMode() )
  1004. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  1005. pCmdUI->Enable( TRUE );
  1006. }
  1007. void CMainFrame::OnCustomize() 
  1008. {
  1009. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  1010. CExtCustomizeSite::DoFormCustomization();
  1011. #endif
  1012. }
  1013. void CMainFrame::OnUpdateCustomize(CCmdUI* pCmdUI) 
  1014. {
  1015. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  1016. pCmdUI->Enable( TRUE );
  1017. #else
  1018. pCmdUI->Enable( FALSE );
  1019. #endif
  1020. }
  1021. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  1022. bool CMainFrame::OnColorItemValueGet(
  1023. CExtBarColorButton * pTBB,
  1024. CExtCustomizeCmdTreeNode * pNode,
  1025. COLORREF & clr,
  1026. bool bSelected
  1027. )
  1028. {
  1029. ASSERT_VALID( pNode );
  1030. pTBB;
  1031. UINT nCmdID = pNode->GetCmdID(false);
  1032. if( nCmdID == ID_OBJECT_FILLCOLOR )
  1033. {
  1034. CFrameWnd * pFrame = GetActiveFrame();
  1035. if( pFrame == NULL )
  1036. return false;
  1037. CDrawView * pView = (CDrawView *)pFrame->GetActiveView();
  1038. if( pView == NULL )
  1039. return false;
  1040. POSITION pos = pView->m_selection.GetHeadPosition();
  1041. if( pos == NULL )
  1042. return false;
  1043. CDrawObj * pObj = pView->m_selection.GetNext( pos );
  1044. ASSERT( pObj != NULL );
  1045. if( bSelected )
  1046. clr = pObj->IsNoFill() ? COLORREF(-1) : pObj->GetFillColor();
  1047. else
  1048. clr = COLORREF(-1);
  1049. return true;
  1050. } // if( nCmdID == ID_OBJECT_FILLCOLOR )
  1051. if( nCmdID == ID_OBJECT_LINECOLOR )
  1052. {
  1053. CFrameWnd * pFrame = GetActiveFrame();
  1054. if( pFrame == NULL )
  1055. return false;
  1056. CDrawView * pView = (CDrawView *)pFrame->GetActiveView();
  1057. if( pView == NULL )
  1058. return false;
  1059. POSITION pos = pView->m_selection.GetHeadPosition();
  1060. if( pos == NULL )
  1061. return false;
  1062. CDrawObj * pObj = pView->m_selection.GetNext( pos );
  1063. ASSERT( pObj != NULL );
  1064. if( bSelected )
  1065. clr = pObj->IsNoOutline() ? COLORREF(-1) : pObj->GetLineColor();
  1066. else
  1067. clr = COLORREF(-1);
  1068. return true;
  1069. } // if( nCmdID == ID_OBJECT_LINECOLOR )
  1070. return CExtCustomizeSite::OnColorItemValueGet( pTBB, pNode, clr, bSelected );
  1071. }
  1072. bool CMainFrame::OnColorItemValueSet(
  1073. CExtBarColorButton * pTBB,
  1074. CExtCustomizeCmdTreeNode * pNode,
  1075. COLORREF & clr,
  1076. bool bSelected
  1077. )
  1078. {
  1079. ASSERT_VALID( pNode );
  1080. pTBB;
  1081. bSelected;
  1082. UINT nCmdID = pNode->GetCmdID(false);
  1083. CFrameWnd * pFrame = GetActiveFrame();
  1084. if( pFrame == NULL )
  1085. return false;
  1086. CDrawView * pView = (CDrawView *)pFrame->GetActiveView();
  1087. if( pView == NULL )
  1088. return false;
  1089. POSITION pos = pView->m_selection.GetHeadPosition();
  1090. if( pos == NULL )
  1091. return false;
  1092. while( pos != NULL )
  1093. {
  1094. CDrawObj * pObj = pView->m_selection.GetNext( pos );
  1095. ASSERT( pObj != NULL );
  1096. switch( nCmdID )
  1097. {
  1098. case ID_OBJECT_FILLCOLOR:
  1099. if( clr == COLORREF(-1) )
  1100. pObj->SetNoFill();
  1101. else
  1102. {
  1103. pObj->SetNoFill( FALSE );
  1104. pObj->SetFillColor( clr );
  1105. }
  1106. break;
  1107. case ID_OBJECT_LINECOLOR:
  1108. if( clr == COLORREF(-1) )
  1109. pObj->SetNoOutline();
  1110. else
  1111. {
  1112. pObj->SetNoOutline( FALSE );
  1113. pObj->SetLineColor( clr );
  1114. }
  1115. break;
  1116. } // pView->
  1117. }
  1118. pView->Invalidate();
  1119. pView->UpdateWindow();
  1120. CExtCustomizeSite::RedrawCommandItems( nCmdID );
  1121. return true;
  1122. }
  1123. CExtBarButton * CMainFrame::OnCreateToolbarButton(
  1124. CExtToolControlBar * pBar,
  1125. CExtCustomizeCmdTreeNode * pNodeI,
  1126. CExtCustomizeCmdTreeNode * pNodeC
  1127. )
  1128. {
  1129. ASSERT_VALID( this );
  1130. ASSERT_VALID( pBar );
  1131. #ifdef _DEBUG
  1132. if( pNodeI != NULL )
  1133. {
  1134. ASSERT_VALID( pNodeI );
  1135. ASSERT( pNodeI->GetCmdID(false) != ID_SEPARATOR );
  1136. }
  1137. #endif // _DEBUG
  1138. ASSERT_VALID( pNodeC );
  1139. ASSERT( pNodeC->GetCmdID(false) != ID_SEPARATOR );
  1140. CExtBarButton * pTBB = NULL;
  1141. switch( pNodeC->GetCmdID(false) )
  1142. {
  1143. case ID_OBJECT_FILLCOLOR:
  1144. {
  1145. CString sNoFill;
  1146. VERIFY( sNoFill.LoadString( IDS_STRING_NO_COLOR_FILL ) );
  1147. pTBB =
  1148. new CExtBarColorButton(
  1149. pBar,
  1150. ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1151. ID_OBJECT_FILLCOLOR, true, true,
  1152. (LPCTSTR)sNoFill, NULL,
  1153. CExtBarColorButton::__DIT_CHAR_2007
  1154. );
  1155. ASSERT_VALID( pTBB );
  1156. //pTBB->SetSeparatedDropDown();
  1157. break;
  1158. } // case ID_OBJECT_FILLCOLOR:
  1159. case ID_OBJECT_LINECOLOR:
  1160. {
  1161. CString sNoOutline;
  1162. VERIFY( sNoOutline.LoadString( IDS_STRING_NO_COLOR_OUTLINE ) );
  1163. pTBB =
  1164. new CExtBarColorButton(
  1165. pBar,
  1166. ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1167. ID_OBJECT_LINECOLOR, true, true,
  1168. (LPCTSTR)sNoOutline, NULL,
  1169. CExtBarColorButton::__DIT_FRAME
  1170. );
  1171. ASSERT_VALID( pTBB );
  1172. break;
  1173. } // ID_OBJECT_LINECOLOR
  1174. } // switch( pNodeC->GetCmdID(false) )
  1175. if( pTBB != NULL )
  1176. {
  1177. ASSERT_VALID( pTBB );
  1178. if( pNodeI != NULL )
  1179. {
  1180. pTBB->SetBasicCmdNode( pNodeI );
  1181. pTBB->OnCustomizeUpdateProps( pNodeI );
  1182. } // if( pNodeI != NULL )
  1183. else
  1184. pTBB->OnCustomizeUpdateProps( pNodeC );
  1185. pTBB->SetCustomizedCmdNode( pNodeC );
  1186. return pTBB;
  1187. } // if( pTBB != NULL )
  1188. return CExtCustomizeSite::OnCreateToolbarButton( pBar, pNodeI, pNodeC );
  1189. }
  1190. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  1191. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  1192. {
  1193. #ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG
  1194. if( nCode == CN_COMMAND )
  1195. {
  1196. if( nID == ID_WINDOWS_LIST )
  1197. {
  1198. CMyMdiWindowsListDlg dlgMdiWindowsList( this );
  1199. dlgMdiWindowsList.DoModal();
  1200. return TRUE;
  1201. }
  1202. }
  1203. #endif // #ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG
  1204. return CExtNCW < CMDIFrameWnd > :: OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  1205. }
  1206. /////////////////////////////////////////////////////////////////////////////
  1207. // CDrawInPlaceFrame
  1208. IMPLEMENT_DYNCREATE(CDrawInPlaceFrame, COleIPFrameWnd)
  1209. BEGIN_MESSAGE_MAP(CDrawInPlaceFrame, COleIPFrameWnd)
  1210. //{{AFX_MSG_MAP(CDrawInPlaceFrame)
  1211. ON_WM_CREATE()
  1212. ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)
  1213. ON_UPDATE_COMMAND_UI(ID_CONTEXT_HELP, OnUpdateContextHelp)
  1214. //}}AFX_MSG_MAP
  1215. #if (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  1216. // ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
  1217. // ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)
  1218. #endif // (!defined __SAMPLE_APP_USES_STD_MENU_LINE)
  1219. ON_COMMAND_EX(ID_VIEW_TOOLBAR2, OnBarCheck )
  1220. ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR2, OnUpdateControlBarMenu)
  1221. ON_COMMAND_EX(ID_VIEW_PALETTE, OnBarCheck )
  1222. ON_UPDATE_COMMAND_UI(ID_VIEW_PALETTE, OnUpdateControlBarMenu)
  1223. ON_COMMAND_EX(ID_VIEW_UI_LOOK_BAR, OnBarCheck )
  1224. ON_UPDATE_COMMAND_UI(ID_VIEW_UI_LOOK_BAR, OnUpdateControlBarMenu)
  1225. ON_REGISTERED_MESSAGE(
  1226. CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel,
  1227. OnExtMenuPrepare
  1228. )
  1229. ON_REGISTERED_MESSAGE(
  1230. CExtPopupMenuWnd::g_nMsgPopupDrawItem,
  1231. OnDrawPopupMenuItem
  1232. )
  1233. // color popup menu
  1234. ON_REGISTERED_MESSAGE(
  1235. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  1236. OnColorChangedFinally
  1237. )
  1238. ON_REGISTERED_MESSAGE(
  1239. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  1240. OnColorSelectCustom
  1241. )
  1242. END_MESSAGE_MAP()
  1243. /////////////////////////////////////////////////////////////////////////////
  1244. // CDrawInPlaceFrame construction/destruction
  1245. CDrawInPlaceFrame::CDrawInPlaceFrame()
  1246. {
  1247. m_strSerializableProfileName = _T("DrawInPlaceFrame");
  1248. m_strCmdProfileName.Format( _T("%s - %p"), LPCTSTR(m_strSerializableProfileName), this );
  1249. }
  1250. CDrawInPlaceFrame::~CDrawInPlaceFrame()
  1251. {
  1252. }
  1253. int CDrawInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  1254. {
  1255. if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1)
  1256. return -1;
  1257. // CResizeBar implements in-place resizing.
  1258. if (!m_wndResizeBar.Create(this))
  1259. {
  1260. TRACE0("Failed to create resize barn");
  1261. return -1;      // fail to create
  1262. }
  1263. // By default, it is a good idea to register a drop-target that does
  1264. //  nothing with your frame window.  This prevents drops from
  1265. //  "falling through" to a container that supports drag-drop.
  1266. m_dropTarget.Register(this);
  1267. return 0;
  1268. }
  1269. // OnCreateControlBars is called by the framework to create control bars on the
  1270. //  container application's windows.  pWndFrame is the top level frame window of
  1271. //  the container and is always non-NULL.  pWndDoc is the doc level frame window
  1272. //  and will be NULL when the container is an SDI application.  A server
  1273. //  application can place MFC control bars on either window.
  1274. BOOL CDrawInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* pWndDoc)
  1275. {
  1276. // Remove this if you use pWndDoc
  1277. UNREFERENCED_PARAMETER(pWndDoc);
  1278. g_CmdManager->ProfileSetup( m_strCmdProfileName, m_hWnd );
  1279. g_CmdManager->ProfileWndAdd( m_strCmdProfileName, pWndFrame->m_hWnd );
  1280. if( pWndDoc != NULL )
  1281. g_CmdManager->ProfileWndAdd( m_strCmdProfileName, pWndDoc->m_hWnd );
  1282. VERIFY( g_CmdManager->UpdateFromMenu( m_strCmdProfileName, IDR_MAINFRAME ) );
  1283. VERIFY( g_CmdManager->UpdateFromMenu( m_strCmdProfileName, IDR_DRAWCLTYPE ) );
  1284. VERIFY( g_CmdManager->UpdateFromToolBar( m_strCmdProfileName, IDR_TOOLBAR_HELPER_ICONS ) );
  1285. if( (! m_wndToolBarStandard.Create( NULL, pWndFrame, AFX_IDW_TOOLBAR ) )
  1286. || (! m_wndToolBarStandard.LoadToolBar( IDR_MAINFRAME ) )
  1287. )
  1288. {
  1289. TRACE0("Failed to create standard toolbarn");
  1290. return -1;      // fail to create
  1291. }
  1292. if( (! m_wndToolBarUiLook.Create( NULL, pWndFrame, ID_VIEW_UI_LOOK_BAR ) )
  1293. || (! m_wndToolBarUiLook.ThemeSwitcherInit() )
  1294. )
  1295. {
  1296. TRACE0("Failed to create UI look switcher toolbarn");
  1297. return -1;      // fail to create
  1298. }
  1299. LPCTSTR strProfileName =
  1300. g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() );
  1301. ASSERT( strProfileName != NULL );
  1302. CExtCmdItem * pCmdItem =
  1303. g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_FILLCOLOR );
  1304. ASSERT( pCmdItem != NULL );
  1305. pCmdItem->StateSetPersistentIcon();
  1306. pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
  1307. pCmdItem->StateSetColor();
  1308. pCmdItem->StateSetColorBtnDefault();
  1309. pCmdItem->StateSetColorBtnCustom();
  1310. pCmdItem->StateSetNoRotateVL();
  1311. pCmdItem->StateSetSeparatedDD();
  1312. pCmdItem =
  1313. g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_LINECOLOR );
  1314. ASSERT( pCmdItem != NULL );
  1315. pCmdItem->StateSetPersistentIcon();
  1316. pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
  1317. pCmdItem->StateSetColor();
  1318. pCmdItem->StateSetColorBtnDefault();
  1319. pCmdItem->StateSetColorBtnCustom();
  1320. pCmdItem->StateSetNoRotateVL();
  1321. pCmdItem =
  1322. g_CmdManager->CmdGetPtr( strProfileName, ID_DOC_LINE_WIDTH );
  1323. ASSERT( pCmdItem != NULL );
  1324. pCmdItem->m_sMenuText = _T("Line &Width");
  1325. pCmdItem->StateSetPersistentIcon();
  1326. INT nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_DOC_LINE_WIDTH);
  1327. ASSERT( nBtnIdx >= 0 );
  1328. CMenu _line_menu;
  1329. VERIFY( _line_menu.LoadMenu(IDR_MENU_LW) );
  1330. VERIFY( m_wndToolBarStandard.SetButtonMenu( nBtnIdx, _line_menu.Detach() ) );
  1331. CExtBarButton * pTBB = m_wndToolBarStandard.GetButton(nBtnIdx);
  1332. ASSERT_VALID( pTBB );
  1333. pTBB->SetNoRotateVerticalLayout();
  1334. pTBB->SetSeparatedDropDown();
  1335. pTBB->SetAutoChangeID();
  1336. pTBB->SetCmdID(ID_LINE_WIDTH_1,true); // set default effective command
  1337. CString sNoFill;
  1338. VERIFY( sNoFill.LoadString( IDS_STRING_NO_COLOR_FILL ) );
  1339. CString sNoOutline;
  1340. VERIFY( sNoOutline.LoadString( IDS_STRING_NO_COLOR_OUTLINE ) );
  1341. nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_FILLCOLOR);
  1342. VERIFY(
  1343. m_wndToolBarStandard.RemoveButton(
  1344. nBtnIdx,
  1345. FALSE
  1346. )
  1347. );
  1348. m_pBtnColorFillS =
  1349. new CExtBarColorButton(
  1350. &m_wndToolBarStandard,
  1351. ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1352. ID_OBJECT_FILLCOLOR, true, true,
  1353. (LPCTSTR)sNoFill, NULL,
  1354. CExtBarColorButton::__DIT_CHAR_2007
  1355. );
  1356. m_pBtnColorFillS->SetSeparatedDropDown();
  1357. VERIFY(
  1358. m_wndToolBarStandard.InsertSpecButton(
  1359. nBtnIdx,
  1360. m_pBtnColorFillS,
  1361. FALSE
  1362. )
  1363. );
  1364. nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_LINECOLOR);
  1365. m_wndToolBarStandard.SetButtonCtrlVisibleVertically( nBtnIdx, true );
  1366. VERIFY(
  1367. m_wndToolBarStandard.RemoveButton(
  1368. nBtnIdx,
  1369. FALSE
  1370. )
  1371. );
  1372. m_pBtnColorOutlineS =
  1373. new CExtBarColorButton(
  1374. &m_wndToolBarStandard,
  1375. ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1376. ID_OBJECT_LINECOLOR, true, true,
  1377. (LPCTSTR)sNoOutline, NULL,
  1378. CExtBarColorButton::__DIT_FRAME
  1379. );
  1380. VERIFY(
  1381. m_wndToolBarStandard.InsertSpecButton(
  1382. nBtnIdx,
  1383. m_pBtnColorOutlineS,
  1384. FALSE
  1385. )
  1386. );
  1387. if( !m_wndToolBarCustom.Create(
  1388. NULL,
  1389. pWndFrame,
  1390. ID_VIEW_TOOLBAR2
  1391. )
  1392. || !m_wndToolBarCustom.InitContentExpandButton()
  1393. )
  1394. {
  1395. TRACE0("Failed to create custom toolbarn");
  1396. return -1;      // fail to create
  1397. }
  1398. static struct
  1399. {
  1400. UINT m_nCmdID;
  1401. LPCTSTR m_sToolbarText;
  1402. }
  1403. custom_toolbar_cmds[] =
  1404. {
  1405. { ID_OBJECT_MOVETOFRONT, _T("Move to front") },
  1406. { ID_OBJECT_MOVETOBACK, _T("Move to back") },
  1407. { ID_SEPARATOR, NULL },
  1408. { ID_OBJECT_MOVEFORWARD, NULL },
  1409. { ID_OBJECT_MOVEBACK, NULL },
  1410. };
  1411. for( INT nCustBarIdx = 0;
  1412. nCustBarIdx < sizeof(custom_toolbar_cmds)/sizeof(custom_toolbar_cmds[0]);
  1413. nCustBarIdx++
  1414. )
  1415. { // add buttons to custom toolbar
  1416. UINT nCmdID = custom_toolbar_cmds[nCustBarIdx].m_nCmdID;
  1417. if( nCmdID != ID_SEPARATOR )
  1418. {
  1419. LPCTSTR sToolBarBtnText =
  1420. custom_toolbar_cmds[nCustBarIdx].m_sToolbarText;
  1421. if( sToolBarBtnText != NULL )
  1422. {
  1423. CExtCmdItem * pCmdItem =
  1424. g_CmdManager->CmdGetPtr(
  1425. strProfileName,
  1426. nCmdID
  1427. );
  1428. ASSERT( pCmdItem != NULL );
  1429. pCmdItem->m_sToolbarText = sToolBarBtnText;
  1430. } // if( sToolBarBtnText != NULL )
  1431. HICON hIcon = (HICON)
  1432. ::LoadImage(
  1433. ::AfxGetInstanceHandle(),
  1434. MAKEINTRESOURCE( nCmdID ),
  1435. IMAGE_ICON,
  1436. 16,
  1437. 16,
  1438. 0
  1439. );
  1440. if( hIcon != NULL )
  1441. {
  1442. VERIFY(
  1443. g_CmdManager->CmdSetIcon(
  1444. g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),
  1445. nCmdID,
  1446. hIcon,
  1447. false
  1448. )
  1449. );
  1450. } // if( hIcon != NULL )
  1451. } // if( nCmdID != ID_SEPARATOR )
  1452. m_wndToolBarCustom.InsertButton( -1, nCmdID, FALSE );
  1453. } // add buttons to custom toolbar
  1454. m_wndPalette.m_bPaletteMode = true;
  1455. if( !m_wndPalette.Create(
  1456. NULL,
  1457. pWndFrame,
  1458. ID_VIEW_PALETTE
  1459. )
  1460. ||
  1461. !m_wndPalette.LoadToolBar(IDR_TOOLBAR_HELPER_ICONS)
  1462. )
  1463. {
  1464. TRACE0("Failed to create m_wndPalette toolbarn");
  1465. return -1;      // fail to create
  1466. }
  1467. m_wndPalette.InsertButton();
  1468. nBtnIdx = m_wndPalette.GetButtonsCount();
  1469. m_pBtnColorFillP =
  1470. new CExtBarColorButton(
  1471. &m_wndPalette,
  1472. ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1473. ID_OBJECT_FILLCOLOR, true, true,
  1474. (LPCTSTR)sNoFill, NULL,
  1475. CExtBarColorButton::__DIT_CHAR_2007
  1476. );
  1477. m_pBtnColorFillP->SetSeparatedDropDown();
  1478. VERIFY(
  1479. m_wndPalette.InsertSpecButton(
  1480. nBtnIdx,
  1481. m_pBtnColorFillP,
  1482. FALSE
  1483. )
  1484. );
  1485. nBtnIdx++;
  1486. m_pBtnColorOutlineP =
  1487. new CExtBarColorButton(
  1488. &m_wndPalette,
  1489. ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
  1490. ID_OBJECT_LINECOLOR, true, true,
  1491. (LPCTSTR)sNoOutline, NULL,
  1492. CExtBarColorButton::__DIT_FRAME
  1493. );
  1494. VERIFY(
  1495. m_wndPalette.InsertSpecButton(
  1496. nBtnIdx,
  1497. m_pBtnColorOutlineP,
  1498. FALSE
  1499. )
  1500. );
  1501. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_HORZ );
  1502. m_wndPalette.GetButton(  8 )->SetWrap( CExtBarButton::__EVT_HORZ );
  1503. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_HORZ );
  1504. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_VERT );
  1505. m_wndPalette.GetButton(  6 )->SetWrap( CExtBarButton::__EVT_VERT );
  1506. m_wndPalette.GetButton(  9 )->SetWrap( CExtBarButton::__EVT_VERT );
  1507. m_wndPalette.GetButton( 12 )->SetWrap( CExtBarButton::__EVT_VERT );
  1508. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_VERT );
  1509. m_wndPalette.GetButton(  3 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1510. m_wndPalette.GetButton(  5 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1511. m_wndPalette.GetButton(  7 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1512. m_wndPalette.GetButton(  9 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1513. m_wndPalette.GetButton( 11 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1514. m_wndPalette.GetButton( 14 )->SetWrap( CExtBarButton::__EVT_FLOAT );
  1515. m_wndToolBarStandard.EnableDocking(CBRS_ALIGN_ANY);
  1516. m_wndToolBarCustom.EnableDocking(CBRS_ALIGN_ANY);
  1517. m_wndPalette.EnableDocking(CBRS_ALIGN_ANY);
  1518. m_wndToolBarUiLook.EnableDocking(CBRS_ALIGN_ANY);
  1519. if( ! CExtControlBar::FrameEnableDocking( pWndFrame ) )
  1520. {
  1521. ASSERT( FALSE );
  1522. return -1;
  1523. }
  1524. VERIFY(
  1525. g_CmdManager->SetBasicCommands(
  1526. m_strCmdProfileName,
  1527. g_statBasicCommands
  1528. )
  1529. );
  1530. // g_CmdManager->CmdGetPtr(
  1531. // m_strCmdProfileName,
  1532. // ID_FILE_NEW
  1533. // )->StateSetCannotHide();
  1534. //CWinApp * pApp = ::AfxGetApp();
  1535. //  ASSERT( pApp != NULL );
  1536. // if( ! CExtControlBar::ProfileBarStateLoad(
  1537. // pWndFrame,
  1538. // pApp->m_pszRegistryKey,
  1539. // pApp->m_pszProfileName,
  1540. // m_strSerializableProfileName)
  1541. // )
  1542. {
  1543. pWndFrame->DockControlBar( &m_wndToolBarStandard );
  1544. pWndFrame->DockControlBar( &m_wndToolBarCustom );
  1545. pWndFrame->DockControlBar( &m_wndPalette, AFX_IDW_DOCKBAR_LEFT );
  1546. pWndFrame->DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );
  1547. }
  1548. //  g_CmdManager->SerializeState(
  1549. //  pApp->m_pszProfileName,
  1550. //  pApp->m_pszRegistryKey,
  1551. //  m_strSerializableProfileName,
  1552. //  false
  1553. //  );
  1554. m_wndToolBarStandard.SetOwner( this );
  1555. m_wndToolBarCustom.SetOwner( this );
  1556. m_wndPalette.SetOwner( this );
  1557. return TRUE;
  1558. }
  1559. BOOL CDrawInPlaceFrame::PreCreateWindow(CREATESTRUCT& cs)
  1560. {
  1561. // TODO: Modify the Window class or styles here by modifying
  1562. //  the CREATESTRUCT cs
  1563. return COleIPFrameWnd::PreCreateWindow(cs);
  1564. }
  1565. /////////////////////////////////////////////////////////////////////////////
  1566. // CDrawInPlaceFrame diagnostics
  1567. #ifdef _DEBUG
  1568. void CDrawInPlaceFrame::AssertValid() const
  1569. {
  1570. COleIPFrameWnd::AssertValid();
  1571. }
  1572. void CDrawInPlaceFrame::Dump(CDumpContext& dc) const
  1573. {
  1574. COleIPFrameWnd::Dump(dc);
  1575. }
  1576. #endif //_DEBUG
  1577. BOOL CDrawInPlaceFrame::DestroyWindow() 
  1578. {
  1579. //CWinApp * pApp = ::AfxGetApp();
  1580. // ASSERT( pApp != NULL );
  1581. // CExtControlBar::ProfileBarStateSave(
  1582. // this,
  1583. // pApp->m_pszRegistryKey,
  1584. // pApp->m_pszProfileName,
  1585. // m_strSerializableProfileName
  1586. // );
  1587. // g_CmdManager->SerializeState(
  1588. // pApp->m_pszProfileName,
  1589. // pApp->m_pszRegistryKey,
  1590. // m_strSerializableProfileName,
  1591. // true
  1592. // );
  1593. g_CmdManager->ProfileDestroy( m_strCmdProfileName, true );
  1594. return COleIPFrameWnd::DestroyWindow();
  1595. }
  1596. /////////////////////////////////////////////////////////////////////////////
  1597. // CDrawInPlaceFrame commands
  1598. LRESULT CDrawInPlaceFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
  1599. {
  1600. //////////////////////////////////////////////////////////////////////////
  1601. CFrameWnd * pFrame = GetActiveFrame();
  1602. CView * pView = NULL;
  1603. if( pFrame != NULL )
  1604. {
  1605. ASSERT_VALID( pFrame );
  1606. pView = pFrame->GetActiveView();
  1607. }
  1608. if( pView == NULL )
  1609. {
  1610. return FALSE;
  1611. }
  1612. ASSERT_VALID( pView );
  1613. return
  1614. pView->SendMessage(
  1615. CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel,
  1616. wParam,
  1617. lParam
  1618. );
  1619. }
  1620. LRESULT CDrawInPlaceFrame::OnDrawPopupMenuItem(WPARAM wParam, LPARAM lParam)
  1621. {
  1622. CFrameWnd * pFrame = GetActiveFrame();
  1623. CView * pView = NULL;
  1624. if( pFrame != NULL )
  1625. {
  1626. ASSERT_VALID( pFrame );
  1627. pView = pFrame->GetActiveView();
  1628. }
  1629. if( pView == NULL )
  1630. {
  1631. return FALSE;
  1632. }
  1633. ASSERT_VALID( pView );
  1634. return
  1635. pView->SendMessage(
  1636. CExtPopupMenuWnd::g_nMsgPopupDrawItem,
  1637. wParam,
  1638. lParam
  1639. );
  1640. }
  1641. LRESULT CDrawInPlaceFrame::OnColorChangedFinally(WPARAM wParam, LPARAM lParam)
  1642. {
  1643. CFrameWnd * pFrame = GetActiveFrame();
  1644. CView * pView = NULL;
  1645. if( pFrame != NULL )
  1646. {
  1647. ASSERT_VALID( pFrame );
  1648. pView = pFrame->GetActiveView();
  1649. }
  1650. if( pView == NULL )
  1651. {
  1652. return FALSE;
  1653. }
  1654. ASSERT_VALID( pView );
  1655. return
  1656. pView->SendMessage(
  1657. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  1658. wParam,
  1659. lParam
  1660. );
  1661. }
  1662. LRESULT CDrawInPlaceFrame::OnColorSelectCustom(WPARAM wParam, LPARAM lParam)
  1663. {
  1664. CFrameWnd * pFrame = GetActiveFrame();
  1665. CView * pView = NULL;
  1666. if( pFrame != NULL )
  1667. {
  1668. ASSERT_VALID( pFrame );
  1669. pView = pFrame->GetActiveView();
  1670. }
  1671. if( pView == NULL )
  1672. {
  1673. return FALSE;
  1674. }
  1675. ASSERT_VALID( pView );
  1676. return
  1677. pView->SendMessage(
  1678. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  1679. wParam,
  1680. lParam
  1681. );
  1682. }