#. ReBar 컨트롤에 집어 넣을 윈도우 구현

   - TB_BUTTONCOUNT, TB_GETITEMRECT 2개의 메세지 구현해주면 ReBar에 넣을수있다.

 

 


/////////////////////////////////////////////////////////////////////////////
class C_WTLWINVIEW_View : public CWindowImpl<C_WTLWINVIEW_View>
{
public:
 DECLARE_WND_CLASS(NULL)

 BOOL PreTranslateMessage(MSG* pMsg)
 {
  pMsg;
  return FALSE;
 }

 BEGIN_MSG_MAP(C_WTLWINVIEW_View)
  MESSAGE_HANDLER ( WM_PAINT            , OnPaint              )
  MESSAGE_HANDLER ( TB_BUTTONCOUNT      , OnTB_ButtonCount     )
  MESSAGE_HANDLER ( TB_GETITEMRECT      , OnTB_GetItemRect     )
  MESSAGE_HANDLER ( TB_GETEXTENDEDSTYLE , OnTB_GetExtendedStyle)
  MESSAGE_HANDLER ( TB_SETEXTENDEDSTYLE , OnTB_SetExtendedStyle)
 END_MSG_MAP()

 // Handler prototypes (uncomment arguments if needed):
 // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
 // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

 LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  CPaintDC dc(m_hWnd);

  //TODO: Add your drawing code here

  return 0;
 }
 LRESULT OnTB_ButtonCount(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return int item count
  // wParam int 0
  // lParam int 0
  return 1;
 }
 LRESULT OnTB_GetItemRect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
 {
  // return BOOL  success
  // wParam int   button index
  // lParam RECT* button rect

  LPRECT lpRect = (LPRECT)lParam;

  lpRect->left  =0;
  lpRect->top   =0;
  lpRect->right =100;
  lpRect->bottom=20;

  return 1;
 }
 LRESULT OnTB_GetExtendedStyle(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return DWORD style
  // wParam int   0
  // lParam int   0
  return 0;
 }
 LRESULT OnTB_SetExtendedStyle(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return DWORD style
  // wParam int   0
  // lParam int   new style
  return 0;
 }
};

WTL::CFrameWindowImplBase::AddSimpleReBarBandCtrl()

 

/////////////////////////////////////////////////////////////////////////////

//

// Class: CMyToolWindow

//

/////////////////////////////////////////////////////////////////////////////

//===========================================================================

class CMyToolWindow : public CWindowImpl<CMyToolWindow>

{

public:

        //DECLARE_WND_CLASS(NULL)

        DECLARE_WND_CLASS_EX (NULL, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, (HBRUSH)(COLOR_APPWORKSPACE))

 

        BOOL PreTranslateMessage(MSG* pMsg)

        {

               pMsg;

               return FALSE;

        }

 

        BEGIN_MSG_MAP(CMyToolWindow)

               MESSAGE_HANDLER(TB_BUTTONCOUNT, OnToolBarButtonCount)

               MESSAGE_HANDLER(TB_GETITEMRECT, OnToolBarItemRect   )

               MESSAGE_HANDLER(WM_PAINT, OnPaint)

        END_MSG_MAP()

 

        LRESULT OnToolBarButtonCount(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

        {

               return 1;

        }

 

        LRESULT OnToolBarItemRect   (UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)

        {

               int    nButtonCount = (int)   wParam;

               LPRECT pRect        = (LPRECT)lParam;

 

               pRect->left   =0;

               pRect->top    =0;

 

               if (nButtonCount>0)

                       pRect->right  =100*nButtonCount;

               else

                       pRect->right  =100;

               pRect->bottom =25;

 

               return 1;

        }

 

        LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

        {

               CPaintDC dc(m_hWnd);

 

               //TODO: Add your drawing code here

               dc.TextOut (0,0,_T("xxx"));

               return 0;

        }

};

 

 

 

#. MainFrame 윈도우에서

 

CMyToolWindow m_MyToolWindow;

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        HWND hWndCmdBar;

        HWND hWndToolBar;

 

        hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);

        m_CmdBar.AttachMenu(GetMenu());

        m_CmdBar.LoadImages(IDR_MAINFRAME);

        SetMenu(NULL);

 

        hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);

 

        m_MyToolWindow.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_STATICEDGE);

 

        // Rebar

        CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);

        AddSimpleReBarBand(hWndCmdBar);

        AddSimpleReBarBand(hWndToolBar, NULL, TRUE);

        AddSimpleReBarBand(m_MyToolWindow, _T("MyToolWindow"), TRUE, 100, TRUE);

 

        // StatusBar

        CreateSimpleStatusBar();

 

        // View

        m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

 

        UIAddToolBar(hWndToolBar);

        UISetCheck(ID_VIEW_TOOLBAR, 1);

        UISetCheck(ID_VIEW_STATUS_BAR, 1);

 

        // register object for message filtering and idle updates

        CMessageLoop* pLoop = _Module.GetMessageLoop();

        ATLASSERT(pLoop != NULL);

        pLoop->AddMessageFilter(this);

        pLoop->AddIdleHandler(this);

 

        return 0;

}

 

Posted by 셈말짓기 :