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 Tech Support » How to get dialog pages embedded in dialog page to resize when parent dialog is resized? Collapse All
Subject Author Date
Bill Harris Jun 27, 2007 - 8:55 AM

Hopefully, I making a simple beginner mistake. I have built a simple dialog based application.
In the main dialog, I have embedded two dialog pages where only one of them is displayed
at one time. The page to be displayed is selected by two of the buttons at the bottom of the
main dialog. The problem I am having is that the items within the pages do not resize when
I resize the main dialog. What am I doing wrong?

I have purposefully not worried about implementing handlers for several of the controls -
to build the example quickly and keep the problem simple. Is there some essential handler
that I am missing?

Note - I am currently using Prof-UIS 2.64

The essential sample source code follows:

// MyDlgOne.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
#error "include ’stdafx.h’ before including this file for PCH"
#endif

#include "resource.h" // main symbols

#define __PROF_UIS_PROJECT_CMD_PROFILE_NAME _T("MyDlgOneProfile")

class CMyDlgOneApp : public CWinApp
{
public:
CMyDlgOneApp();

// Overrides
public:
virtual BOOL InitInstance();

// Implementation

//
// Prof-UIS advanced options
//
void SetupUiAdvancedOptions();

DECLARE_MESSAGE_MAP()
};

extern CMyDlgOneApp theApp;// MyDlgOne.cpp : Defines the class behaviors for the application.
//

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "stdafx.h"
#include "PageBase.h"
#include "MyDlgOne.h"
#include "MyDlgOneDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CMyDlgOneApp

BEGIN_MESSAGE_MAP(CMyDlgOneApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CMyDlgOneApp construction

CMyDlgOneApp::CMyDlgOneApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}


// The one and only CMyDlgOneApp object

CMyDlgOneApp theApp;

/////////////////////////////////////////////////////////////////////////////
// Prof-UIS advanced options

void CMyDlgOneApp::SetupUiAdvancedOptions()
{
//
// Prof-UIS command manager profile
//
VERIFY(
g_CmdManager->ProfileSetup(
__PROF_UIS_PROJECT_CMD_PROFILE_NAME
)
);

//
// General UI look
//
g_PaintManager.InstallPaintManager(
RUNTIME_CLASS( CExtPaintManagerXP )
//RUNTIME_CLASS( CExtPaintManager )
//RUNTIME_CLASS( CExtPaintManagerXP )
//RUNTIME_CLASS( CExtPaintManagerOffice2003 )
//RUNTIME_CLASS( CExtPaintManagerOffice2003NoThemes )
//RUNTIME_CLASS( CExtPaintManagerStudio2005 )
//RUNTIME_CLASS( CExtPaintManagerNativeXP )
//RUNTIME_CLASS( CExtPaintManagerOffice2007_R1 )
//RUNTIME_CLASS( CExtPaintManagerOffice2007_R2_LunaBlue )
//RUNTIME_CLASS( CExtPaintManagerOffice2007_R2_Obsidian )
);

//
// Popup menu option: Display menu shadows
//
CExtPopupMenuWnd::g_bMenuWithShadows = false;

//
// Popup menu option: Display menu cool tips
//
CExtPopupMenuWnd::g_bMenuShowCoolTips = false;

//
// Popup menu option: Initially hide rarely used items (RUI)
//
CExtPopupMenuWnd::g_bMenuExpanding = false;

//
// Popup menu option: Display RUI in different style
//

CExtPopupMenuWnd::g_bMenuHighlightRarely = true;

//
// Popup menu option: Animate when expanding RUI (like Office XP)
//
CExtPopupMenuWnd::g_bMenuExpandAnimation = false;

//
// Popup menu option: Align to desktop work area (false - to screen area)
//
CExtPopupMenuWnd::g_bUseDesktopWorkArea = false;

//
// Popup menu option: Popup menu animation effect (when displaying)
CExtPopupMenuWnd::g_DefAnimationType =
CExtPopupMenuWnd::__AT_FADE;
//$$__PROFUISAPPWIZ_KEY_MENU_ANIM_DISPMS$$

}




// CMyDlgOneApp initialization

BOOL CMyDlgOneApp::InitInstance()
{
//
// Prof-UIS advanced options
//
SetupUiAdvancedOptions();

CWinApp::InitInstance();


SetRegistryKey( _T("MyDlgOne") ); //$$__PROFUISAPPWIZ_KEY_APP_REG_KEY$$
ASSERT( m_pszRegistryKey != NULL );

if( m_pszProfileName != NULL )
free( (void*)m_pszProfileName );
m_pszProfileName =
_tcsdup( _T("MyDlgOne") ); //$$__PROFUISAPPWIZ_KEY_APP_PROFILE_NAME$$
ASSERT( m_pszProfileName != NULL );



CMyDlgOneDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application’s message pump.
return FALSE;
}


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// MyDlgOneDlg.h : header file
//

#pragma once

//
//-1
//0

#define __PROF_UIS_PROJECT_DLG_PERSIST_REG_KEY _T("CMyDlgOneApp-resizable-dialog-positions")

#define __PROF_UIS_PROJECT_DLG_PERSIST_REG_KEY _T("CMyDlgOneApp-resizable-dialog-positions")

class CMyPageDlgOne;
class CMyPageDlgTwo;

// CMyDlgOneDlg dialog
// class CMyDlgOneDlg : public CDialog
class CMyDlgOneDlg : public CExtNCW < CExtResizableDialog >
{
// Construction
public:
CMyDlgOneDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
enum { IDD = IDD_MYDLGONE_DIALOG };

CExtButton m_BtnOK;
CExtButton m_BtnCancel;
CExtButton m_BtnButton1;
CExtButton m_BtnButton2;
CExtEdit m_Edit;

CMyPageDlgOne *m_pMyPageDlgOne;
CMyPageDlgTwo *m_pMyPageDlgTwo;

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

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
public:
afx_msg void OnBnClickedButton2();
};

//*********************************************************************************

class CMyPageDlgOne : public CPageBase
{
public:
enum { IDD = IDD_PAGEONE };
CExtButton m_BtnOne;
CExtButton m_BtnTwo;

public:
CMyPageDlgOne ( CWnd *pParent = NULL );

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();

DECLARE_MESSAGE_MAP()
};

//*********************************************************************************

class CMyPageDlgTwo : public CPageBase
{
public:
enum { IDD = IDD_PAGETWO };
CExtButton m_BtnC;
CExtButton m_BtnD;
CExtEdit m_Edit;

public:
CMyPageDlgTwo ( CWnd *pParent = NULL );

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();

DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedPagedlgtwobutton();
};


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// MyDlgOneDlg.cpp : implementation file
//

#include "stdafx.h"
#include "PageBase.h"
#include "MyDlgOne.h"
#include "MyDlgOneDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CMyDlgOneDlg dialog
CMyDlgOneDlg::CMyDlgOneDlg(CWnd* pParent /*=NULL*/)
: CExtNCW < CExtResizableDialog >(CMyDlgOneDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMyDlgOneDlg::DoDataExchange(CDataExchange* pDX)
{
CExtNCW < CExtResizableDialog >::DoDataExchange(pDX);

DDX_Control(pDX, IDOK, m_BtnOK);
DDX_Control(pDX, IDCANCEL, m_BtnCancel);
DDX_Control(pDX, IDC_BUTTON1, m_BtnButton1);
DDX_Control(pDX, IDC_BUTTON2, m_BtnButton2);
DDX_Control(pDX, IDC_EDIT1, m_Edit);
}

BEGIN_MESSAGE_MAP(CMyDlgOneDlg, CExtResizableDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, &CMyDlgOneDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CMyDlgOneDlg::OnBnClickedButton2)
END_MESSAGE_MAP()

// CMyDlgOneDlg message handlers
BOOL CMyDlgOneDlg::OnInitDialog()
{
CExtNCW < CExtResizableDialog >::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application’s main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

//
// Setup anchors for resizable dialog controls
//
CExtNCW < CExtResizableDialog >::AddAnchor( IDOK, __RDA_RB );
CExtNCW < CExtResizableDialog >::AddAnchor( IDCANCEL, __RDA_RB );
CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON1, __RDA_RB );
CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON2, __RDA_RB );
CExtNCW < CExtResizableDialog >::AddAnchor( IDC_EDIT1, __RDA_LT, __RDA_LB );
CExtNCW < CExtResizableDialog >::AddAnchor( IDC_STATIC_PAGES_RECT, __RDA_LT, __RDA_RB );

CRect rcPages;
::GetWindowRect(::GetDlgItem(m_hWnd,IDC_STATIC_PAGES_RECT),&rcPages);
ScreenToClient(&rcPages);
//
m_pMyPageDlgOne = new CMyPageDlgOne;
ASSERT(m_pMyPageDlgOne != NULL);
m_pMyPageDlgOne->Create(CMyPageDlgOne::IDD,this);
m_pMyPageDlgOne->MoveWindow(&rcPages);

m_pMyPageDlgTwo = new CMyPageDlgTwo;
ASSERT(m_pMyPageDlgTwo != NULL);
m_pMyPageDlgTwo->Create(CMyPageDlgTwo::IDD,this);
m_pMyPageDlgTwo->MoveWindow(&rcPages);

::ShowWindow(m_pMyPageDlgOne->GetSafeHwnd(),SW_SHOW);

//!__PROFUISAPPWIZ_KEY_PERS_POS_DLG
//
// Uncomment these lines to enable dialog position
// saving/restoring in registry
//
//VERBOSE
//CExtNCW < CExtResizableDialog >::EnableSaveRestore(
// __PROF_UIS_PROJECT_DLG_PERSIST_REG_KEY,
// _T("CMyDlgOneDlg-Saved-Position")
// );

//!__PROFUISAPPWIZ_KEY_PERS_POS_DLG
//
// Show size gripper
//
//VERBOSE
CExtNCW < CExtResizableDialog >::ShowSizeGrip( TRUE );

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

//
//-1
//0

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CMyDlgOneDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CExtNCW < CExtResizableDialog >::OnPaint();
}
}

// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlgOneDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}

//*************************************************************************************

CMyPageDlgOne::CMyPageDlgOne ( CWnd *pParent )
: CPageBase(CMyPageDlgOne::IDD, pParent)
{
}

void CMyPageDlgOne::DoDataExchange(CDataExchange* pDX)
{
CPageBase::DoDataExchange(pDX);
DDX_Control(pDX,IDC_BUTTON_A,m_BtnOne);
DDX_Control(pDX,IDC_BUTTON_B,m_BtnTwo);
}

BEGIN_MESSAGE_MAP(CMyPageDlgOne, CPageBase)
//{{AFX_MSG_MAP(CMyPageDlgOne)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CMyPageDlgOne::OnInitDialog()
{
CPageBase::OnInitDialog();

AddAnchor( IDC_BUTTON_A, __RDA_RT );
AddAnchor( IDC_BUTTON_B, __RDA_RB );

return TRUE;
}

//*************************************************************************************

CMyPageDlgTwo::CMyPageDlgTwo ( CWnd *pParent )
: CPageBase(CMyPageDlgTwo::IDD, pParent)
{
}

void CMyPageDlgTwo::DoDataExchange(CDataExchange* pDX)
{
CPageBase::DoDataExchange(pDX);
DDX_Control(pDX,IDC_BUTTON_C,m_BtnC);
DDX_Control(pDX,IDC_BUTTON_D,m_BtnD);
DDX_Control(pDX,IDC_EDIT_PAGETWO,m_Edit);
}

BEGIN_MESSAGE_MAP(CMyPageDlgTwo, CPageBase)
//{{AFX_MSG_MAP(CMyPageDlgTwo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CMyPageDlgTwo::OnInitDialog()
{
CPageBase::OnInitDialog();

AddAnchor( IDC_EDIT_PAGETWO, __RDA_LT, __RDA_RT );
AddAnchor( IDC_BUTTON_C, __RDA_LB );
AddAnchor( IDC_BUTTON_D, __RDA_RB );

return TRUE;
}

void CMyDlgOneDlg::OnBnClickedButton1()
{
if( m_pMyPageDlgTwo != NULL )
::ShowWindow(m_pMyPageDlgTwo->GetSafeHwnd(),SW_HIDE);
if( m_pMyPageDlgOne != NULL )
::ShowWindow(m_pMyPageDlgOne->GetSafeHwnd(),SW_SHOW);
}

void CMyDlgOneDlg::OnBnClickedButton2()
{
if( m_pMyPageDlgOne != NULL )
::ShowWindow(m_pMyPageDlgOne->GetSafeHwnd(),SW_HIDE);
if( m_pMyPageDlgTwo != NULL )
::ShowWindow(m_pMyPageDlgTwo->GetSafeHwnd(),SW_SHOW);
}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#include ""res\\MyDlgOne.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\MyDlgOne.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_MYDLGONE_DIALOG DIALOGEX 0, 0, 358, 230
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW
CAPTION "MyDlgOne"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,301,207,50,16
PUSHBUTTON "Cancel",IDCANCEL,245,207,50,16
PUSHBUTTON "Button1",IDC_BUTTON1,105,207,66,16
PUSHBUTTON "Button2",IDC_BUTTON2,175,207,64,16
EDITTEXT IDC_EDIT1,7,7,94,216,ES_MULTILINE | ES_AUTOHSCROLL
GROUPBOX "",IDC_STATIC_PAGES_RECT,106,7,245,195,NOT WS_VISIBLE
END

IDD_PAGEONE DIALOGEX 0, 0, 241, 150
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Button_A",IDC_BUTTON_A,171,0,70,16
PUSHBUTTON "Button_B",IDC_BUTTON_B,170,134,71,16
END

IDD_PAGETWO DIALOGEX 0, 0, 264, 159
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Button_C",IDC_BUTTON_C,6,78,83,14
PUSHBUTTON "Button_D",IDC_BUTTON_D,180,142,82,14
EDITTEXT IDC_EDIT_PAGETWO,6,59,251,15,ES_AUTOHSCROLL
END


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "4094e4"
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "TODO: <File description>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "MyDlgOne.exe"
VALUE "LegalCopyright", "TODO: (c) <Company name>. All rights reserved."
VALUE "OriginalFilename", "MyDlgOne.exe"
VALUE "ProductName", "TODO: <Product name>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_MYDLGONE_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 351
TOPMARGIN, 7
BOTTOMMARGIN, 223
END
END
#endif // APSTUDIO_INVOKED

#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\MyDlgOne.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif

/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PageBase.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CPageBase dialog

class CPageBase : public CExtResizableDialog
{
// Construction
public:
CPageBase(UINT _IDD, CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CPageBase)
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPageBase)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy();
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CPageBase)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// PageBase.cpp : implementation file
//

#include "stdafx.h"
#include "PageBase.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPageBase dialog
CPageBase::CPageBase(UINT _IDD, CWnd* pParent /*=NULL*/)
: CExtResizableDialog(_IDD, pParent)
{
//{{AFX_DATA_INIT(CPageBase)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}

void CPageBase::DoDataExchange(CDataExchange* pDX)
{
CExtResizableDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPageBase)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPageBase, CExtResizableDialog)
//{{AFX_MSG_MAP(CPageBase)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageBase message handlers

BOOL CPageBase::OnInitDialog()
{
CExtResizableDialog::OnInitDialog();
ShowSizeGrip( FALSE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

//////////////////////////////////////////////////////////////////////////

void CPageBase::PostNcDestroy()
{
CExtResizableDialog::PostNcDestroy();
delete this;
}
//////////////////////////////////////////////////////////////////////////

Bill Harris Jun 29, 2007 - 9:01 AM

That fixed it!!

Thanks Suhai - Very much appreciated!

Bill Harris Jun 28, 2007 - 7:35 PM

I just made the changes as you suggested. The ASSERT() is still triggered - the same as before.
I’ve tried moving the statements around a bit - but I have not yet come up with the magical solution.

I appreciate your help and any more help you can give to get me through this.

Suhai Gyorgy Jun 29, 2007 - 2:35 AM

I’ve made a sample application based on your code and that helped me find out the problem:

AddAnchor uses its first parameter as an ID, trying to find the control (child window) associated with that ID. But creating the child windows with the code m_pMyPageDlgOne->Create(CMyPageDlgOne::IDD,this); doesn’t set the child window’s ID to CMyPageDlgOne::IDD, as in this call it is the ID of the dialog template, based on which the window is created. So you have to set the ID manually. But it is better program design to use different IDs to dialog templates and different ones for control objects (in case at any point in the development you’d like to use 2 CMyPageDlgOne objects).

So I made 2 new IDs for the child window controls: IDC_FIRST_PAGE and IDC_SECOND_PAGE and I set these IDs manually with SetDlgCtrlID.

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
 
	CRect rcPages;
	::GetWindowRect(::GetDlgItem(m_hWnd,IDC_STATIC_PAGES_RECT),&rcPages);
	ScreenToClient(&rcPages);
	//
	m_pMyPageDlgOne = new CMyPageDlgOne;
	ASSERT(m_pMyPageDlgOne != NULL);
	m_pMyPageDlgOne->Create(CMyPageDlgOne::IDD,this);
	m_pMyPageDlgOne->SetDlgCtrlID(IDC_FIRST_PAGE);
	m_pMyPageDlgOne->MoveWindow(&rcPages);
 
	m_pMyPageDlgTwo = new CMyPageDlgTwo;
	ASSERT(m_pMyPageDlgTwo != NULL);
	m_pMyPageDlgTwo->Create(CMyPageDlgTwo::IDD,this);
	m_pMyPageDlgTwo->SetDlgCtrlID(IDC_SECOND_PAGE);
	m_pMyPageDlgTwo->MoveWindow(&rcPages);
 
	::ShowWindow(m_pMyPageDlgOne->GetSafeHwnd(),SW_SHOW);
 
	CExtNCW < CExtResizableDialog >::AddAnchor( IDOK, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDCANCEL, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON1, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON2, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_FIRST_PAGE, __RDA_LT, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_SECOND_PAGE, __RDA_LT, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_STATIC_PAGES_RECT, __RDA_LT, __RDA_RB );
 
	ShowSizeGrip(TRUE);

Bill Harris Jun 28, 2007 - 8:31 AM

I tried adding the two lines you suggested and showing borders.
This caused an ASSERT( ) to be triggered in AddAnchor() - due to hWnd being NULL or !::IsWindow(hWnd).
When I take your suggested lines out, but leave the borders turned on, I can see that indeed the
inner dialogs are not resizing.

Any new suggestions?

Suhai Gyorgy Jun 28, 2007 - 12:57 PM

Yes, true, the Create method for the dialogs is not called at that point yet.
So all you need to do is place the AddAnchor calls after the Create method. But to keep all AddAnchors together, this code would better:

BOOL CMyDlgOneDlg::OnInitDialog()
{
	CExtNCW < CExtResizableDialog >::OnInitDialog();
 
	// Set the icon for this dialog. The framework does this automatically
	// when the application’s main window is not a dialog
	SetIcon(m_hIcon, TRUE); // Set big icon
	SetIcon(m_hIcon, FALSE); // Set small icon
 
	CRect rcPages;
	::GetWindowRect(::GetDlgItem(m_hWnd,IDC_STATIC_PAGES_RECT),&rcPages);
	ScreenToClient(&rcPages);
	//
	m_pMyPageDlgOne = new CMyPageDlgOne;
	ASSERT(m_pMyPageDlgOne != NULL);
	m_pMyPageDlgOne->Create(CMyPageDlgOne::IDD,this);
	m_pMyPageDlgOne->MoveWindow(&rcPages);
 
	m_pMyPageDlgTwo = new CMyPageDlgTwo;
	ASSERT(m_pMyPageDlgTwo != NULL);
	m_pMyPageDlgTwo->Create(CMyPageDlgTwo::IDD,this);
	m_pMyPageDlgTwo->MoveWindow(&rcPages);
 
	::ShowWindow(m_pMyPageDlgOne->GetSafeHwnd(),SW_SHOW);
 
	//
	// Setup anchors for resizable dialog controls
	//
	CExtNCW < CExtResizableDialog >::AddAnchor( IDOK, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDCANCEL, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON1, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_BUTTON2, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_EDIT1, __RDA_LT, __RDA_LB );
	CExtNCW < CExtResizableDialog >::AddAnchor( IDC_STATIC_PAGES_RECT, __RDA_LT, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( CMyPageDlgOne::IDD, __RDA_LT, __RDA_RB );
	CExtNCW < CExtResizableDialog >::AddAnchor( CMyPageDlgTwo::IDD, __RDA_LT, __RDA_RB );
 
	//!__PROFUISAPPWIZ_KEY_PERS_POS_DLG
	//
	...
}

Technical Support Jun 27, 2007 - 12:05 PM

You should anchor the controls on your dialog manually so that their size and layout can proportionally change when the dialog is resized. Please read about this in the article below:

How to create a window containing auto-resizable controls?



Bill Harris Jun 27, 2007 - 8:14 PM

I have read it. I have also anchored all of my controls. When you say "manually" - do you mean
by specifying values like CPoint(5,95) and so on? I have tried this by going back and explicitly
setting the values by uing anchor calls like the following:

AddAnchor( IDC_BUTTON_D, CPoint(90,90), CPoint(100,100) );

But it didn’t have any effect. Can you suggest something else that I might be doing wrong -
or did I misunderstand what you meant by the word "manually"?

Suhai Gyorgy Jun 28, 2007 - 3:55 AM

The problem is that your inner dialogs are not resizing. Even though you added anchoring to IDC_STATIC_PAGES_RECT, that won’t resize your dialogs as well. And since your inner dialogs are not resizing, IDC_BUTTON_D and the other buttons like that won’t get moving either.

I’m not sure if it works, but I’d try adding the lines:
CExtNCW < CExtResizableDialog >::AddAnchor( CMyPageDlgOne::IDD, __RDA_LT, __RDA_RB );
CExtNCW < CExtResizableDialog >::AddAnchor( CMyPageDlgTwo::IDD, __RDA_LT, __RDA_RB );

just below
CExtNCW < CExtResizableDialog >::AddAnchor( IDC_STATIC_PAGES_RECT, __RDA_LT, __RDA_RB );

And while testing, you might want to show borders around the inner dialogs, just to see if they are resizing or not.