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

界面编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "FunnyBars.h"
  5. #include "MainFrm.h"
  6. #include "ChildView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CFunnyToolButton
  14. IMPLEMENT_DYNAMIC( CFunnyToolButton, CExtBarButton );
  15. CFunnyToolButton::CFunnyToolButton(
  16. CExtToolControlBar * pBar,
  17. UINT nCmdID,
  18. LPCTSTR strFunnyText,
  19. double lfHotPercent
  20. ) : CExtBarButton( pBar, nCmdID, 0 )
  21. , m_strFunnyText( (strFunnyText==NULL) ? _T("") : strFunnyText )
  22. , m_sizeFunnyTextCalc( 0, 0 )
  23. , m_sizeFunnyTextWell( 0, 0 )
  24. , m_lfHotPercent( lfHotPercent )
  25. {
  26. }
  27. CSize CFunnyToolButton::CalculateLayout(
  28. CDC & dc,
  29. CSize sizePreCalc,
  30. BOOL bHorz
  31. )
  32. {
  33. ASSERT_VALID( this );
  34. CSize _size = CExtBarButton::CalculateLayout( dc, sizePreCalc, bHorz );
  35. ASSERT( !IsSeparator() );
  36. if( ! m_strFunnyText.IsEmpty() )
  37. {
  38. CFont * pOldFont = dc.SelectObject( &g_PaintManager->m_FontNormal );
  39. CRect rcMeasured( 0, 0, 0, 0 );
  40. dc.DrawText( m_strFunnyText, &rcMeasured, DT_LEFT|DT_CALCRECT );
  41. m_sizeFunnyTextWell = rcMeasured.Size();
  42. m_sizeFunnyTextWell.cx += __EXT_TB_BUTTON_TEXT_MARGIN*2;
  43. static CString strMeasureTemplate( _T("AapqWZznAapqWZz") );
  44. dc.DrawText( strMeasureTemplate, &rcMeasured, DT_LEFT|DT_CALCRECT );
  45. dc.SelectObject( pOldFont );
  46. m_sizeFunnyTextCalc = rcMeasured.Size();
  47. m_sizeFunnyTextCalc.cx += __EXT_TB_BUTTON_TEXT_MARGIN*2;
  48. m_sizeFunnyTextCalc.cx = max( m_sizeFunnyTextWell.cx, m_sizeFunnyTextCalc.cy );
  49. m_sizeFunnyTextCalc.cy = max( m_sizeFunnyTextWell.cy, m_sizeFunnyTextCalc.cy );
  50. m_sizeFunnyTextCalc.cx += __EXT_TB_BUTTON_INNER_MARGIN*2;
  51. _size.cx = max( m_sizeFunnyTextCalc.cx, _size.cx );
  52. _size.cy += m_sizeFunnyTextCalc.cy + 4;
  53. } // if( ! m_strFunnyText.IsEmpty() )
  54. m_ActiveSize = _size;
  55. return m_ActiveSize;
  56. }
  57. void CFunnyToolButton::PaintCompound(
  58. CDC & dc,
  59. bool bPaintParentChain,
  60. bool bPaintChildren,
  61. bool bPaintOneNearestChildrenLevelOnly
  62. )
  63. {
  64. ASSERT_VALID( this );
  65. ASSERT( dc.GetSafeHdc() != NULL );
  66. CExtToolControlBar * pBar = GetBar();
  67. ASSERT_VALID( pBar );
  68. if( (m_pCtrl != NULL) && (!m_bVertDocked || GetCtrlVisibleVertically()) )
  69. return;
  70. ASSERT( ! IsSeparator() );
  71. if( ! IsPaintAble( dc ) )
  72. return;
  73. if( AnimationClient_StatePaint( dc ) )
  74. return;
  75. if( bPaintParentChain )
  76. PaintParentChain( dc );
  77. CRect rcArea( m_ActiveRect );
  78. rcArea.DeflateRect( __EXT_TB_BUTTON_INNER_MARGIN, __EXT_TB_BUTTON_INNER_MARGIN );
  79. if( (!IsVisible())
  80. || rcArea.right <= rcArea.left || rcArea.bottom <= rcArea.top
  81. || (GetStyle() & TBBS_HIDDEN) != 0
  82. || (!dc.RectVisible(&m_ActiveRect))
  83. )
  84. return;
  85. bool bPushed = IsPressed() ? true : false;
  86. bool bEnabled = IsDisabled() ? false : true;
  87. bool bHover =
  88. ( IsHover()
  89. && (! CExtToolControlBar::g_bMenuTracking )
  90. && (! CExtPopupMenuWnd::IsMenuTracking() )
  91. ) ? true : false;
  92. bool bIndeterminate = IsIndeterminate() ? true : false;
  93. CExtCmdIcon * pIcon = GetIconPtr();
  94. if( m_lfHotPercent >= -1.0 && pIcon != NULL && (! pIcon->IsEmpty() ) )
  95. {
  96. ASSERT( m_lfHotPercent <= 1.0 );
  97. if( m_iconCold.IsEmpty() )
  98. {
  99. m_iconCold.m_bmpNormal = pIcon->m_bmpNormal;
  100. COLORREF clrIconAlphaAccent =
  101. pBar->PmBridge_GetPM()->GetIconAlphaColor();
  102. if( clrIconAlphaAccent != COLORREF(-1L) )
  103. {
  104. double H = 0.0, S = 0.0, L = 0.0;
  105. CExtBitmap::stat_RGBtoHSL( clrIconAlphaAccent, &H, &S, &L );
  106. S = 0.3;
  107. clrIconAlphaAccent = CExtBitmap::stat_HLStoRGB( H, L, S );
  108. } // if( clrIconAlphaAccent != COLORREF(-1L) )
  109. m_iconCold.m_bmpNormal.MakeMono( clrIconAlphaAccent );
  110. m_iconCold.m_bmpNormal.AdjustHLS(
  111. COLORREF(-1L),
  112. COLORREF(-1L),
  113. 0.0,
  114. m_lfHotPercent,
  115. 0.0
  116. );
  117. m_iconCold.m_bmpNormal.AdjustAlpha( -0.5 );
  118. } // if( m_iconCold.IsEmpty() )
  119. if( (! bHover) && (! bPushed) && (! m_iconCold.IsEmpty() )  )
  120. pIcon = &m_iconCold;
  121. } // if( m_lfHotPercent >= -1.0 && pIcon != NULL && (! pIcon->IsEmpty() ) )
  122. bool bHorz = true;
  123. CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
  124. this, 
  125. bHorz, 
  126. rcArea, 
  127. NULL, 
  128. pIcon,
  129. true, 
  130. bHover, 
  131. bPushed, 
  132. bIndeterminate, 
  133. bEnabled,
  134. true, 
  135. false, 
  136. false, 
  137. CExtPaintManager::__ALIGN_HORIZ_CENTER, 
  138. NULL,
  139. ( IsAbleToTrackMenu()
  140. && (!m_pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)))
  141. ) ? true : false,
  142. 0, ( bEnabled && (!bHover) && (!bPushed) )
  143. );
  144. _ppbd.m_rcBorderSizes = OnQueryBorderSizes( bHorz );
  145. _ppbd.m_nIconAlignment = CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_TOP;
  146. _ppbd.m_nTextAlignment = CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_BOTTOM;
  147. _ppbd.m_rcIconMargins = OnQueryMarginsIcon( bHorz );
  148. _ppbd.m_rcTextMargins = OnQueryMarginsText( bHorz );
  149. if( m_bSeparatedDropDown )
  150. {
  151. _ppbd.m_bSeparatedDropDown = true;
  152. if( (m_bDropDownHT || CExtToolControlBar::g_bMenuTracking)
  153. && bPushed
  154. )
  155. _ppbd.m_bPushedDropDown = true;
  156. } // if( m_bSeparatedDropDown )
  157. g_PaintManager->PaintPushButton( dc, _ppbd );
  158. CRect rcText( rcArea );
  159. rcText.DeflateRect( __EXT_TB_BUTTON_OUTER_MARGIN, __EXT_TB_BUTTON_OUTER_MARGIN+__EXT_TB_BUTTON_INNER_MARGIN  );
  160. rcText.top = rcText.bottom - m_sizeFunnyTextCalc.cy;
  161. rcText.OffsetRect(
  162. ( m_sizeFunnyTextCalc.cx - m_sizeFunnyTextWell.cx ) / 2,
  163. ( m_sizeFunnyTextCalc.cy - m_sizeFunnyTextWell.cy ) / 2
  164. );
  165. if( bPushed )
  166. rcText.OffsetRect( g_PaintManager->GetPushedOffset() );
  167. CFont fontTmp;
  168. CFont * pOldFont = NULL;
  169. COLORREF clrText = 
  170. bEnabled
  171. ? ( ( m_lfHotPercent >= -1.0f )
  172. ? g_PaintManager->GetColor(
  173. (bHover || bPushed) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT,
  174. this
  175. )
  176. : dc.GetNearestColor(
  177. (bHover || bPushed) ? ( RGB(255,64,64) ) : ( RGB(64,64,255) )
  178. )
  179. )
  180. : g_PaintManager->GetColor( COLOR_3DSHADOW, this )
  181. ;
  182. if( bEnabled && bHover || bPushed )
  183. {
  184. LOGFONT lf;
  185. VERIFY( g_PaintManager->m_FontNormal.GetLogFont(&lf) );
  186. lf.lfUnderline = TRUE;
  187. VERIFY( fontTmp.CreateFontIndirect(&lf) );
  188. dc.SelectObject( &fontTmp );
  189. }
  190. else
  191. dc.SelectObject( &g_PaintManager->m_FontNormal );
  192. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  193. COLORREF clrTextOld = dc.SetTextColor( clrText );
  194. dc.DrawText( m_strFunnyText, &rcText, DT_CENTER|DT_VCENTER );
  195. dc.SetTextColor( clrTextOld );
  196. dc.SetBkMode( nOldBkMode );
  197. dc.SelectObject( pOldFont );
  198. if( bPaintChildren )
  199. PaintChildren( dc, bPaintOneNearestChildrenLevelOnly );
  200. }
  201. /////////////////////////////////////////////////////////////////////////////
  202. // CMainFrame
  203. IMPLEMENT_DYNAMIC( CMainFrame, CFrameWnd )
  204. BEGIN_MESSAGE_MAP( CMainFrame, CFrameWnd )
  205. //{{AFX_MSG_MAP(CMainFrame)
  206. ON_WM_CREATE()
  207. ON_WM_SETFOCUS()
  208. //}}AFX_MSG_MAP
  209. ON_COMMAND( ID_256_FILE_NEW, OnAnyCommand )
  210. ON_COMMAND( ID_256_FILE_OPEN, OnAnyCommand )
  211. ON_COMMAND( ID_256_FILE_FAVORITES, OnAnyCommand )
  212. ON_COMMAND( ID_256_FILE_ADD, OnAnyCommand )
  213. ON_COMMAND( ID_256_FILE_EXTRACT, OnAnyCommand )
  214. ON_COMMAND( ID_256_FILE_VIEW, OnAnyCommand )
  215. ON_COMMAND( ID_256_FILE_CHECK_OUT, OnAnyCommand )
  216. ON_COMMAND( ID_256_FILE_WIZARD, OnAnyCommand )
  217. ON_COMMAND( ID_TRUE_FILE_NEW, OnAnyCommand )
  218. ON_COMMAND( ID_TRUE_FILE_OPEN, OnAnyCommand )
  219. ON_COMMAND( ID_TRUE_FILE_FAVORITES, OnAnyCommand )
  220. ON_COMMAND( ID_TRUE_FILE_ADD, OnAnyCommand )
  221. ON_COMMAND( ID_TRUE_FILE_EXTRACT, OnAnyCommand )
  222. ON_COMMAND( ID_TRUE_FILE_VIEW, OnAnyCommand )
  223. ON_COMMAND( ID_TRUE_FILE_CHECK_OUT, OnAnyCommand )
  224. ON_COMMAND( ID_TRUE_FILE_WIZARD, OnAnyCommand )
  225. ON_COMMAND( ID_VISTA_RECYCLE_BIN_EMPTY, OnAnyCommand )
  226. ON_COMMAND( ID_VISTA_RECYCLE_BIN_FULL, OnAnyCommand )
  227. ON_COMMAND( ID_VISTA_PICS, OnAnyCommand )
  228. ON_COMMAND( ID_VISTA_PARENTAL_CONTROL, OnAnyCommand )
  229. ON_COMMAND( ID_VISTA_SEARCH, OnAnyCommand )
  230. ON_COMMAND( ID_VISTA_MENU_RECYCLE_BIN_EMPTY, OnAnyCommand )
  231. ON_COMMAND( ID_VISTA_MENU_RECYCLE_BIN_FULL, OnAnyCommand )
  232. ON_COMMAND( ID_VISTA_MENU_PICS, OnAnyCommand )
  233. ON_COMMAND( ID_VISTA_MENU_PARENTAL_CONTROL, OnAnyCommand )
  234. ON_COMMAND( ID_VISTA_MENU_SEARCH, OnAnyCommand )
  235. ON_UPDATE_COMMAND_UI( ID_256_FILE_NEW, OnUpdateAnyCommand )
  236. ON_UPDATE_COMMAND_UI( ID_256_FILE_OPEN, OnUpdateAnyCommand )
  237. ON_UPDATE_COMMAND_UI( ID_256_FILE_FAVORITES, OnUpdateAnyCommand )
  238. ON_UPDATE_COMMAND_UI( ID_256_FILE_ADD, OnUpdateAnyCommand )
  239. ON_UPDATE_COMMAND_UI( ID_256_FILE_EXTRACT, OnUpdateAnyCommand )
  240. ON_UPDATE_COMMAND_UI( ID_256_FILE_VIEW, OnUpdateAnyCommand )
  241. ON_UPDATE_COMMAND_UI( ID_256_FILE_CHECK_OUT, OnUpdateAnyCommand )
  242. ON_UPDATE_COMMAND_UI( ID_256_FILE_WIZARD, OnUpdateAnyCommand )
  243. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_NEW, OnUpdateAnyCommand )
  244. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_OPEN, OnUpdateAnyCommand )
  245. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_FAVORITES, OnUpdateAnyCommand )
  246. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_ADD, OnUpdateAnyCommand )
  247. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_EXTRACT, OnUpdateAnyCommand )
  248. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_VIEW, OnUpdateAnyCommand )
  249. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_CHECK_OUT, OnUpdateAnyCommand )
  250. ON_UPDATE_COMMAND_UI( ID_TRUE_FILE_WIZARD, OnUpdateAnyCommand )
  251. ON_UPDATE_COMMAND_UI( ID_VISTA_RECYCLE_BIN_EMPTY, OnUpdateAnyCommand )
  252. ON_UPDATE_COMMAND_UI( ID_VISTA_RECYCLE_BIN_FULL, OnUpdateAnyCommand )
  253. ON_UPDATE_COMMAND_UI( ID_VISTA_PICS, OnUpdateAnyCommand )
  254. ON_UPDATE_COMMAND_UI( ID_VISTA_PARENTAL_CONTROL, OnUpdateAnyCommand )
  255. ON_UPDATE_COMMAND_UI( ID_VISTA_SEARCH, OnUpdateAnyCommand )
  256. ON_UPDATE_COMMAND_UI( ID_VISTA_MENU_RECYCLE_BIN_EMPTY, OnUpdateAnyCommand )
  257. ON_UPDATE_COMMAND_UI( ID_VISTA_MENU_RECYCLE_BIN_FULL, OnUpdateAnyCommand )
  258. ON_UPDATE_COMMAND_UI( ID_VISTA_MENU_PICS, OnUpdateAnyCommand )
  259. ON_UPDATE_COMMAND_UI( ID_VISTA_MENU_PARENTAL_CONTROL, OnUpdateAnyCommand )
  260. ON_UPDATE_COMMAND_UI( ID_VISTA_MENU_SEARCH, OnUpdateAnyCommand )
  261. ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
  262. ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)
  263. ON_COMMAND_EX(IDR_TOOLBAR_SMALL_256_COLOR, OnBarCheck )
  264. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR_SMALL_256_COLOR, OnUpdateControlBarMenu)
  265. ON_COMMAND_EX(IDR_TOOLBAR_BIG_TRUE_COLOR, OnBarCheck )
  266. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR_BIG_TRUE_COLOR, OnUpdateControlBarMenu)
  267. ON_COMMAND_EX(IDR_TOOLBAR_BIG_TRUE_COLOR2, OnBarCheck )
  268. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR_BIG_TRUE_COLOR2, OnUpdateControlBarMenu)
  269. ON_COMMAND_EX(IDR_TOOLBAR_BIG_TRUE_COLOR3, OnBarCheck )
  270. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR_BIG_TRUE_COLOR3, OnUpdateControlBarMenu)
  271. ON_COMMAND_EX(IDR_TOOLBAR_VISTA_ICONS, OnBarCheck )
  272. ON_UPDATE_COMMAND_UI(IDR_TOOLBAR_VISTA_ICONS, OnUpdateControlBarMenu)
  273. ON_COMMAND_EX(ID_VIEW_UI_LOOK_BAR, OnBarCheck )
  274. ON_UPDATE_COMMAND_UI(ID_VIEW_UI_LOOK_BAR, OnUpdateControlBarMenu)
  275. END_MESSAGE_MAP()
  276. static UINT indicators[] =
  277. {
  278. ID_SEPARATOR,           // status line indicator
  279. ID_INDICATOR_CAPS,
  280. ID_INDICATOR_NUM,
  281. ID_INDICATOR_SCRL,
  282. };
  283. /////////////////////////////////////////////////////////////////////////////
  284. // CMainFrame construction/destruction
  285. CMainFrame::CMainFrame()
  286. {
  287. CWinApp * pApp = ::AfxGetApp();
  288. ASSERT( pApp != NULL );
  289. ASSERT( pApp->m_pszRegistryKey != NULL );
  290. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  291. ASSERT( pApp->m_pszProfileName != NULL );
  292. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  293. if( ! g_PaintManager.PaintManagerStateLoad(
  294. pApp->m_pszRegistryKey,
  295. pApp->m_pszProfileName,
  296. pApp->m_pszProfileName
  297. )
  298. )
  299. g_PaintManager.InstallPaintManager(
  300. RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue)
  301. );
  302. CExtPopupMenuWnd::g_bMenuExpanding = false;
  303. CExtPopupMenuWnd::g_bMenuHighlightRarely = false;
  304. // window placement persistence
  305. ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
  306. m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
  307. m_dataFrameWP.showCmd = SW_HIDE;
  308. }
  309. CMainFrame::~CMainFrame()
  310. {
  311. }
  312. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  313. {
  314. if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
  315. return -1;
  316. HICON hIcon = (::AfxGetApp())->LoadIcon(IDR_MAINFRAME);
  317. ASSERT( hIcon != NULL );
  318. SetIcon( hIcon, TRUE );
  319. SetIcon( hIcon, FALSE );
  320. CCreateContext _cc;
  321. _cc.m_pCurrentDoc = NULL;
  322. _cc.m_pCurrentFrame = this;
  323. _cc.m_pLastView = NULL;
  324. _cc.m_pNewDocTemplate = NULL;
  325. _cc.m_pNewViewClass = RUNTIME_CLASS( CChildView );
  326. CWnd * pWndView = CreateView( &_cc );
  327. if( pWndView == NULL )
  328. {
  329. TRACE0("Failed to create view windown");
  330. return -1;
  331. }
  332. ASSERT_KINDOF( CChildView, pWndView );
  333. CChildView * pChildView =
  334. STATIC_DOWNCAST( CChildView, pWndView );
  335. SetActiveView( pChildView );
  336. pWndView->ModifyStyleEx( WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME, 0, SWP_FRAMECHANGED );
  337. CWinApp * pApp = ::AfxGetApp();
  338. ASSERT( pApp != NULL );
  339. ASSERT( pApp->m_pszRegistryKey != NULL );
  340. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  341. ASSERT( pApp->m_pszProfileName != NULL );
  342. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  343. ASSERT( pApp->m_pszProfileName != NULL );
  344. g_CmdManager->ProfileSetup(
  345. pApp->m_pszProfileName,
  346. GetSafeHwnd()
  347. );
  348. VERIFY(
  349. g_CmdManager->UpdateFromMenu(
  350. pApp->m_pszProfileName,
  351. IDR_MAINFRAME
  352. )
  353. );
  354. VERIFY(
  355. g_CmdManager->UpdateFromToolBar(
  356. pApp->m_pszProfileName,
  357. IDR_MAINFRAME
  358. )
  359. );
  360. VERIFY(
  361. g_CmdManager->UpdateFromToolBar(
  362. pApp->m_pszProfileName,
  363. IDR_TOOLBAR_SMALL_256_COLOR,
  364. NULL,
  365. NULL,
  366. false,
  367. true,
  368. RGB(188,190,188)
  369. )
  370. );
  371. VERIFY(
  372. g_CmdManager->UpdateFromToolBar(
  373. pApp->m_pszProfileName,
  374. IDR_TOOLBAR_BIG_TRUE_COLOR
  375. )
  376. );
  377. VERIFY(
  378. g_CmdManager->UpdateFromToolBar(
  379. pApp->m_pszProfileName,
  380. IDR_TOOLBAR_VISTA_ICONS_SMALL,
  381. NULL,
  382. NULL,
  383. false,
  384. true,
  385. COLORREF( -1L )
  386. )
  387. );
  388. CExtCmdItem * pCmdItem =
  389. g_CmdManager->CmdGetPtr(
  390. pApp->m_pszProfileName, ID_APP_ABOUT );
  391. ASSERT( pCmdItem != NULL );
  392. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  393. pCmdItem->m_sToolbarText.Replace( __EXT_MFC_SAFE_LPCTSTR( _T("&") ), __EXT_MFC_SAFE_LPCTSTR( _T("") ) );
  394. pCmdItem =
  395. g_CmdManager->CmdGetPtr(
  396. pApp->m_pszProfileName, ID_APP_EXIT );
  397. ASSERT( pCmdItem != NULL );
  398. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  399. pCmdItem->m_sToolbarText.Replace( __EXT_MFC_SAFE_LPCTSTR( _T("&") ), __EXT_MFC_SAFE_LPCTSTR( _T("") ) );
  400. if( !m_wndMenuBar.Create(
  401. NULL, // _T("Menu Bar"),
  402. this,
  403. ID_VIEW_MENUBAR
  404. )
  405. )
  406.     {
  407.         TRACE0("Failed to create menubarn");
  408.         return -1;      // failed to create
  409.     }
  410. if( (! m_wndToolBarStd.Create(
  411. _T("Standard ToolBar"), this, AFX_IDW_TOOLBAR
  412. ) )
  413. || (! m_wndToolBarStd.LoadToolBar(IDR_MAINFRAME) )
  414. )
  415. {
  416. TRACE0("Failed to create standard toolbarn");
  417. return -1;      // fail to create
  418. }
  419. if( (! m_wndToolBar256.Create(
  420. _T("256 Color (16x16 buttons)"), this, IDR_TOOLBAR_SMALL_256_COLOR
  421. ) )
  422. || (! m_wndToolBar256.LoadToolBar(IDR_TOOLBAR_SMALL_256_COLOR,RGB(188,190,188)) )
  423. )
  424. {
  425. TRACE0("Failed to create 256-color toolbarn");
  426. return -1;      // fail to create
  427. }
  428. if( (! m_wndToolBarTrue.Create(
  429. _T("16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR
  430. ) )
  431. || (! m_wndToolBarTrue.LoadToolBar(IDR_TOOLBAR_BIG_TRUE_COLOR) )
  432. )
  433. {
  434. TRACE0("Failed to create true-color toolbarn");
  435. return -1;      // fail to create
  436. }
  437. if( (! m_wndToolBarTruePlusText.Create(
  438. _T("Text + 16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR2
  439. ) )
  440. )
  441. {
  442. TRACE0("Failed to create true-color toolbar with textn");
  443. return -1;      // fail to create
  444. }
  445. if( (! m_wndToolBarTrueHot.Create(
  446. _T("Hot + 16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR3
  447. ) )
  448. )
  449. {
  450. TRACE0("Failed to create hot-true-color toolbarn");
  451. return -1;      // fail to create
  452. }
  453. if( (! m_wndToolBarVista.Create(
  454. _T("Vista Icons (RGB/A 32 bits with Alpha Channel)"), this, IDR_TOOLBAR_VISTA_ICONS
  455. ) )
  456. || (! m_wndToolBarVista.LoadToolBar(IDR_TOOLBAR_VISTA_ICONS, COLORREF( -1L ) ) )
  457. )
  458. {
  459. TRACE0("Failed to create Vista Icons toolbarn");
  460. return -1;      // fail to create
  461. }
  462. m_wndToolBarVista.SetInitDesiredSizeFloating( CSize( 500, 100 ) );
  463. if( (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )
  464. || (! m_wndToolBarUiLook.ThemeSwitcherInit() )
  465. )
  466. {
  467. TRACE0("Failed to create Vista Icons toolbarn");
  468. return -1;      // fail to create
  469. }
  470. int nCount = m_wndToolBarTrue.GetButtonsCount();
  471. for( int i = 0; i < nCount; i++ )
  472. {
  473. CExtBarButton * pTBB =
  474. m_wndToolBarTrue.GetButton( i );
  475. ASSERT_VALID( pTBB );
  476. if( pTBB->IsKindOf( RUNTIME_CLASS(CExtBarContentExpandButton) ) )
  477. continue;
  478. if( pTBB->IsSeparator() )
  479. {
  480. m_wndToolBarTruePlusText.InsertButton(
  481. -1,
  482. ID_SEPARATOR,
  483. FALSE
  484. );
  485. m_wndToolBarTrueHot.InsertButton(
  486. -1,
  487. ID_SEPARATOR,
  488. FALSE
  489. );
  490. continue;
  491. } // if( pTBB->IsSeparator() )
  492. CString strFunnyText( _T("") );
  493. switch( pTBB->GetCmdID() )
  494. {
  495. case ID_TRUE_FILE_NEW:
  496. strFunnyText = _T("New filenentry ...");
  497. break;
  498. case ID_TRUE_FILE_OPEN:
  499. strFunnyText = _T("Open filenentry ...");
  500. break;
  501. case ID_TRUE_FILE_FAVORITES:
  502. strFunnyText = _T("Organizenfavorites");
  503. break;
  504. case ID_TRUE_FILE_ADD:
  505. strFunnyText = _T("Addnitem");
  506. break;
  507. case ID_TRUE_FILE_EXTRACT:
  508. strFunnyText = _T("Extactnfile");
  509. break;
  510. case ID_TRUE_FILE_VIEW:
  511. strFunnyText = _T("Viewnselected");
  512. break;
  513. case ID_TRUE_FILE_CHECK_OUT:
  514. strFunnyText = _T("Check Out");
  515. break;
  516. case ID_TRUE_FILE_WIZARD:
  517. strFunnyText = _T("Wizard");
  518. break;
  519. } // switch( pTBB->GetCmdID() )
  520. CFunnyToolButton * pSpecTBB =
  521. new CFunnyToolButton(
  522. &m_wndToolBarTruePlusText,
  523. pTBB->GetCmdID(),
  524. (LPCTSTR)strFunnyText,
  525. -2.0f
  526. );
  527. m_wndToolBarTruePlusText.InsertSpecButton(
  528. -1,
  529. pSpecTBB,
  530. FALSE
  531. );
  532. pSpecTBB =
  533. new CFunnyToolButton(
  534. &m_wndToolBarTrueHot,
  535. pTBB->GetCmdID(),
  536. (LPCTSTR)strFunnyText,
  537. 0.25
  538. );
  539. m_wndToolBarTrueHot.InsertSpecButton(
  540. -1,
  541. pSpecTBB,
  542. FALSE
  543. );
  544. } // for( int i = 0; i < nCount; i++ )
  545. m_wndToolBarTruePlusText.InitContentExpandButton();
  546. m_wndToolBarTrueHot.InitContentExpandButton();
  547. if (!m_wndStatusBar.Create(this) ||
  548. !m_wndStatusBar.SetIndicators(indicators,
  549.   sizeof(indicators)/sizeof(UINT)))
  550. {
  551. TRACE0("Failed to create status barn");
  552. return -1;      // fail to create
  553. }
  554. m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  555. m_wndToolBarStd.EnableDocking(CBRS_ALIGN_ANY);
  556. m_wndToolBar256.EnableDocking(CBRS_ALIGN_ANY);
  557. m_wndToolBarTrue.EnableDocking(CBRS_ALIGN_ANY);
  558. m_wndToolBarTruePlusText.EnableDocking(CBRS_ALIGN_ANY);
  559. m_wndToolBarTrueHot.EnableDocking(CBRS_ALIGN_ANY);
  560. m_wndToolBarVista.EnableDocking(CBRS_ALIGN_ANY);
  561. m_wndToolBarUiLook.EnableDocking(CBRS_ALIGN_ANY);
  562. if( !CExtControlBar::FrameEnableDocking(this) )
  563. {
  564. ASSERT( FALSE );
  565. return -1;
  566. }
  567. if( !CExtControlBar::ProfileBarStateLoad(
  568. this,
  569. pApp->m_pszRegistryKey,
  570. pApp->m_pszProfileName,
  571. pApp->m_pszProfileName,
  572. &m_dataFrameWP
  573. )
  574. )
  575. {
  576. DockControlBar( &m_wndMenuBar, AFX_IDW_DOCKBAR_TOP );
  577. DockControlBar( &m_wndToolBarStd, AFX_IDW_DOCKBAR_TOP );
  578. DockControlBar( &m_wndToolBar256, AFX_IDW_DOCKBAR_TOP );
  579. DockControlBar( &m_wndToolBarTrue, AFX_IDW_DOCKBAR_LEFT );
  580. DockControlBar( &m_wndToolBarTruePlusText, AFX_IDW_DOCKBAR_BOTTOM );
  581. DockControlBar( &m_wndToolBarTrueHot, AFX_IDW_DOCKBAR_TOP );
  582. FloatControlBar( &m_wndToolBarVista, CPoint(300,300) );
  583. DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );
  584. }
  585. RecalcLayout();
  586. return 0;
  587. }
  588. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  589. {
  590. if( ! CExtNCW < CFrameWnd > :: PreCreateWindow( cs ) )
  591. return FALSE;
  592. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  593. cs.lpszClass = AfxRegisterWndClass(0);
  594. return TRUE;
  595. }
  596. /////////////////////////////////////////////////////////////////////////////
  597. // CMainFrame diagnostics
  598. #ifdef _DEBUG
  599. void CMainFrame::AssertValid() const
  600. {
  601. CExtNCW < CFrameWnd > :: AssertValid();
  602. }
  603. void CMainFrame::Dump(CDumpContext& dc) const
  604. {
  605. CExtNCW < CFrameWnd > :: Dump( dc );
  606. }
  607. #endif //_DEBUG
  608. /////////////////////////////////////////////////////////////////////////////
  609. // CMainFrame message handlers
  610. void CMainFrame::OnSetFocus(CWnd* pOldWnd)
  611. {
  612. pOldWnd;
  613. // forward focus to the view window
  614. CView * pView = GetActiveView();
  615. if( pView != NULL )
  616. pView->SetFocus();
  617. }
  618. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  619. {
  620. // let the view have first crack at the command
  621. CView * pView = GetActiveView();
  622. if( pView != NULL )
  623. {
  624. if( pView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo) )
  625. return TRUE;
  626. }
  627. // otherwise, do default handling
  628. return CExtNCW < CFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
  629. }
  630. void CMainFrame::ActivateFrame(int nCmdShow) 
  631. {
  632. // window placement persistence
  633. if( m_dataFrameWP.showCmd != SW_HIDE )
  634. {
  635. SetWindowPlacement( &m_dataFrameWP );
  636. CExtNCW < CFrameWnd > :: ActivateFrame( m_dataFrameWP.showCmd );
  637. m_dataFrameWP.showCmd = SW_HIDE;
  638. return;
  639. }
  640. CExtNCW < CFrameWnd > :: ActivateFrame( nCmdShow );
  641. }
  642. BOOL CMainFrame::DestroyWindow() 
  643. {
  644. CWinApp * pApp = ::AfxGetApp();
  645. ASSERT( pApp != NULL );
  646. ASSERT( pApp->m_pszRegistryKey != NULL );
  647. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  648. ASSERT( pApp->m_pszProfileName != NULL );
  649. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  650. VERIFY(
  651. CExtControlBar::ProfileBarStateSave(
  652. this,
  653. pApp->m_pszRegistryKey,
  654. pApp->m_pszProfileName,
  655. pApp->m_pszProfileName
  656. )
  657. );
  658. VERIFY(
  659. g_PaintManager.PaintManagerStateSave(
  660. pApp->m_pszRegistryKey,
  661. pApp->m_pszProfileName,
  662. pApp->m_pszProfileName
  663. )
  664. );
  665. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  666. return CExtNCW < CFrameWnd > :: DestroyWindow();
  667. }
  668. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  669. {
  670. if( m_wndToolBarUiLook.PreTranslateMessage( pMsg ) )
  671. return TRUE;
  672. if( m_wndMenuBar.TranslateMainFrameMessage( pMsg ) )
  673. return TRUE;
  674. return CExtNCW < CFrameWnd > :: PreTranslateMessage(pMsg);
  675. }
  676. void CMainFrame::OnAnyCommand()
  677. {
  678. }
  679. void CMainFrame::OnUpdateAnyCommand( CCmdUI* pCmdUI )
  680. {
  681. pCmdUI->Enable( TRUE );
  682. }