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

对话框与窗口

开发平台:

Visual C++

  1. // UIFrame.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "taskpanel.h"
  5. #include "UIFrame.h"
  6. #include "MainFrm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. static UINT indicators[] =
  13. {
  14. ID_SEPARATOR,           // status line indicator
  15. ID_INDICATOR_CAPS,
  16. ID_INDICATOR_NUM,
  17. ID_INDICATOR_SCRL,
  18. };
  19. CChildView::CChildView()
  20. {
  21. }
  22. CChildView::~CChildView()
  23. {
  24. }
  25. BEGIN_MESSAGE_MAP(CChildView,CWnd )
  26. //{{AFX_MSG_MAP(CChildView)
  27. ON_WM_PAINT()
  28. //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CChildView message handlers
  32. BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
  33. {
  34. if (!CWnd::PreCreateWindow(cs))
  35. return FALSE;
  36. cs.dwExStyle |= WS_EX_CLIENTEDGE;
  37. cs.style &= ~WS_BORDER;
  38. cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
  39. ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
  40. return TRUE;
  41. }
  42. void CChildView::OnPaint()
  43. {
  44. CPaintDC dc(this); // device context for painting
  45. CXTPClientRect rc(this);
  46. dc.FillSolidRect(rc, GetSysColor(COLOR_WINDOW));
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CUIFrame
  50. IMPLEMENT_DYNCREATE(CUIFrame, CFrameWnd)
  51. CUIFrame::CUIFrame()
  52. {
  53. }
  54. CUIFrame::~CUIFrame()
  55. {
  56. }
  57. BEGIN_MESSAGE_MAP(CUIFrame, CFrameWnd)
  58. //{{AFX_MSG_MAP(CUIFrame)
  59. ON_WM_CREATE()
  60. ON_WM_SETFOCUS()
  61. ON_WM_CLOSE()
  62. //}}AFX_MSG_MAP
  63. ON_COMMAND(ID_THEME_OFFICE2000, OnThemeOffice2000)
  64. ON_UPDATE_COMMAND_UI(ID_THEME_OFFICE2000, OnUpdateThemeOffice2000)
  65. ON_COMMAND(ID_THEME_OFFICE2003, OnThemeOffice2003)
  66. ON_UPDATE_COMMAND_UI(ID_THEME_OFFICE2003, OnUpdateThemeOffice2003)
  67. ON_COMMAND(ID_THEME_NATIVEWINXP, OnThemeNativewinxp)
  68. ON_UPDATE_COMMAND_UI(ID_THEME_NATIVEWINXP, OnUpdateThemeNativewinxp)
  69. ON_COMMAND(ID_THEME_OFFICE2000PLAIN, OnThemeOffice2000plain)
  70. ON_UPDATE_COMMAND_UI(ID_THEME_OFFICE2000PLAIN, OnUpdateThemeOffice2000plain)
  71. ON_COMMAND(ID_THEME_OFFICEXPPLAIN, OnThemeOfficexpplain)
  72. ON_UPDATE_COMMAND_UI(ID_THEME_OFFICEXPPLAIN, OnUpdateThemeOfficexpplain)
  73. ON_COMMAND(ID_THEME_OFFICE2003PLAIN, OnThemeOffice2003plain)
  74. ON_UPDATE_COMMAND_UI(ID_THEME_OFFICE2003PLAIN, OnUpdateThemeOffice2003plain)
  75. ON_COMMAND(ID_THEME_NATIVEWINXPPLAIN, OnThemeNativewinxpplain)
  76. ON_UPDATE_COMMAND_UI(ID_THEME_NATIVEWINXPPLAIN, OnUpdateThemeNativewinxpplain)
  77. ON_COMMAND(ID_TASKPANEL_ANIMATION, OnTaskpanelAnimation)
  78. ON_UPDATE_COMMAND_UI(ID_TASKPANEL_ANIMATION, OnUpdateTaskpanelAnimation)
  79. ON_MESSAGE(XTPWM_TASKPANEL_NOTIFY, OnTaskPanelNotify)
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CUIFrame message handlers
  83. int CUIFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  84. {
  85. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  86. return -1;
  87. if (!m_wndStatusBar.Create(this) ||
  88. !m_wndStatusBar.SetIndicators(indicators,
  89.   sizeof(indicators)/sizeof(UINT)))
  90. {
  91. TRACE0("Failed to create status barn");
  92. return -1;      // fail to create
  93. }
  94. return 0;
  95. }
  96. void CUIFrame::OnSetFocus(CWnd* pOldWnd) 
  97. {
  98. CFrameWnd::OnSetFocus(pOldWnd);
  99. // forward focus to the view window
  100. m_wndView.SetFocus();
  101. }
  102. BOOL CUIFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  103. {
  104. // let the view have first crack at the command
  105. if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  106. return TRUE;
  107. return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  108. }
  109. void CUIFrame::OnClose() 
  110. {
  111. // TODO: Add your message handler code here and/or call default
  112. CFrameWnd::OnClose();
  113. CMainFrame* pFrameWnd = (CMainFrame*)AfxGetMainWnd();
  114. if (pFrameWnd != NULL)
  115. {
  116. pFrameWnd->m_pUIFrame = NULL;
  117. }
  118. }
  119. BOOL CUIFrame::CreateTaskPanel()
  120. {
  121. if (!m_wndTaskPanel.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP, CRect(0, 0, 0, 0), &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0)))
  122. return FALSE;
  123. m_wndTaskPanel.SetOwner(this);
  124. m_wndSplitter.SetColumnInfo(0, 210, 0);
  125. CMenu menu;
  126. menu.LoadMenu(IDR_MAINFRAME);
  127. m_wndTaskPanel.CreateFromMenu(&menu);
  128. m_wndTaskPanel.m_bUIMode = TRUE;
  129. m_wndTaskPanel.SetHotTrackStyle(xtpTaskPanelHighlightItem);
  130. m_wndTaskPanel.GetImageManager()->SetIcons(IDR_MAINFRAME, 
  131. XTPImageManager()->IsAlphaIconsSupported() ?  IDR_TOOLBAR_A : IDR_MAINFRAME);
  132. return TRUE;
  133. }
  134. BOOL CUIFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* /*pContext*/) 
  135. {
  136. m_wndSplitter.CreateStatic(this, 1, 2);
  137. if (!CreateTaskPanel())
  138. return FALSE;
  139. // create a view to occupy the client area of the frame
  140. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
  141. CRect(0, 0, 0, 0), &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 1), NULL))
  142. {
  143. TRACE0("Failed to create view windown");
  144. return -1;
  145. }
  146. m_wndSplitter.ShowTopBorder(FALSE, 0);
  147. return TRUE;
  148. }
  149. LRESULT CUIFrame::OnTaskPanelNotify(WPARAM wParam, LPARAM lParam)
  150. {
  151. switch(wParam) {
  152. case XTP_TPN_CLICK:
  153. {
  154. CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)lParam;
  155. TRACE(_T("Click Event: pItem.Caption = %s, pItem.ID = %in"), pItem->GetCaption(), pItem->GetID());
  156. if (m_wndTaskPanel.m_bUIMode)
  157. {
  158. SendMessage(WM_COMMAND, pItem->GetID());
  159. }
  160. }
  161. break;
  162. }
  163. return 0;
  164. }
  165. void CUIFrame::SetTheme(XTPTaskPanelPaintTheme taskPanelTheme)
  166. {
  167. m_wndTaskPanel.SetTheme(taskPanelTheme);
  168. RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
  169. }
  170. void CUIFrame::OnThemeOffice2000()
  171. {
  172. SetTheme(xtpTaskPanelThemeOffice2000);
  173. }
  174. void CUIFrame::OnUpdateThemeOffice2000(CCmdUI* pCmdUI)
  175. {
  176. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeOffice2000);
  177. }
  178. void CUIFrame::OnThemeOffice2003()
  179. {
  180. SetTheme(xtpTaskPanelThemeOffice2003);
  181. }
  182. void CUIFrame::OnUpdateThemeOffice2003(CCmdUI* pCmdUI)
  183. {
  184. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeOffice2003);
  185. }
  186. void CUIFrame::OnThemeNativewinxp()
  187. {
  188. SetTheme(xtpTaskPanelThemeNativeWinXP);
  189. }
  190. void CUIFrame::OnUpdateThemeNativewinxp(CCmdUI* pCmdUI)
  191. {
  192. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeNativeWinXP);
  193. }
  194. void CUIFrame::OnThemeOffice2000plain()
  195. {
  196. SetTheme(xtpTaskPanelThemeOffice2000Plain);
  197. }
  198. void CUIFrame::OnUpdateThemeOffice2000plain(CCmdUI* pCmdUI)
  199. {
  200. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeOffice2000Plain);
  201. }
  202. void CUIFrame::OnThemeOfficexpplain()
  203. {
  204. SetTheme(xtpTaskPanelThemeOfficeXPPlain);
  205. }
  206. void CUIFrame::OnUpdateThemeOfficexpplain(CCmdUI* pCmdUI)
  207. {
  208. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeOfficeXPPlain);
  209. }
  210. void CUIFrame::OnThemeOffice2003plain()
  211. {
  212. SetTheme(xtpTaskPanelThemeOffice2003Plain);
  213. }
  214. void CUIFrame::OnUpdateThemeOffice2003plain(CCmdUI* pCmdUI)
  215. {
  216. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeOffice2003Plain);
  217. }
  218. void CUIFrame::OnThemeNativewinxpplain()
  219. {
  220. SetTheme(xtpTaskPanelThemeNativeWinXPPlain);
  221. }
  222. void CUIFrame::OnUpdateThemeNativewinxpplain(CCmdUI* pCmdUI)
  223. {
  224. pCmdUI->SetCheck(m_wndTaskPanel.GetCurrentTheme() == xtpTaskPanelThemeNativeWinXPPlain);
  225. }
  226. void CUIFrame::OnTaskpanelAnimation()
  227. {
  228. m_wndTaskPanel.SetAnimation(m_wndTaskPanel.GetAnimation() == xtpTaskPanelAnimationNo? xtpTaskPanelAnimationYes: xtpTaskPanelAnimationNo);
  229. }
  230. void CUIFrame::OnUpdateTaskpanelAnimation(CCmdUI* pCmdUI)
  231. {
  232. pCmdUI->SetCheck(m_wndTaskPanel.GetAnimation() == xtpTaskPanelAnimationYes);
  233. }