Professional UI Solutions
Site Map   /  Register


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 » Anchoring in dynamically created CFormView with templates applied? Collapse All
Subject Author Date
Jase Wolfe Aug 7, 2007 - 8:53 AM

I have a mainframe with a splitter window and 2 CFormView representing the panes in the splitter. The CFormView panes are created dynamically with the splitter CreateView function. How would I add anchors to these CFormViews (they are dialog resources with base class CFormView with templates applied)

Here is the code for one of the formviews:

// Header
#pragma once
#include "extbutton.h"

// CFormRight form view

class CFormRight : public CExtWA < CExtWS < CExtAFV < CFormView > > >

    CFormRight(); // protected constructor used by dynamic creation
    virtual ~CFormRight();

    enum { IDD = IDD_FORM_RIGHT };
#ifdef _DEBUG
    virtual void AssertValid() const;
#ifndef _WIN32_WCE
    virtual void Dump(CDumpContext& dc) const;

    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

    CExtButton m_btnCancel;
    CExtButton m_btnOK;
    virtual void OnInitialUpdate();

// Implementation
// FormRight.cpp : implementation file

#include "stdafx.h"
#include "ProfUIS_Split.h"
#include "FormRight.h"

// CFormRight


    : CExtWA < CExtWS < CExtAFV < CFormView > > > ( CFormRight::IDD, ((CWnd *)NULL) )



void CFormRight::DoDataExchange(CDataExchange* pDX)
    DDX_Control(pDX, IDCANCEL, m_btnCancel);
    DDX_Control(pDX, IDOK, m_btnOK);



// CFormRight diagnostics

#ifdef _DEBUG
void CFormRight::AssertValid() const

#ifndef _WIN32_WCE
void CFormRight::Dump(CDumpContext& dc) const
#endif //_DEBUG

// CFormRight message handlers

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

    // TODO: Add your specialized code here and/or call the base class

    ShowSizeGrip( FALSE );

    //AddAnchor( IDOK, CPoint( 100, 100 ), CPoint( 100, 100 ));

Technical Support Aug 8, 2007 - 10:02 AM

Unfortunately the anchoring feature provided by the CExtWA template class and the scrolling feature provided by MFC’s form view are not compatible with each other. We would like to provide you with two possible solutions here:

1) Disable scrolling in your form views. If it is acceptable for you, then you should handle the WM_HSCROLL, WM_VSCROLL and WM_SIZE messages in your form view class and invoke the CWnd::On***() parent class method instead of the CExtWA < CExtWS < CExtAFV < CFormView > > >::On***() nearest parent class method.

2) Replace each form view with a container window and CExtResizableDialog resizable dialog window inside this container. The CExtResizableDialog class is also based on CExtWA template class and supports anchoring. The container window should display scroll bars and scroll the child dialog if the size of this container window is less than the initial dialog size. Otherwise the container window should stretch its children dialog window to cover the entire container’s client area and allow the dialog to apply its anchoring rules. This is preferable solution (it will use Prof-UIS skinned scrollbars and themed dialog background will be compatible with scrolling) but you will have to modify your source code by removing the form view and adding resizable dialog and container. This sample application contains a ready-to-use scrollable container class which you can move into your project without any changes.

Timofey Smirnov Jun 2, 2008 - 4:18 AM

How to change appearing of scrollbars(if the size of this container window is less than the initial dialog size) to fixed size(user can’t resize less than initial dialog size) of container in sample?

Technical Support Jun 3, 2008 - 4:39 AM

You don’t need a scrollable dialog container at all if the dialog inside it can be resized to of a smaller size. You should simply use a CExtResizableDialog window without any scrollable container. If the dialog is a child window, its resizing is not limited. If this dialog is a popup window (modal or not), you can invoke its SetMinTrackSize() method to specify the minimum limit less than the initial dialog size.

Suhai Gyorgy Aug 8, 2007 - 1:23 AM