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 » How to use AddAnchor() in a CFormView ? Collapse All
Subject Author Date
Emmanuel Verguet Oct 15, 2003 - 9:13 AM

Hi,

I’m using a CMyView class derived from CFormView. I have some controls in it, and I want to use AddAnchor() to resize my controls when my view is resized.

I think I do not have to derive from CFormView; This is why AddAnchor() is not defined :), but i don’t know how to do that...

Thanks for your help,

Emmanuel.

Sergiy Lavrynenko Oct 15, 2003 - 11:32 PM

Dear Emmanuel,

Please do following steps:

1) Add template-adaptor class into your project (somewhere before your view class declaration):


template < class CExtAFVBase >
class CExtAFV : public CExtAFVBase
{
public:
    CExtAFV()
    {
    }
    CExtAFV( LPCTSTR lpszTemplateName, CWnd * pParentWnd )
        : CExtAFVBase( lpszTemplateName )
    {
        pParentWnd;
    }
    CExtAFV( UINT nIDTemplate, CWnd * pParentWnd )
        : CExtAFVBase( nIDTemplate )
    {
        pParentWnd;
    }
};

2) Modify your view class declaration:

// class CTestView : public CFormView
class CTestView
    : public CExtWA < CExtAFV < CFormView > >

3) Modify your view class constructor:

CTestView::CTestView()
//  : CFormView(CTestView::IDD)
    : CExtWA < CExtAFV < CFormView > >
            ( CTestView::IDD, ((CWnd *)NULL) )

4) Now your form view has full anchoring support (absolutely like CExtResizableDialog); To remove scroll bars please add WM_SIZE message handler like this:

void CTestView::OnSize(UINT nType, int cx, int cy) 
{
//  CFormView::OnSize(nType, cx, cy);
    CWnd::OnSize(nType, cx, cy);
}

5) That’s all :-)

Best regards, Sergiy.

Dmitriy Yakovlev Oct 17, 2003 - 1:26 AM

For correct background painting of a window according to the current theme you should use CExtWS template.

CExtWA < CExtWS < CExtAFV < CFormView > > >

Emmanuel Verguet Oct 16, 2003 - 3:24 AM

It’s working :)

Thanks, Emmanuel.