Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Adding a Toolbar to  a Dialog
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding a Toolbar to a Dialog

 Post Reply Post Reply
Author
Message
Wolfgang View Drop Down
Newbie
Newbie


Joined: 01 December 2003
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote Wolfgang Quote  Post ReplyReply Direct Link To This Post Topic: Adding a Toolbar to a Dialog
    Posted: 16 September 2004 at 3:32am

Hi!

This time a simple question, i want to add an CXTPToolbar to an Dialog, which is quite easy, but I need it on the right side of the dialog. How must I insert and initialize the CXTPDialog therefore?

Thanx in advance

Wolfgang

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2004 at 9:00am

class CRightToolBar : public CXTPToolBar
{
 LRESULT OnSizeParent(WPARAM, LPARAM lParam);
 DECLARE_MESSAGE_MAP();
};

BEGIN_MESSAGE_MAP(CRightToolBar, CXTPToolBar)
 ON_MESSAGE(WM_SIZEPARENT, OnSizeParent)
END_MESSAGE_MAP()

LRESULT CRightToolBar::OnSizeParent(WPARAM, LPARAM lParam)
{
 AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;

 if (GetStyle() & WS_VISIBLE)
 {
  m_barPosition = xtpBarRight;
  
  // align the control bar
  CRect rect;
  rect.CopyRect(&lpLayout->rect);

  CSize sizeAvail = rect.Size(); 

  // get maximum requested size
  DWORD dwMode = LM_VERTDOCK|LM_COMMIT;
  if (GetFlags() & xtpFlagStretched) dwMode |= LM_STRETCH;
  if (GetFlags() & xtpFlagHideWrap) dwMode |= LM_HIDEWRAP;

  if (lpLayout->hDWP == NULL) dwMode &= ~LM_COMMIT;

  CSize size = CalcDockingLayout(32000, dwMode);

  size.cx = min(size.cx, sizeAvail.cx);
  size.cy = min(size.cy, sizeAvail.cy);

  lpLayout->sizeTotal.cy += size.cy;
  lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
  lpLayout->rect.right -= size.cx;

  rect.left = rect.right - size.cx;
  rect.bottom = rect.top + size.cy;

  // only resize the window if doing layout and not just rect query
  if (lpLayout->hDWP != NULL)
   AfxRepositionWindow(lpLayout, m_hWnd, &rect);
  
 }
 return 0;
}

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.