Advertisement
Fernando_Fiore

CMDISplitterFrameImpl

Sep 22nd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. template <class T,bool t_bVertical = true, class TBase = CMDIWindow, class TWinTraits = CFrameWinTraits>
  2. class ATL_NO_VTABLE CMDISplitterFrameImpl : public CMDIFrameWindowImpl<T,TBase,TWinTraits>,
  3.     public CSplitterImpl<T,t_bVertical>
  4. {
  5.     typedef CMDIFrameWindowImpl<T,CMDIWindow,TWinTraits> _BaseClass;
  6.     typedef CSplitterImpl<T,t_bVertical > _splitter;
  7.     typedef CMDISplitterFrameImpl<T,t_bVertical,TBase,TWinTraits> _ThisClass;
  8. public:
  9.     BEGIN_MSG_MAP(_ThisClass)
  10.         MESSAGE_HANDLER(WM_CREATE,OnCreate)
  11.         MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
  12.         MESSAGE_HANDLER(WM_SIZE, OnSize)
  13.         CHAIN_MSG_MAP(_splitter)
  14.         CHAIN_MSG_MAP(_BaseClass)
  15.     END_MSG_MAP()
  16.  
  17.     LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  18.     {
  19.         _splitter::OnCreate(uMsg,wParam,lParam,bHandled);
  20.         bHandled = FALSE;
  21.         return 0;
  22.     }
  23.  
  24.     LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  25.     {
  26.         // handled, no background painting needed
  27.         return 1;
  28.     }
  29.  
  30.     LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  31.     {
  32.         if(wParam != SIZE_MINIMIZED)
  33.         {
  34.             T* pT = static_cast<T*>(this);
  35.             pT->UpdateLayout();
  36.         }
  37.         // message must be handled, otherwise DefFrameProc would resize the client again
  38.         return 0;
  39.     }
  40.  
  41.     void UpdateLayout(BOOL bResizeBars = TRUE)
  42.     {
  43.         RECT r = {0};
  44.  
  45.         GetClientRect(&r);
  46.         UpdateBarsPosition(r,bResizeBars);
  47.         SetSplitterRect(&r);
  48.     }
  49. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement