MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:28k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "GUI_Outlook.h"
  22. #include "MainFrm.h"
  23. #include "GUI_OutlookDoc.h"
  24. #include "GUI_OutlookView.h"
  25. #include "ItemTreeView.h"
  26. #include "PreviewPane.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CMainFrame
  34. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  35. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  36. //{{AFX_MSG_MAP(CMainFrame)
  37. ON_WM_CREATE()
  38. ON_COMMAND(ID_FILE_NEWMAIL, OnDoNothing)
  39. ON_COMMAND(ID_FILE_PREVIEWPANE, OnFilePreviewpane)
  40. ON_UPDATE_COMMAND_UI(ID_FILE_PREVIEWPANE, OnUpdateFilePreviewpane)
  41. ON_WM_SYSCOLORCHANGE()
  42. ON_WM_CLOSE()
  43. ON_COMMAND(ID_FILE_MOVEFOLDER, OnDoNothing)
  44. ON_COMMAND(ID_FILE_ADDRESS, OnDoNothing)
  45. ON_COMMAND(ID_FILE_SENDRECEIVE, OnDoNothing)
  46. ON_COMMAND(ID_FILE_FIND, OnDoNothing)
  47. ON_COMMAND(ID_FILE_ORGANIZE, OnDoNothing)
  48. ON_COMMAND(ID_FILE_DELETE, OnDoNothing)
  49. ON_COMMAND(ID_ACTIONS_REPLY, OnDoNothing)
  50. ON_COMMAND(ID_ACTIONS_FORWARD, OnDoNothing)
  51. ON_COMMAND(ID_ACTIONS_REPLYTOALL, OnDoNothing)
  52. ON_COMMAND(ID_NEW_MAILMESSAGE, OnDoNothing)
  53. ON_COMMAND(ID_NEW_FAXMESSAGE, OnDoNothing)
  54. ON_COMMAND(ID_NEW_POSTINTHISFOLDER, OnDoNothing)
  55. ON_COMMAND(ID_NEW_FOLDER, OnDoNothing)
  56. ON_COMMAND(ID_NEW_OUTLOOKBARSHORTCUT, OnDoNothing)
  57. ON_COMMAND(ID_NEW_APPOINTMENT, OnDoNothing)
  58. ON_COMMAND(ID_NEW_MEETINGREQUEST, OnDoNothing)
  59. ON_COMMAND(ID_NEW_CONTACT, OnDoNothing)
  60. ON_COMMAND(ID_NEW_DISTRIBUTIONLIST, OnDoNothing)
  61. ON_COMMAND(ID_NEW_TASK, OnDoNothing)
  62. ON_COMMAND(ID_NEW_TASKREQUEST, OnDoNothing)
  63. ON_COMMAND(ID_NEW_JOURNALENTRY, OnDoNothing)
  64. ON_COMMAND(ID_NEW_NOTE, OnDoNothing)
  65. ON_COMMAND(ID_NEW_OFFICEDOCUMENT, OnDoNothing)
  66. ON_COMMAND(ID_NEW_CHOOSEFORM, OnDoNothing)
  67. ON_COMMAND(ID_NEW_PERSONALFOLDERSFILEPST, OnDoNothing)
  68. ON_COMMAND(ID_VIEW_THEME_OFFICEXP, OnViewThemeOfficexp)
  69. ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_OFFICEXP, OnUpdateViewThemeOfficexp)
  70. ON_COMMAND(ID_VIEW_THEME_OFFICE2003, OnViewThemeOffice2003)
  71. ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_OFFICE2003, OnUpdateViewThemeOffice2003)
  72. ON_COMMAND(ID_VIEW_THEME_OFFICE2000, OnViewThemeOffice2000)
  73. ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_OFFICE2000, OnUpdateViewThemeOffice2000)
  74. ON_COMMAND(ID_VIEW_THEME_NATIVEWINXP, OnViewThemeWinXP)
  75. ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_NATIVEWINXP, OnUpdateViewThemeWinXP)
  76. //}}AFX_MSG_MAP
  77. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  78. ON_COMMAND_RANGE(ID_SKIN_LUNABLUE, ID_SKIN_DISABLE, OnSkinChanged)
  79. ON_COMMAND(ID_SKIN_POPUP, OnSkinPopup)
  80. #endif
  81. ON_MESSAGE(XTPWM_TASKPANEL_NOTIFY, OnOutbarNotify)
  82. ON_MESSAGE_VOID(CPWN_XT_PUSHPINBUTTON, OnPushPinButton)
  83. ON_MESSAGE_VOID(CPWN_XT_PUSHPINCANCEL, OnPushPinCancel)
  84. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  85. ON_XTP_CREATECONTROL()
  86. ON_XTP_EXECUTE(ID_GOTO_URL, OnGotoURL)
  87. END_MESSAGE_MAP()
  88. static UINT indicators[] =
  89. {
  90. ID_SEPARATOR,           // status line indicator
  91. ID_INDICATOR_CAPS,
  92. ID_INDICATOR_NUM,
  93. ID_INDICATOR_SCRL,
  94. };
  95. typedef enum
  96. {
  97. IDX_OUTLOOK_TODAY,  // Outlook Shortcuts
  98. IDX_INBOX,
  99. IDX_CALENDAR,
  100. IDX_CONTACTS,
  101. IDX_TASKS,
  102. IDX_NOTES,
  103. IDX_DELETED_ITEMS,
  104. IDX_DRAFTS,         // My Shortcuts
  105. IDX_OUTBOX,
  106. IDX_SENT_ITEMS,
  107. IDX_JOURNAL,
  108. IDX_OUTLOOK_UPDATE,
  109. IDX_MY_COMPUTER,    // Other Shortcuts
  110. IDX_MY_DOCUMENTS,
  111. IDX_FAVORITES,
  112. IDX_COUNT
  113. } INDEX;
  114. typedef struct
  115. {
  116. INDEX   m_nIndex;
  117. UINT    m_nTextID;
  118. UINT    m_nIconID;
  119. }
  120. FOLDER_ENTRY;
  121. typedef struct
  122. {
  123. UINT            m_nTextID;
  124. UINT            m_nEntries;
  125. FOLDER_ENTRY*   m_pEntries;
  126. }
  127. FOLDER_DEF;
  128. static UINT arHiddenCmds[] =
  129. {
  130. ID_FILE_SAVE_AS,
  131. ID_FILE_PRINT_PREVIEW,
  132. ID_EDIT_CUT,
  133. ID_EDIT_COPY,
  134. ID_EDIT_PASTE,
  135. ID_VIEW_STATUS_BAR,
  136. ID_NEW_FOLDER,
  137. ID_NEW_OUTLOOKBARSHORTCUT,
  138. ID_NEW_TASK,
  139. ID_NEW_JOURNALENTRY,
  140. ID_NEW_OFFICEDOCUMENT,
  141. ID_NEW_PERSONALFOLDERSFILEPST
  142. };
  143. static FOLDER_ENTRY OutlookShortcuts[] =
  144. {
  145. { IDX_OUTLOOK_TODAY,    IDS_OUTLOOK_TODAY,  IDI_OUTLOOK_TODAY   },
  146. { IDX_INBOX,            IDS_INBOX,          IDI_INBOX           },
  147. { IDX_CALENDAR,         IDS_CALENDAR,       IDI_CALENDAR        },
  148. { IDX_CONTACTS,         IDS_CONTACTS,       IDI_CONTACTS        },
  149. { IDX_TASKS,            IDS_TASKS,          IDI_TASKS           },
  150. { IDX_NOTES,            IDS_NOTES,          IDI_NOTES           },
  151. { IDX_DELETED_ITEMS,    IDS_DELETED_ITEMS,  IDI_DELETED_ITEMS   }
  152. };
  153. static FOLDER_ENTRY MyShortcuts[] =
  154. {
  155. { IDX_DRAFTS,           IDS_DRAFTS,         IDI_DRAFTS          },
  156. { IDX_OUTBOX,           IDS_OUTBOX,         IDI_OUTBOX          },
  157. { IDX_SENT_ITEMS,       IDS_SENT_ITEMS,     IDI_SENT_ITEMS      },
  158. { IDX_JOURNAL,          IDS_JOURNAL,        IDI_JOURNAL         },
  159. { IDX_OUTLOOK_UPDATE,   IDS_OUTLOOK_UPDATE, IDI_OUTLOOK_UPDATE  }
  160. };
  161. static FOLDER_ENTRY OtherShortcuts[] =
  162. {
  163. { IDX_MY_COMPUTER,      IDS_MY_COMPUTER,    IDI_MY_COMPUTER     },
  164. { IDX_MY_DOCUMENTS,     IDS_MY_DOCUMENTS,   IDI_MY_DOCUMENTS    },
  165. { IDX_FAVORITES,        IDS_FAVORITES,      IDI_FAVORITES       }
  166. };
  167. static FOLDER_DEF FolderDefs[] =
  168. {
  169. { IDS_OUTLOOK_SHORTCUTS,    _countof(OutlookShortcuts), OutlookShortcuts    },
  170. { IDS_MY_SHORTCUTS,         _countof(MyShortcuts),      MyShortcuts         },
  171. { IDS_OTHER_SHORTCUTS,      _countof(OtherShortcuts),   OtherShortcuts      }
  172. };
  173. /////////////////////////////////////////////////////////////////////////////
  174. // CMainFrame construction/destruction
  175. CMainFrame::CMainFrame()
  176. {
  177. // TODO: add member initialization code here
  178. m_pItemTreeView = NULL;
  179. m_bShowPreview = TRUE;
  180. m_pwndTreeCtrl = NULL;
  181. // Enable/Disable XP GUI Mode
  182. CXTRegistryManager regMgr;
  183. m_nTheme = (XTPPaintTheme)regMgr.GetProfileInt(_T("Settings"), _T("Theme"), xtpThemeOffice2003);
  184. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  185. XTPSkinManager()->SetApplyOptions(XTPSkinManager()->GetApplyOptions() | xtpSkinApplyMetrics);
  186. #endif
  187. }
  188. CMainFrame::~CMainFrame()
  189. {
  190. CXTRegistryManager regMgr;
  191. regMgr.WriteProfileInt(_T("Settings"), _T("Theme"), m_nTheme);
  192. }
  193. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  194. {
  195. // TODO: Remove this lihe if you don't want intelligent menus.
  196. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  197. return -1;
  198. if (!m_wndStatusBar.Create(this) ||
  199. !m_wndStatusBar.SetIndicators(indicators,
  200.   sizeof(indicators)/sizeof(UINT)))
  201. {
  202. TRACE0("Failed to create status barn");
  203. return -1;      // fail to create
  204. }
  205. if (!InitCommandBars())
  206. {
  207. return -1;      // fail to create
  208. }
  209. CXTPCommandBars* pCommandBars = GetCommandBars();
  210. pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
  211. CXTPToolBar* pStandardBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop);
  212. if (!pStandardBar ||
  213. !pStandardBar->LoadToolBar(IDR_STANDARD))
  214. {
  215. TRACE0("Failed to create toolbarn");
  216. return -1;
  217. }
  218. CXTPToolBar* pSkinBar = (CXTPToolBar*)pCommandBars->Add(_T("Skin Framework"), xtpBarTop);
  219. if (!pSkinBar ||
  220. !pSkinBar->LoadToolBar(IDR_SKINBAR))
  221. {
  222. TRACE0("Failed to create toolbarn");
  223. return -1;
  224. }
  225. DockRightOf(pSkinBar, pStandardBar);
  226. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  227. pOptions->bAlwaysShowFullMenus = FALSE;
  228. pCommandBars->HideCommands(arHiddenCmds, _countof(arHiddenCmds));
  229. LoadCommandBars(_T("CommandBars4"));
  230. SetTheme(m_nTheme);
  231. if (XTPImageManager()->IsAlphaIconsSupported())
  232. {
  233. XTPImageManager()->SetIcons(IDR_STANDARD, IDB_STANDARD_ALPHA);
  234. XTPImageManager()->SetIcons(IDR_NEW_POPUP, IDB_POPUP_ALPHA);
  235. XTPImageManager()->SetIcons(IDR_MAINFRAME, IDB_TOOLBAR_ALPHA);
  236. }
  237. else
  238. {
  239. XTPImageManager()->SetIcons(IDR_NEW_POPUP);
  240. XTPImageManager()->SetIcons(IDR_MAINFRAME);
  241. }
  242. return 0;
  243. }
  244. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  245. {
  246. if( !CFrameWnd::PreCreateWindow(cs) )
  247. return FALSE;
  248. cs.lpszClass = _T("XTPMainFrame");
  249. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  250. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  251. cs.style &= ~FWS_ADDTOTITLE;
  252. return TRUE;
  253. }
  254. /////////////////////////////////////////////////////////////////////////////
  255. // CMainFrame diagnostics
  256. #ifdef _DEBUG
  257. void CMainFrame::AssertValid() const
  258. {
  259. CFrameWnd::AssertValid();
  260. }
  261. void CMainFrame::Dump(CDumpContext& dc) const
  262. {
  263. CFrameWnd::Dump(dc);
  264. }
  265. #endif //_DEBUG
  266. /////////////////////////////////////////////////////////////////////////////
  267. // CMainFrame message handlers
  268. /*CR
  269. |- m_wndSplitter1 --|---------------------------------------------------------------|
  270. |                   |   |- m_wndSplitter2 --------------------------------------|   |
  271. |                   |   |                                                       |   |
  272. |                   |   |                   CaptionBar                          |   |
  273. |                   |   |                                                       |   |
  274. |                   |   |-------------------------------------------------------|   |
  275. |                   |   |   |- m_wndSplitter3 --|---------------------------|   |   |
  276. |                   |   |   |                   |   |- m_wndSplitter4 --|   |   |   |
  277. |                   |   |   |                   |   |                   |   |   |   |
  278. |                   |   |   |                   |   |                   |   |   |   |
  279. |                   |   |   |                   |   |    TeamUpView     |   |   |   |
  280. |     OutlookBar    |   |   |                   |   |                   |   |   |   |
  281. |                   |   |   |                   |   |                   |   |   |   |
  282. |                   |   |   |   TreeItemView    |   |-------------------|   |   |   |
  283. |                   |   |   |                   |   |                   |   |   |   |
  284. |                   |   |   |                   |   |                   |   |   |   |
  285. |                   |   |   |                   |   |    PreviewPane    |   |   |   |
  286. |                   |   |   |                   |   |                   |   |   |   |
  287. |                   |   |   |                   |   |                   |   |   |   |
  288. |                   |   |   |                   |   |-------------------|   |   |   |
  289. |                   |   |   |-------------------|---------------------------|   |   |
  290. |                   |   |-------------------------------------------------------|   |
  291. |-------------------|---------------------------------------------------------------|
  292. ***/
  293. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
  294. {
  295. // Create the splitter window with two columns
  296. if (!m_wndSplitter1.CreateStatic(this, 1, 2))
  297. {
  298. TRACE0("Failed to create splitter windown");
  299. return FALSE;
  300. }
  301. // Create the Outlook bar, this will be inserted
  302. // into row 0, col 0.
  303. if (!InitializeOutlookBar())
  304. return FALSE;
  305. // Create the first nested splitter window to contain the
  306. // caption bar and a second nested splitter.
  307. if (!m_wndSplitter2.CreateStatic(&m_wndSplitter1,   // our parent window is the first splitter
  308. 2, 1,                                           // the new splitter is 2 rows, 1 column
  309. WS_CHILD | WS_VISIBLE | WS_BORDER,              // style, WS_BORDER is needed
  310. m_wndSplitter1.IdFromRowCol(0, 1)))             // new splitter is in the first row, 3rd column of first splitter
  311. {
  312. TRACE0("Failed to create nested splittern");
  313. return FALSE;
  314. }
  315. // Create the caption bar, this will be inserted
  316. // into row 0, col 0 of nested splitter.
  317. if (!InitializeCaptionBar())
  318. return FALSE;
  319. // Second nested splitter contains tree view and a third
  320. // nested splitter.
  321. if (!m_wndSplitter3.CreateStatic(&m_wndSplitter2,   // our parent window is the first splitter
  322. 1, 2,                                           // the new splitter is 2 rows, 1 column
  323. WS_CHILD | WS_VISIBLE | WS_BORDER,              // style, WS_BORDER is needed
  324. m_wndSplitter2.IdFromRowCol(1, 0)))             // new splitter is in the first row, 3rd column of first splitter
  325. {
  326. TRACE0("Failed to create nested splittern");
  327. return FALSE;
  328. }
  329. // add the tree view.
  330. if (!m_wndSplitter3.CreateView(0, 0, RUNTIME_CLASS(CItemTreeView),
  331. CSize(175, 0), pContext))
  332. {
  333. TRACE0("Failed to create CContainerViewn");
  334. return FALSE;
  335. }
  336. // Initialize m_pwndTreeCtrl to point to the tree control in CItemTreeView
  337. m_pItemTreeView = (CItemTreeView*)m_wndSplitter3.GetPane(0,0);
  338. ASSERT_VALID(m_pItemTreeView);
  339. m_pwndTreeCtrl = &m_pItemTreeView->m_wndTreeCtrl;
  340. ASSERT_VALID(m_pwndTreeCtrl);
  341. // Third nested splitter contains list view and preview
  342. // window.
  343. if (!m_wndSplitter4.CreateStatic(&m_wndSplitter3,   // our parent window is the first splitter
  344. 2, 1,                                           // the new splitter is 2 rows, 1 column
  345. WS_CHILD | WS_VISIBLE | WS_BORDER,              // style, WS_BORDER is needed
  346. m_wndSplitter3.IdFromRowCol(0, 1)))             // new splitter is in the first row, 3rd column of first splitter
  347. {
  348. TRACE0("Failed to create nested splittern");
  349. return FALSE;
  350. }
  351. if (!m_wndSplitter4.CreateView(0, 0, RUNTIME_CLASS(CGUI_OutlookView),
  352. CSize(0, 200), pContext))
  353. {
  354. TRACE0("Failed to create CContainerViewn");
  355. return FALSE;
  356. }
  357. if (!m_wndSplitter4.CreateView(1, 0, RUNTIME_CLASS(CPreviewPane),
  358. CSize(0, 0), pContext))
  359. {
  360. TRACE0("Failed to create CContainerViewn");
  361. return FALSE;
  362. }
  363. m_wndSplitter1.RecalcLayout();
  364. m_wndSplitter2.RecalcLayout();
  365. m_wndSplitter3.RecalcLayout();
  366. m_wndSplitter4.RecalcLayout();
  367. m_wndSplitter2.SetSplitterStyle(XT_SPLIT_NOFULLDRAG | XT_SPLIT_NOSIZE | XT_SPLIT_NOBORDER);
  368. if (m_pwndTreeCtrl)
  369. {
  370. m_pwndTreeCtrl->SetFocus();
  371. }
  372. return TRUE;
  373. }
  374. BOOL CMainFrame::InitializeOutlookBar()
  375. {
  376. // Create the outbar control, set the id to the first row/col.
  377. if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0),
  378. &m_wndSplitter1, m_wndSplitter1.IdFromRowCol(0, 0)))
  379. {
  380. TRACE0("Failed to create outlook bar.");
  381. return FALSE;
  382. }
  383. // Tell the control to send message to this window (the mainframe)
  384. // and not to its real parent (the splitter)
  385. m_wndOutlookBar.SetOwner(this);
  386. // Add icons to the large and small image lists.
  387. int nFolder;
  388. m_wndOutlookBar.SetIconSize(CSize(32, 32));
  389. // Add folders to the outlook bar. Input values are folder text
  390. // and lParam value.
  391. for (nFolder = 0; nFolder < _countof(FolderDefs); nFolder++)
  392. {
  393. // Get pointer to folder definition
  394. FOLDER_DEF* pFolder = &FolderDefs[nFolder];
  395. // Load folder label and add folder
  396. CString str;
  397. str.LoadString (pFolder->m_nTextID);
  398. CXTPTaskPanelGroup* pGroup = m_wndOutlookBar.AddGroup(pFolder->m_nTextID);
  399. // Add folder entries
  400. UINT nEntry;
  401. for (nEntry = 0; nEntry < pFolder->m_nEntries; nEntry++)
  402. {
  403. // Get pointer to entry, load text and add entry
  404. FOLDER_ENTRY* pDef = &pFolder->m_pEntries[nEntry];
  405. str.LoadString (pDef->m_nTextID);
  406. pGroup->AddLinkItem(pDef->m_nTextID, pDef->m_nIndex);
  407. m_wndOutlookBar.GetImageManager()->SetIcon(pDef->m_nIconID, pDef->m_nIndex);
  408. }
  409. }
  410. m_wndOutlookBar.SetBehaviour(xtpTaskPanelBehaviourList);
  411. m_wndOutlookBar.SetSelectItemOnFocus(TRUE);
  412. // Select the first folder.
  413. m_wndOutlookBar.GetAt(0)->SetExpanded(TRUE);
  414. m_wndOutlookBar.AllowDrag(TRUE);
  415. // Sizing for splitter
  416. CRect r;
  417. GetClientRect(&r);
  418. m_wndSplitter1.SetColumnInfo( 0, r.Width()/7, 0 );
  419. m_wndSplitter1.SetColumnInfo( 1, r.Width()/5, 0 );
  420. return TRUE;
  421. }
  422. BOOL CMainFrame::InitializeCaptionBar()
  423. {
  424. if (!m_wndCaption.Create(&m_wndSplitter2, _T("Caption Text"), NULL,
  425. WS_VISIBLE|SS_CENTER|SS_CENTERIMAGE, CRect(0,0,0,0), m_wndSplitter2.IdFromRowCol(0, 0)))
  426. {
  427. TRACE0("Failed to caption window.n");
  428. return FALSE;
  429. }
  430. HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  431. // set the caption colors.
  432. m_wndCaption.SetCaptionColors (GetXtremeColor(COLOR_3DFACE),
  433. GetXtremeColor(COLOR_3DSHADOW), GetXtremeColor(COLOR_WINDOW) );
  434. LOGFONT lf;
  435. XTAuxData().fontBold.GetLogFont(&lf);
  436. lf.lfHeight = 18;
  437. m_fontCaption.CreateFontIndirect(&lf);
  438. // set the font and initial icon.
  439. m_wndCaption.ModifyCaptionStyle(0,
  440. &m_fontCaption, NULL, hIcon);
  441. // Sizing for splitter
  442. m_wndSplitter2.SetRowInfo (0, 22, 0);
  443. return TRUE;
  444. }
  445. LRESULT CMainFrame::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
  446. {
  447. switch (wParam)
  448. {
  449. case XTP_TPN_CLICK:
  450. {
  451. CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)lParam;
  452. TRACE(_T("Click Event: pItem.Caption = %s, pItem.ID = %in"), pItem->GetCaption(), pItem->GetID());
  453. HTREEITEM hItem = m_pwndTreeCtrl->FindItem (pItem->GetCaption());
  454. if (hItem) {
  455. m_pwndTreeCtrl->SelectItem (hItem);
  456. }
  457. }
  458. break;
  459. case XTP_TPN_RCLICK:
  460. OnOutbarRButtonDown((CXTPTaskPanelItem*)lParam);
  461. return TRUE;
  462. }
  463. return 0;
  464. }
  465. void CMainFrame::OnRenameItem(CXTPTaskPanelItem* pItem)
  466. {
  467. CXTPTaskPanelGroup* pGroup = pItem->GetItemGroup();
  468. if (pGroup->GetItemLayout() == xtpTaskItemLayoutImages)
  469. pGroup->SetItemLayout(xtpTaskItemLayoutDefault);
  470. m_wndOutlookBar.RenameItem(pItem);
  471. }
  472. void CMainFrame::OnOutbarRButtonDown(CXTPTaskPanelItem* pItem)
  473. {
  474. CPoint pt;
  475. GetCursorPos(&pt);
  476. CXTPTaskPanelGroup* pGroup = pItem->GetItemGroup();
  477. BOOL bGroup = pItem->GetType() == xtpTaskItemTypeGroup;
  478. ASSERT(pGroup);
  479. CMenu menu;
  480. menu.LoadMenu(IDR_POPUP_TOOLBOX);
  481. CMenu* pMenuPopup = menu.GetSubMenu(bGroup? 1: 0);
  482. if (pGroup->GetItemLayout() != xtpTaskItemLayoutImagesWithText)
  483. pMenuPopup->CheckMenuItem(ID_TOOLBOX_LISTVIEW, MF_CHECKED|MF_BYCOMMAND);
  484. CXTPTaskPanelItems* pItems = pItem->GetParentItems();
  485. if (pItem->GetIndex() == 0)
  486. pMenuPopup->EnableMenuItem(ID_TOOLBOX_MOVEUP, MF_DISABLED|MF_BYCOMMAND);
  487. if (pItem->GetIndex() == pItems->GetCount() - 1)
  488. pMenuPopup->EnableMenuItem(ID_TOOLBOX_MOVEDOWN, MF_DISABLED|MF_BYCOMMAND);
  489. if (!::IsClipboardFormatAvailable(CXTPTaskPanel::GetClipboardFormat()))
  490. pMenuPopup->EnableMenuItem(ID_EDIT_PASTE, MF_DISABLED|MF_BYCOMMAND);
  491. int nReturn = CXTPCommandBars::TrackPopupMenu(pMenuPopup, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_NONOTIFY, pt.x, pt.y, this);
  492. switch (nReturn)
  493. {
  494. case ID_TOOLBOX_RENAME:
  495. OnRenameItem(pItem);
  496. break;
  497. case ID_TOOLBOX_ADDTAB:
  498. {
  499. CXTPTaskPanelGroup* pGroup = m_wndOutlookBar.AddGroup(0);
  500. m_wndOutlookBar.RenameItem(pGroup);
  501. }
  502. break;
  503. case ID_TOOLBOX_LISTVIEW:
  504. if (pGroup->GetItemLayout() == xtpTaskItemLayoutImagesWithText)
  505. {
  506. pGroup->SetItemLayout(xtpTaskItemLayoutDefault);
  507. pGroup->SetIconSize(CSize(32, 32));
  508. }
  509. else
  510. {
  511. pGroup->SetItemLayout(xtpTaskItemLayoutImagesWithText);
  512. pGroup->SetIconSize(CSize(16, 16));
  513. }
  514. break;
  515. case ID_TOOLBOX_MOVEDOWN:
  516. case ID_TOOLBOX_MOVEUP:
  517. {
  518. CXTPTaskPanelItems* pItems = pItem->GetParentItems();
  519. pItems->Move(pItem, pItem->GetIndex() + (nReturn == ID_TOOLBOX_MOVEDOWN? +1: -1));
  520. }
  521. break;
  522. case ID_EDIT_COPY:
  523. pItem->CopyToClipboard();
  524. break;
  525. case ID_EDIT_PASTE:
  526. {
  527. CXTPTaskPanelItem* pItem = CXTPTaskPanelItem::PasteFromClipboard();
  528. if (pItem)
  529. {
  530. CXTPTaskPanelItems* pItems = pGroup->GetItems();
  531. pItems->InsertAt(pItems->GetCount(), pItem);
  532. }
  533. }
  534. break;
  535. case ID_EDIT_CUT:
  536. pItem->CopyToClipboard();
  537. case ID_TOOLBOX_DELETE:
  538. pItem->Remove();
  539. break;
  540. }
  541. }
  542. void CMainFrame::CloseTreeViewPane()
  543. {
  544. ASSERT_VALID(this);
  545. m_wndCaption.SetChildWindow (m_pwndTreeCtrl, this);
  546. m_wndSplitter3.HideColumn(0);
  547. }
  548. void CMainFrame::OnPushPinButton()
  549. {
  550. m_wndSplitter3.ShowColumn();
  551. }
  552. void CMainFrame::OnPushPinCancel()
  553. {
  554. // TODO: Add your message handler code here and/or call default
  555. }
  556. void CMainFrame::OnDoNothing()
  557. {
  558. // TODO: Add your command handler code here
  559. }
  560. void CMainFrame::OnFilePreviewpane()
  561. {
  562. m_bShowPreview = !m_bShowPreview;
  563. if (m_bShowPreview) {
  564. m_wndSplitter4.ShowRow();
  565. }
  566. else {
  567. m_wndSplitter4.HideRow(1);
  568. }
  569. }
  570. void CMainFrame::OnUpdateFilePreviewpane(CCmdUI* pCmdUI)
  571. {
  572. pCmdUI->SetCheck(m_bShowPreview);
  573. }
  574. void CMainFrame::UpdateCaption(LPCTSTR lpszText, HICON hIcon)
  575. {
  576. m_wndCaption.UpdateCaption(lpszText, hIcon);
  577. }
  578. void CMainFrame::OnSysColorChange()
  579. {
  580. CFrameWnd::OnSysColorChange();
  581. // update toolkit colors.
  582. XTPColorManager()->RefreshColors();
  583. XTThemeManager()->RefreshMetrics();
  584. SetTheme(m_nTheme);
  585. }
  586. BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
  587. {
  588. if ( !CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext) )
  589. {
  590. return FALSE;
  591. }
  592. return TRUE;
  593. }
  594. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  595. {
  596. if (lpCreateControl->bToolBar && lpCreateControl->nID == ID_FILE_NEWMAIL)
  597. {
  598. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  599. lpCreateControl->buttonStyle = xtpButtonIconAndCaption;
  600. return TRUE;
  601. }
  602. if (lpCreateControl->bToolBar && lpCreateControl->nID == ID_SKIN_POPUP)
  603. {
  604. lpCreateControl->controlType = xtpControlPopup;
  605. return TRUE;
  606. }
  607. if (lpCreateControl->bToolBar &&
  608. (
  609. lpCreateControl->nID == ID_ACTIONS_REPLY ||
  610. lpCreateControl->nID == ID_ACTIONS_REPLYTOALL ||
  611. lpCreateControl->nID == ID_FILE_SENDRECEIVE ||
  612. lpCreateControl->nID == ID_FILE_FIND ||
  613. lpCreateControl->nID == ID_FILE_ORGANIZE ||
  614. lpCreateControl->nID == ID_ACTIONS_FORWARD
  615. ))
  616. {
  617. lpCreateControl->buttonStyle = xtpButtonIconAndCaption;
  618. return TRUE;
  619. }
  620. if (lpCreateControl->nID == ID_GOTO_URL)
  621. {
  622. CXTPControlComboBox* pComboState = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  623. for (int i = 0; i < _countof(OutlookShortcuts); i++)
  624. {
  625. CString str;
  626. str.LoadString(OutlookShortcuts[i].m_nTextID);
  627. pComboState->AddString(str);
  628. }
  629. pComboState->SetFlags(xtpFlagManualUpdate);
  630. pComboState->SetDropDownWidth(150);
  631. lpCreateControl->pControl = pComboState;
  632. return TRUE;
  633. }
  634. return FALSE;
  635. }
  636. void CMainFrame::OnCustomize()
  637. {
  638. CXTPCustomizeSheet cs(GetCommandBars());
  639. CXTPCustomizeOptionsPage pageOptions(&cs);
  640. cs.AddPage(&pageOptions);
  641. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  642. pCommands->AddCategories(IDR_MAINFRAME);
  643. pCommands->InsertAllCommandsCategory();
  644. pCommands->InsertNewMenuCategory();
  645. cs.DoModal();
  646. }
  647. void CMainFrame::OnGotoURL(NMHDR* pNMHDR, LRESULT* pResult)
  648. {
  649. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  650. CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl;
  651. if (pControl->GetType() == xtpControlComboBox)
  652. {
  653. int nState = pControl->GetCurSel();
  654. if (nState != -1)
  655. {
  656. CString str;
  657. pControl->GetLBText(nState, str);
  658. HTREEITEM hItem = m_pwndTreeCtrl->FindItem (str);
  659. if (hItem) {
  660. m_pwndTreeCtrl->SelectItem (hItem);
  661. }
  662. }
  663. *pResult = TRUE; // Handled
  664. }
  665. }
  666. void CMainFrame::OnClose()
  667. {
  668. SaveCommandBars(_T("CommandBars4"));
  669. CFrameWnd::OnClose();
  670. }
  671. void CMainFrame::UpdateButtonStyle(CXTCaptionButton& btnCaption)
  672. {
  673. DWORD dwBtnStyle = (btnCaption.GetXButtonStyle() &
  674. ~(BS_XT_FLAT|BS_XT_XPFLAT));
  675. if (m_nTheme != xtpThemeOffice2000)
  676. {
  677. btnCaption.SetXButtonStyle(
  678. dwBtnStyle|BS_XT_XPFLAT, FALSE);
  679. }
  680. else
  681. {
  682. btnCaption.SetXButtonStyle(
  683. dwBtnStyle|BS_XT_FLAT, FALSE);
  684. }
  685. }
  686. void CMainFrame::SetTheme(XTPPaintTheme nTheme)
  687. {
  688. m_nTheme = nTheme;
  689. XTPPaintManager()->SetTheme(nTheme);
  690. UpdateButtonStyle(m_wndCaption.GetCaptionButton());
  691. UpdateButtonStyle(m_pItemTreeView->m_wndCaption.GetCaptionButton());
  692. XTThemeStyle nControlsTheme = m_nTheme == xtpThemeNativeWinXP? xtThemeDefault: m_nTheme == xtpThemeOffice2000? xtThemeDefault:
  693. m_nTheme == xtpThemeOfficeXP? xtThemeOfficeXP: xtThemeOffice2003;
  694. XTThemeManager()->SetTheme(nControlsTheme);
  695. if ( m_nTheme == xtpThemeNativeWinXP)
  696. {
  697. m_wndOutlookBar.SetTheme(xtpTaskPanelThemeNativeWinXP);
  698. CXTHeaderCtrl::SetDefaultTheme(new CXTHeaderCtrlThemeExplorer());
  699. }
  700. else if ( m_nTheme == xtpThemeOffice2000)
  701. m_wndOutlookBar.SetTheme(xtpTaskPanelThemeListView);
  702. else if ( m_nTheme == xtpThemeOfficeXP)
  703. m_wndOutlookBar.SetTheme(xtpTaskPanelThemeListViewOfficeXP);
  704. else m_wndOutlookBar.SetTheme(xtpTaskPanelThemeShortcutBarOffice2003);
  705. if ( m_nTheme == xtpThemeNativeWinXP)
  706. {
  707. m_wndCaption.SetTheme(xtThemeOffice2003);
  708. m_pItemTreeView->m_wndCaption.SetTheme(new CXTCaptionThemeNativeWinXP);
  709. }
  710. else if ( m_nTheme != xtpThemeOffice2003)
  711. {
  712. m_wndCaption.SetTheme(nControlsTheme);
  713. m_pItemTreeView->m_wndCaption.SetTheme(nControlsTheme);
  714. }
  715. else
  716. {
  717. m_wndCaption.SetTheme(nControlsTheme);
  718. m_pItemTreeView->m_wndCaption.SetTheme(new CXTCaptionThemeOffice2003);
  719. }
  720. GetCommandBars()->RedrawCommandBars();
  721. RedrawWindow(NULL, NULL,
  722. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
  723. RecalcLayout();
  724. MoveWindow(CXTPWindowRect(this));
  725. m_wndSplitter1.RecalcLayout();
  726. m_wndSplitter2.RecalcLayout();
  727. m_wndSplitter3.RecalcLayout();
  728. m_wndSplitter4.RecalcLayout();
  729. m_wndOutlookBar.Reposition(FALSE);
  730. }
  731. void CMainFrame::OnViewThemeOfficexp()
  732. {
  733. SetTheme(xtpThemeOfficeXP);
  734. }
  735. void CMainFrame::OnUpdateViewThemeOfficexp(CCmdUI* pCmdUI)
  736. {
  737. pCmdUI->SetCheck(m_nTheme == xtpThemeOfficeXP);
  738. }
  739. void CMainFrame::OnViewThemeOffice2003()
  740. {
  741. SetTheme(xtpThemeOffice2003);
  742. }
  743. void CMainFrame::OnUpdateViewThemeOffice2003(CCmdUI* pCmdUI)
  744. {
  745. pCmdUI->SetCheck(m_nTheme == xtpThemeOffice2003);
  746. }
  747. void CMainFrame::OnViewThemeOffice2000()
  748. {
  749. SetTheme(xtpThemeOffice2000);
  750. }
  751. void CMainFrame::OnUpdateViewThemeOffice2000(CCmdUI* pCmdUI)
  752. {
  753. pCmdUI->SetCheck(m_nTheme == xtpThemeOffice2000);
  754. }
  755. void CMainFrame::OnViewThemeWinXP()
  756. {
  757. SetTheme(xtpThemeNativeWinXP);
  758. }
  759. void CMainFrame::OnUpdateViewThemeWinXP(CCmdUI* pCmdUI)
  760. {
  761. pCmdUI->SetCheck(m_nTheme == xtpThemeNativeWinXP);
  762. }
  763. CString CMainFrame::GetStylesPath()
  764. {
  765. TCHAR szStylesPath[_MAX_PATH];
  766. VERIFY(::GetModuleFileName(
  767. AfxGetApp()->m_hInstance, szStylesPath, _MAX_PATH));
  768. CString csStylesPath(szStylesPath);
  769. int nIndex  = csStylesPath.ReverseFind(_T('\'));
  770. if (nIndex > 0) {
  771. csStylesPath = csStylesPath.Left(nIndex);
  772. }
  773. else {
  774. csStylesPath.Empty();
  775. }
  776. return csStylesPath + _T("\Styles\");
  777. }
  778.  
  779. void CMainFrame::OnSkinChanged(UINT nID)
  780. {
  781. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  782. switch (nID)
  783. {
  784. case ID_SKIN_LUNABLUE:
  785. XTPSkinManager()->LoadSkin(GetStylesPath() + _T("WinXP.Luna.cjstyles"), _T("NormalBlue.INI"));
  786. break;
  787. case ID_SKIN_LUNAOLIVE:
  788. XTPSkinManager()->LoadSkin(GetStylesPath() + _T("WinXP.Luna.cjstyles"), _T("NormalHomeStead.INI"));
  789. break;
  790. case ID_SKIN_LUNAMETALLIC:
  791. XTPSkinManager()->LoadSkin(GetStylesPath() + _T("WinXP.Luna.cjstyles"), _T("NormalMetallic.INI"));
  792. break;
  793. case ID_SKIN_ROYALE:
  794. XTPSkinManager()->LoadSkin(GetStylesPath() + _T("WinXP.Royale.cjstyles"));
  795. break;
  796. default:
  797. XTPSkinManager()->LoadSkin(_T(""), _T(""));
  798. }
  799. #endif
  800. }
  801. void CMainFrame::OnSkinPopup()
  802. {
  803. }