Advertisement
xiahanlu

WTL-依靠frame的最简tab

May 1st, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. class CMainFrame :
  2. public CFrameWindowImpl<CMainFrame>
  3. {
  4. public:
  5. DECLARE_FRAME_WND_CLASS(NULL, 0)
  6.  
  7. CTabView m_view;
  8.  
  9. virtual BOOL PreTranslateMessage(MSG* pMsg)
  10. {
  11. if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
  12. return TRUE;
  13.  
  14. return m_view.PreTranslateMessage(pMsg);
  15. }
  16.  
  17. BEGIN_MSG_MAP(CMainFrame)
  18. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  19. MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
  20. COMMAND_ID_HANDLER(ID_WINDOW_CLOSE, OnWindowClose)
  21. COMMAND_ID_HANDLER(ID_WINDOW_CLOSE_ALL, OnWindowCloseAll)
  22. CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
  23. END_MSG_MAP()
  24.  
  25. LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  26. {
  27. m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
  28. CView* pView = new CView;
  29. pView->Create(m_view, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
  30. m_view.AddPage(pView->m_hWnd, _T("Document"));
  31. return 0;
  32. }
  33.  
  34. LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
  35. {
  36. // unregister message filtering and idle updates
  37. CMessageLoop* pLoop = _Module.GetMessageLoop();
  38. ATLASSERT(pLoop != NULL);
  39.  
  40. bHandled = FALSE;
  41. return 1;
  42. }
  43.  
  44. LRESULT OnWindowClose(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  45. {
  46. int nActivePage = m_view.GetActivePage();
  47. if(nActivePage != -1)
  48. m_view.RemovePage(nActivePage);
  49. else
  50. ::MessageBeep((UINT)-1);
  51.  
  52. return 0;
  53. }
  54.  
  55. LRESULT OnWindowCloseAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  56. {
  57. m_view.RemoveAllPages();
  58.  
  59. return 0;
  60. }
  61.  
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement