Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - resizable dialog & problem with toolbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

resizable dialog & problem with toolbar

 Post Reply Post Reply
Author
Message
Joe Brown View Drop Down
Newbie
Newbie


Joined: 01 March 2004
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote Joe Brown Quote  Post ReplyReply Direct Link To This Post Topic: resizable dialog & problem with toolbar
    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
}
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post 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 :-)

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.140 seconds.