Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CExtWS < CExtWA < CExtAFV < CFormView > > > Collapse All
Subject Author Date
Krustys Donuts Aug 3, 2005 - 1:18 AM

Hello-

I needed to add a far-too-busy dialog to a CExtSplitterWnd pane. I encapsulated my dialog in a CExtWS < CExtWA < CExtAFV < CFormView > > >, thinking it would magically handle all of the resizing for me. In OnInitialUpdate() I put all my AddAnchor code.

The resizing sort of works... when I resize the pane all of my controls resize properly. The problem is that initially the controls are all in the wrong positions. For example, in the resource editor I placed a button at the bottom of my dialog. However, at runtime when the dialog gets rendered in the pane, it’s not at the bottom of the pane but somewhere in the middle. Yet if I resize the pane by stretching it horizontally, the button stretches correctly.

What am I doing wrong? Or should I not be using CExtWS < CExtWA < CExtAFV < CFormView > > > at all?

Thanks.

Technical Support Aug 3, 2005 - 1:07 PM

You should handle the WM_SIZE, WM_VSCROLL and WM_HSCROLL messages and redirect them directly to the CView class rather than to the parent class:

void CChildFormView::OnSize(UINT nType, int cx, int cy) 
{
      CView::OnSize(nType, cx, cy);
}
 
void CChildFormView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
      CView::OnVScroll(nSBCode, nPos, pScrollBar);
}
 
void CChildFormView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
      CView::OnHScroll(nSBCode, nPos, pScrollBar);
}

Krustys Donuts Aug 3, 2005 - 1:36 PM

Hello-


 


This is what I have that DOESN’T work:


void CViewDeviceTree::OnInitialUpdate()
{
 CExtWS < CExtWA < CExtAFV < CFormView > > >::OnInitialUpdate();


 ShowSizeGrip( FALSE );


 //This doesn’t seem to work right so I override OnSize instead
 AddAnchor(tree, CPoint(0,0), CPoint(100,100));
 AddAnchor(m_DeleteDevice, CPoint(0,100), CPoint(100,100));
 AddAnchor(m_DeviceDiagnostics, CPoint(0,100), CPoint(100,100));
 AddAnchor(m_InitializeDevices, CPoint(0,100), CPoint(100,100));
 AddAnchor(m_CloseDevices, CPoint(0,100), CPoint(100,100));
}


 


void CViewDeviceTree::OnSize(UINT nType, int cx, int cy)


{      CView::OnSize(nType, cx, cy);


}


 void CViewDeviceTree::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)


 {


      CView::OnVScroll(nSBCode, nPos, pScrollBar);


}


 void CViewDeviceTree::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)



     CView::OnHScroll(nSBCode, nPos, pScrollBar);


}


 


And this DOES work:


void CViewDeviceTree::OnInitialUpdate()
{
 CExtWS < CExtWA < CExtAFV < CFormView > > >::OnInitialUpdate();


 ShowSizeGrip( FALSE );


}
//-----------------------------------------------------------------------------
void CViewDeviceTree::OnSize(UINT nType, int cx, int cy)
{
 CExtWS < CExtWA < CExtAFV < CFormView > > >::OnSize(nType, cx, cy);
 if (IsWindow(tree.m_hWnd))
  tree.MoveWindow( 0, 0, cx, cy-120);
 if (IsWindow(m_InitializeDevices.m_hWnd))
  m_InitializeDevices.MoveWindow( 0, cy-110, cx, 20);
 if (IsWindow(m_CloseDevices.m_hWnd))
  m_CloseDevices.MoveWindow( 0, cy-80, cx, 20);
 if (IsWindow(m_DeleteDevice.m_hWnd))
  m_DeleteDevice.MoveWindow( 0, cy-50, cx, 20);
 if (IsWindow(m_DeviceDiagnostics.m_hWnd))
  m_DeviceDiagnostics.MoveWindow( 0, cy-20, cx, 20);
}

Any other ideas?

Technical Support Aug 4, 2005 - 3:10 AM

The explanation is simple. When the CViewDeviceTree::OnInitialUpdate() method is called, the size of your form view is already changed. I.e. it is not equal to the original size of the loaded dialog template resource.

Krustys Donuts Aug 4, 2005 - 3:55 PM

So what’s a better function to set anchors in?


 


Thanks!

Technical Support Aug 5, 2005 - 10:10 AM

We recommend you set up anchors when the main frame window is created:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
 
    // create a view to occupy the client area of the frame
    m_pWndView = new CChildFormView;
    if (!m_pWndView->Create(
            NULL, 
            NULL, 
            AFX_WS_DEFAULT_VIEW, 
            CRect(0, 0, 0, 0), 
            this, 
            AFX_IDW_PANE_FIRST, 
            NULL
            )
        )
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }
 
    ....
 
    if( !m_wndMenuBar.Create(
            NULL,
            this,
            ID_VIEW_MENUBAR
            )
        )
    {
        TRACE0("Failed to create menubar\n");
        return -1;      // failed to create
    }
 
    m_pWndView->AddAnchor(IDC_DISABLE_PANE, __RDA_LT, __RDA_RT);
 
 
....