Print Page | Close Window

Adding a Toolbar to a Dialog

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=1179
Printed Date: 06 March 2025 at 4:07am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Adding a Toolbar to a Dialog
Posted By: Wolfgang
Subject: Adding a Toolbar to a Dialog
Date 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




Replies:
Posted By: Oleg
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net