Print Page | Close Window

resizable dialog & problem with toolbar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=484
Printed Date: 19 May 2024 at 3:29pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: resizable dialog & problem with toolbar
Posted By: Joe Brown
Subject: resizable dialog & problem with toolbar
Date Posted: 01 March 2004 at 10:52am
I have a CXTResizeDialog app and added a toolbar to the top. My dialog also has a few buttons and list controls. When the app starts, everything looks fine, but as soon as I resize the dialog in any direction, all of the controls resize incorrectly.

It almost seems as if they don't take into account the presence of the toolbar when recalculating new sizes and positions, because I've commented out my toolbar code and everything works fine.

Here is my OnInitDialog function. I took the toolbar creation and resizing code from one of the sample dialog apps and toolbar apps.


BOOL CVolEditDlg::OnInitDialog()
{
     CXTResizeDialog::OnInitDialog( );

// cut out a bunch of code that adds columns to my 2 list controls.

     CXTPPaintManager::SetTheme(xtp ThemeOfficeXP);
     XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
     pIconsInfo->bUseDisabledIco ns = TRUE;
     pIconsInfo->bIconsWithShado w = FALSE;
     pIconsInfo->bUseFadedIcons = TRUE;

     VERIFY(m_toolbar.CreateToolBar (WS_VISIBLE|WS_CHILD|CBRS_TOOLTIPS|CBRS_GRIPPER, this, AFX_IDW_TOOLBAR));
     VERIFY(m_toolbar.LoadToolBar(I DR_TOOLBAR));
     m_toolbar.SetFlags(xtpFlagStre tched);

     ((CXTPControlButton*)m_toolbar .GetControls()->FindControl(xtpControlButton, ID_FILE_OPEN, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);
     ((CXTPControlButton*)m_toolbar .GetControls()->FindControl(xtpControlButton, ID_FILE_SAVE, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);
     ((CXTPControlButton*)m_toolbar .GetControls()->FindControl(xtpControlButton, ID_CLEAR, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

     CRect rcClientStart;
     CRect rcClientNow;
     GetClientRect(rcClientStart);
     RepositionBars(AFX_IDW_CONTROL BAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);

     CPoint ptOffset(rcClientStart.left - rcClientNow.left, -rcClientStart.top + rcClientNow.top);
     
//     ptOffset.y -= ::GetSystemMetrics(SM_CYMENU);
     CRect rcChild;
     CWnd* pwndChild = GetWindow(GW_CHILD);
     while (pwndChild)
     {
           pwndChild->GetWindowRect(rcChild);
//         &nbs p;rcChild.OffsetRect(ptOffset);
           pwndChild->MoveWindow(rcChild, FALSE);
           pwndChild = pwndChild->GetNextWindow();
     }

     CRect rcWindow;
     GetWindowRect(rcWindow);
     rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
     rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
     MoveWindow(rcWindow, FALSE);
     RepositionBars(AFX_IDW_CONTROL BAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
     // END create toolbar and reposition controls so toolbar is at the top

     // Set control resizing.
     SetResize(IDC_TXT_PWR_SUPPLIES , SZ_TOP_LEFT, SZ_TOP_RIGHT);
     SetResize(IDC_PWR_SUPPLIES, SZ_TOP_LEFT, SZ_TOP_RIGHT);
     SetResize(IDC_TXT_PWR_SEQ, SZ_TOP_LEFT, SZ_TOP_RIGHT);
     SetResize(IDC_PWR_SEQ_LIST, SZ_TOP_LEFT, SZ_BOTTOM_RIGHT);
     SetResize(IDC_ADD_POWER_SEQ_BU TTON, SZ_BOTTOM_RIGHT, SZ_BOTTOM_RIGHT);
     SetResize(IDC_DELETE_POWER_SEQ _BUTTON, SZ_BOTTOM_RIGHT, SZ_BOTTOM_RIGHT);
     SetResize(IDC_UP_POWER_SEQ, SZ_BOTTOM_RIGHT, SZ_BOTTOM_RIGHT);
     SetResize(IDC_DOWN_POWER_SEQ, SZ_BOTTOM_RIGHT, SZ_BOTTOM_RIGHT);

     // Load window placement
     LoadPlacement(_T("CVolEditDlg" ));
     SetMinSize(CSize(rcWindow.Widt h(), rcWindow.Height()));
     AdjustListCtrlLastColumnWidth( );

     return TRUE; // return TRUE unless you set the focus to a control
}



Replies:
Posted By: Alex H.
Date Posted: 03 September 2004 at 7:07am

You should use CXTCBarDialog, if working with the 4.1 or 4.0 Standard Edition.

This works much better :-)




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