PropertyPage disappears mysteriously

Posted on 2004-03-25
Last Modified: 2013-11-20
I have a PropertySheet with 5 PropertyPages in my SDI-app. If I just do the following:
1) Open the PropertySheet.
2) Select PropertyPage 4.
3) Close the PropertySheet.
and repeating this about 30 to 40 times then the PropertyPage 4 disappears when trying to select that page.

* The other pages still work as usual. The order of the pages does not matter, i.e. if I put the page as number 5 it still disappears.
* The page only contains some buttons and a lot of checkboxes (2 Group Boxes, 4 Push buttons, 69 Check Boxes).
* If I reduce the number of Check Boxes to 50 then it seems OK, but 51 Check Boxes gives the same error.
* I do not get any warnings about memory leaks and the CPU and memory usage is the same.
* I am using VC++6 and MFC.

I have put a trace on the WindowProc(UINT message, WPARAM wParam, LPARAM lParam) function for the PropertyPage.
The following messages are received when everything is OK:
... and a lot more.

When it fails the following messages are received:

Does anybody have any ideas about what is causing this problem or have any suggestions about how to find out more about what is causing this?

This is very annoying and confusing and I am totally stuck here so any kind of help/suggestions would be very much appreciated. Thanks!

Question by:P1R
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 16
  • 13
  • 3
  • +1

Expert Comment

ID: 10676403
Operating system?
There's a resource size and control number limit you may have reached.
Do you properly destroy your resources and objects?

Btw, it's probably not a memory leak but a resource leak. And there are much more possibilities for either kind of leaks than Visual Studio gives warning for.

As a private note (as a would-be user of your property page) is that a page with 69 check boxes is a nightmare, a sure sign of a bad user interface design.
LVL 44

Expert Comment

ID: 10676508
I have the same feeling as joghurt - resources not being freed up.  75 controls should not be hitting a limit.
Are you doing anything special with the controls on this page (owner draw for example, creating dynamically in code).

Author Comment

ID: 10676531
* I have only seen the problem in WinXP.
* The CPropertyPage objects are declared as members of the derived CPropertySheet class and should thus be destroyed by the default destructor.

I am aware of that a GUI with many check boxes is not very nice, but in this case there are a lot of features that could be selected and I am not sure if it would be more intuitive if I split them into additional PropertyPages instead. (Suggestions?)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 10676568
I am not doing anything special with the controls. Originally there are control variables (DDX_Check) for each check box, but I have tried to comment out that part but with the same result.
LVL 44

Expert Comment

ID: 10676579
Have you used the system monitor to track resource usage as you perform this action?


Check list box (or a few with common items grouped together)
Combo with predefined 'styles' that set/unset / hide/show  numbers of checkbox's at one go.

Author Comment

ID: 10676655
I have used the system monitor but there is no difference when the PropertyPage is shown or when it fails. The memory and CPU usage is almost constant during the entire test.
LVL 44

Expert Comment

ID: 10676671
resource handles not system memory

Author Comment

ID: 10676791
Do you mean the number of threads and processes? Those are constant during the test.

Expert Comment

ID: 10677360
NOOO. Resource and GDI handles such are window handles, bitmap handles, brush handles, etc. And the size of the resource and the GDI heap.

Most people know about the 64k (in fact, 60k) GDI heap limit on Win9x because internally they use the old 16-bit subsystem.
However, most people think that it's all solved in NT/2k/XP because they have real 32-bit system so you have 2 gigabytes for resources.
Not quite. In fact you have only about 2 megabytes that can be easily exhausted if you leak resources in numbers and use XP's fancy stuff.
LVL 44

Expert Comment

ID: 10677365
The is a utility - performance monitor - There you can select from a horrendous array of things to monitor.  Try selecting handles (or others) and see what happens as you switch to/from this tab.

Author Comment

ID: 10678241
OK now I have found the performance monitor (thanks). I have selected my process and handles and threads. Both handles and threads are rather constant during the test.

I have also tried to split the property page into two pages, but the result is still the same.
LVL 44

Expert Comment

ID: 10678354
can you post the code of this page4 here?  (not just a little bit of the page, the whole lot).

Author Comment

ID: 10685089
OK, here it comes. First the .h file and then the .cpp file.


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

// CResultsViewSelectionPage dialog

class CResultsViewSelectionPage : public CPropertyPage
friend class CResultsSheet;


// Construction
      void setSelectedObjectParams(__int64 params);
      void setSelectedFieldParams(__int64 params);

// Dialog Data
      BOOL      fieldAreaOfRoi;
      BOOL      fieldAreaInRoi;
      BOOL      fieldAreaFraction;
      BOOL      fieldArea;
      BOOL      fieldPerimeter;
      BOOL      fieldFeretX;
      BOOL      fieldFeretY;
      BOOL      fieldFeretMinDiameter;
      BOOL      fieldFeretMinAngle;
      BOOL      fieldFeretMaxDiameter;
      BOOL      fieldFeretMaxAngle;
      BOOL      fieldFeretMeanDiameter;
      BOOL      fieldFeretElongation;
      BOOL      fieldConvexPerimeter;
      BOOL      fieldCompactness;
      BOOL      fieldNumberOfHoles;
      BOOL      fieldRoughness;
      BOOL      fieldLength;
      BOOL      fieldBreadth;
      BOOL      fieldElongation;
      BOOL      fieldSumPixel;
      BOOL      fieldMinPixel;
      BOOL      fieldMaxPixel;
      BOOL      fieldMeanPixel;
      BOOL      fieldSigmaPixel;
      BOOL      fieldSumPixelSquared;
      BOOL      fieldCenterOfGravityX;
      BOOL      fieldCenterOfGravityY;
      BOOL      fieldCount;
      BOOL      fieldObjectCount;
      BOOL      fieldFeretMinVolume;
      BOOL      fieldFeretMaxVolume;
      BOOL      fieldFeretMeanVolume;
      BOOL      fieldInnerDiameter;
      BOOL      fieldInnerVolume;
      BOOL      fieldCorrespondingSphere;
      BOOL      fieldCorrespondingDiameter;
      BOOL      objectArea;
      BOOL      objectPerimeter;
      BOOL      objectFeretX;
      BOOL      objectFeretY;
      BOOL      objectFeretMinDiameter;
      BOOL      objectFeretMinAngle;
      BOOL      objectFeretMaxDiameter;
      BOOL      objectFeretMaxAngle;
      BOOL      objectFeretMeanDiameter;
      BOOL      objectFeretElongation;
      BOOL      objectConvexPerimeter;
      BOOL      objectCompactness;
      BOOL      objectNumberOfHoles;
      BOOL      objectRoughness;
      BOOL      objectLength;
      BOOL      objectBreadth;
      BOOL      objectElongation;
      BOOL      objectSumPixel;
      BOOL      objectMinPixel;
      BOOL      objectMaxPixel;
      BOOL      objectMeanPixel;
      BOOL      objectSigmaPixel;
      BOOL      objectSumPixelSquared;
      BOOL      objectCenterOfGravityX;
      BOOL      objectCenterOfGravityY;
      BOOL      objectFeretMinVolume;
      BOOL      objectFeretMaxVolume;
      BOOL      objectFeretMeanVolume;
      BOOL      objectInnerDiameter;
      BOOL      objectInnerVolume;
      BOOL      objectCorrespondingSphere;
      BOOL      objectCorrespondingDiameter;

// Overrides
      // ClassWizard generate virtual function overrides
      virtual BOOL OnKillActive();
      virtual BOOL OnSetActive();
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
      CResultViewSelection* selection;

      void setData();
      void getData();

      // Generated message map functions
      afx_msg void OnSelectAllFieldParams();
      afx_msg void OnSelectAllObjectParams();
      afx_msg void OnSelectNoFieldParams();
      afx_msg void OnSelectNoObjectParams();


// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RESULTSVIEWSELECTIONPAGE_H__CDAC1C53_04CD_11D1_99F4_0020AF563EB1__INCLUDED_)

// ResultsViewSelectionPage.cpp : implementation file

#include "stdafx.h"
#include "ImageAnalysis.h"
#include "ResultsViewSelectionPage.h"

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

// CResultsViewSelectionPage property page

IMPLEMENT_DYNCREATE(CResultsViewSelectionPage, CPropertyPage)

CResultsViewSelectionPage::CResultsViewSelectionPage() : CPropertyPage(CResultsViewSelectionPage::IDD)
      fieldAreaOfRoi = FALSE;
      fieldAreaInRoi = FALSE;
      fieldAreaFraction = FALSE;
      fieldArea = FALSE;
      fieldPerimeter = FALSE;
      fieldFeretX = FALSE;
      fieldFeretY = FALSE;
      fieldFeretMinDiameter = FALSE;
      fieldFeretMinAngle = FALSE;
      fieldFeretMaxDiameter = FALSE;
      fieldFeretMaxAngle = FALSE;
      fieldFeretMeanDiameter = FALSE;
      fieldFeretElongation = FALSE;
      fieldConvexPerimeter = FALSE;
      fieldCompactness = FALSE;
      fieldNumberOfHoles = FALSE;
      fieldRoughness = FALSE;
      fieldLength = FALSE;
      fieldBreadth = FALSE;
      fieldElongation = FALSE;
      fieldSumPixel = FALSE;
      fieldMinPixel = FALSE;
      fieldMaxPixel = FALSE;
      fieldMeanPixel = FALSE;
      fieldSigmaPixel = FALSE;
      fieldSumPixelSquared = FALSE;
      fieldCenterOfGravityX = FALSE;
      fieldCenterOfGravityY = FALSE;
      fieldCount = FALSE;
      fieldObjectCount = FALSE;
      fieldFeretMinVolume = FALSE;
      fieldFeretMaxVolume = FALSE;
      fieldFeretMeanVolume = FALSE;
      fieldInnerDiameter = FALSE;
      fieldInnerVolume = FALSE;
      fieldCorrespondingSphere = FALSE;
      fieldCorrespondingDiameter = FALSE;
      objectArea = FALSE;
      objectPerimeter = FALSE;
      objectFeretX = FALSE;
      objectFeretY = FALSE;
      objectFeretMinDiameter = FALSE;
      objectFeretMinAngle = FALSE;
      objectFeretMaxDiameter = FALSE;
      objectFeretMaxAngle = FALSE;
      objectFeretMeanDiameter = FALSE;
      objectFeretElongation = FALSE;
      objectConvexPerimeter = FALSE;
      objectCompactness = FALSE;
      objectNumberOfHoles = FALSE;
      objectRoughness = FALSE;
      objectLength = FALSE;
      objectBreadth = FALSE;
      objectElongation = FALSE;
      objectSumPixel = FALSE;
      objectMinPixel = FALSE;
      objectMaxPixel = FALSE;
      objectMeanPixel = FALSE;
      objectSigmaPixel = FALSE;
      objectSumPixelSquared = FALSE;
      objectCenterOfGravityX = FALSE;
      objectCenterOfGravityY = FALSE;
      objectFeretMinVolume = FALSE;
      objectFeretMaxVolume = FALSE;
      objectFeretMeanVolume = FALSE;
      objectInnerDiameter = FALSE;
      objectInnerVolume = FALSE;
      objectCorrespondingSphere = FALSE;
      objectCorrespondingDiameter = FALSE;

      m_psp.dwFlags &= ~(PSP_HASHELP);


void CResultsViewSelectionPage::DoDataExchange(CDataExchange* pDX)
      DDX_Check(pDX, IDC_F_AREA_OF_ROI, fieldAreaOfRoi);
      DDX_Check(pDX, IDC_F_AREA_IN_ROI, fieldAreaInRoi);
      DDX_Check(pDX, IDC_F_AREA_FRACTION, fieldAreaFraction);
      DDX_Check(pDX, IDC_F_AREA, fieldArea);
      DDX_Check(pDX, IDC_F_PERIMETER, fieldPerimeter);
      DDX_Check(pDX, IDC_F_FERET_X, fieldFeretX);
      DDX_Check(pDX, IDC_F_FERET_Y, fieldFeretY);
      DDX_Check(pDX, IDC_F_FERET_MIN_DIAMETER, fieldFeretMinDiameter);
      DDX_Check(pDX, IDC_F_FERET_MIN_ANGLE, fieldFeretMinAngle);
      DDX_Check(pDX, IDC_F_FERET_MAX_DIAMETER, fieldFeretMaxDiameter);
      DDX_Check(pDX, IDC_F_FERET_MAX_ANGLE, fieldFeretMaxAngle);
      DDX_Check(pDX, IDC_F_FERET_MEAN_DIAMETER, fieldFeretMeanDiameter);
      DDX_Check(pDX, IDC_F_FERET_ELONGATION, fieldFeretElongation);
      DDX_Check(pDX, IDC_F_CONVEX_PERIMETER, fieldConvexPerimeter);
      DDX_Check(pDX, IDC_F_COMPACTNESS, fieldCompactness);
      DDX_Check(pDX, IDC_F_NUMBER_OF_HOLES, fieldNumberOfHoles);
      DDX_Check(pDX, IDC_F_ROUGHNESS, fieldRoughness);
      DDX_Check(pDX, IDC_F_LENGTH, fieldLength);
      DDX_Check(pDX, IDC_F_BREADTH, fieldBreadth);
      DDX_Check(pDX, IDC_F_ELONGATION, fieldElongation);
      DDX_Check(pDX, IDC_F_SUM_PIXEL, fieldSumPixel);
      DDX_Check(pDX, IDC_F_MIN_PIXEL, fieldMinPixel);
      DDX_Check(pDX, IDC_F_MAX_PIXEL, fieldMaxPixel);
      DDX_Check(pDX, IDC_F_MEAN_PIXEL, fieldMeanPixel);
      DDX_Check(pDX, IDC_F_SIGMA_PIXEL, fieldSigmaPixel);
      DDX_Check(pDX, IDC_F_SUM_PIXEL_SQUARED, fieldSumPixelSquared);
      DDX_Check(pDX, IDC_F_COG_X, fieldCenterOfGravityX);
      DDX_Check(pDX, IDC_F_COG_Y, fieldCenterOfGravityY);
      DDX_Check(pDX, IDC_F_COUNT, fieldCount);
      DDX_Check(pDX, IDC_F_OBJECT_COUNT, fieldObjectCount);
      DDX_Check(pDX, IDC_F_FERET_MIN_VOLUME, fieldFeretMinVolume);
      DDX_Check(pDX, IDC_F_FERET_MAX_VOLUME, fieldFeretMaxVolume);
      DDX_Check(pDX, IDC_F_FERET_MEAN_VOLUME, fieldFeretMeanVolume);
      DDX_Check(pDX, IDC_F_INNER_DIAMETER, fieldInnerDiameter);
      DDX_Check(pDX, IDC_F_INNER_VOLUME, fieldInnerVolume);
      DDX_Check(pDX, IDC_F_CORRESPONDING_SPHERE, fieldCorrespondingSphere);
      DDX_Check(pDX, IDC_F_CORRESPONDING_DIAMETER, fieldCorrespondingDiameter);
      DDX_Check(pDX, IDC_O_AREA, objectArea);
      DDX_Check(pDX, IDC_O_PERIMETER, objectPerimeter);
      DDX_Check(pDX, IDC_O_FERET_X, objectFeretX);
      DDX_Check(pDX, IDC_O_FERET_Y, objectFeretY);
      DDX_Check(pDX, IDC_O_FERET_MIN_DIAMETER, objectFeretMinDiameter);
      DDX_Check(pDX, IDC_O_FERET_MIN_ANGLE, objectFeretMinAngle);
      DDX_Check(pDX, IDC_O_FERET_MAX_DIAMETER, objectFeretMaxDiameter);
      DDX_Check(pDX, IDC_O_FERET_MAX_ANGLE, objectFeretMaxAngle);
      DDX_Check(pDX, IDC_O_FERET_MEAN_DIAMETER, objectFeretMeanDiameter);
      DDX_Check(pDX, IDC_O_FERET_ELONGATION, objectFeretElongation);
      DDX_Check(pDX, IDC_O_CONVEX_PERIMETER, objectConvexPerimeter);
      DDX_Check(pDX, IDC_O_COMPACTNESS, objectCompactness);
      DDX_Check(pDX, IDC_O_NUMBER_OF_HOLES, objectNumberOfHoles);
      DDX_Check(pDX, IDC_O_ROUGHNESS, objectRoughness);
      DDX_Check(pDX, IDC_O_LENGTH, objectLength);
      DDX_Check(pDX, IDC_O_BREADTH, objectBreadth);
      DDX_Check(pDX, IDC_O_ELONGATION, objectElongation);
      DDX_Check(pDX, IDC_O_SUM_PIXEL, objectSumPixel);
      DDX_Check(pDX, IDC_O_MIN_PIXEL, objectMinPixel);
      DDX_Check(pDX, IDC_O_MAX_PIXEL, objectMaxPixel);
      DDX_Check(pDX, IDC_O_MEAN_PIXEL, objectMeanPixel);
      DDX_Check(pDX, IDC_O_SIGMA_PIXEL, objectSigmaPixel);
      DDX_Check(pDX, IDC_O_SUM_PIXEL_SQUARED, objectSumPixelSquared);
      DDX_Check(pDX, IDC_O_COG_X, objectCenterOfGravityX);
      DDX_Check(pDX, IDC_O_COG_Y, objectCenterOfGravityY);
      DDX_Check(pDX, IDC_O_FERET_MIN_VOLUME, objectFeretMinVolume);
      DDX_Check(pDX, IDC_O_FERET_MAX_VOLUME, objectFeretMaxVolume);
      DDX_Check(pDX, IDC_O_FERET_MEAN_VOLUME, objectFeretMeanVolume);
      DDX_Check(pDX, IDC_O_INNER_DIAMETER, objectInnerDiameter);
      DDX_Check(pDX, IDC_O_INNER_VOLUME, objectInnerVolume);
      DDX_Check(pDX, IDC_O_CORRESPONDING_SPHERE, objectCorrespondingSphere);
      DDX_Check(pDX, IDC_O_CORRESPONDING_DIAMETER, objectCorrespondingDiameter);

BEGIN_MESSAGE_MAP(CResultsViewSelectionPage, CPropertyPage)

// CResultsViewSelectionPage message handlers

BOOL CResultsViewSelectionPage::OnKillActive()
      return CPropertyPage::OnKillActive();

BOOL CResultsViewSelectionPage::OnSetActive()
      return CPropertyPage::OnSetActive();

void CResultsViewSelectionPage::setData()
      ASSERT(selection != NULL);
      fieldCount = selection->fieldCount;
      fieldObjectCount = selection->fieldObjectCount;
      fieldAreaOfRoi = selection->fieldAreaOfRoi;
      fieldAreaInRoi = selection->fieldAreaInRoi;
      fieldAreaFraction = selection->fieldAreaFraction;
      fieldArea = selection->fieldArea;
      fieldPerimeter = selection->fieldPerimeter;
      fieldFeretX = selection->fieldFeretX;
      fieldFeretY = selection->fieldFeretY;
      fieldFeretMinDiameter = selection->fieldFeretMinDiameter;
      fieldFeretMinAngle = selection->fieldFeretMinAngle;
      fieldFeretMaxDiameter = selection->fieldFeretMaxDiameter;
      fieldFeretMaxAngle = selection->fieldFeretMaxAngle;
      fieldFeretMeanDiameter = selection->fieldFeretMeanDiameter;
      fieldFeretElongation = selection->fieldFeretElongation;
      fieldFeretMinVolume = selection->fieldFeretMinVolume;
      fieldFeretMaxVolume = selection->fieldFeretMaxVolume;
      fieldFeretMeanVolume = selection->fieldFeretMeanVolume;
      fieldConvexPerimeter = selection->fieldConvexPerimeter;
      fieldCompactness = selection->fieldCompactness;
      fieldNumberOfHoles = selection->fieldNumberOfHoles;
      fieldRoughness = selection->fieldRoughness;
      fieldLength = selection->fieldLength;
      fieldBreadth = selection->fieldBreadth;
      fieldElongation = selection->fieldElongation;
      fieldSumPixel = selection->fieldSumPixel;
      fieldMinPixel = selection->fieldMinPixel;
      fieldMaxPixel = selection->fieldMaxPixel;
      fieldMeanPixel = selection->fieldMeanPixel;
      fieldSigmaPixel = selection->fieldSigmaPixel;
      fieldSumPixelSquared = selection->fieldSumPixelSquared;
      fieldCenterOfGravityX = selection->fieldCenterOfGravityX;
      fieldCenterOfGravityY = selection->fieldCenterOfGravityY;
      fieldInnerDiameter = selection->fieldInnerDiameter;
      fieldInnerVolume = selection->fieldInnerVolume;
      fieldCorrespondingSphere = selection->fieldCorrespondingSphere;
      fieldCorrespondingDiameter = selection->fieldCorrespondingDiameter;
      // Object
      objectArea = selection->objectArea;
      objectPerimeter = selection->objectPerimeter;
      objectFeretX = selection->objectFeretX;
      objectFeretY = selection->objectFeretY;
      objectFeretMinDiameter = selection->objectFeretMinDiameter;
      objectFeretMinAngle = selection->objectFeretMinAngle;
      objectFeretMaxDiameter = selection->objectFeretMaxDiameter;
      objectFeretMaxAngle = selection->objectFeretMaxAngle;
      objectFeretMeanDiameter = selection->objectFeretMeanDiameter;
      objectFeretElongation = selection->objectFeretElongation;
      objectFeretMinVolume = selection->objectFeretMinVolume;
      objectFeretMaxVolume = selection->objectFeretMaxVolume;
      objectFeretMeanVolume = selection->objectFeretMeanVolume;
      objectConvexPerimeter = selection->objectConvexPerimeter;
      objectCompactness = selection->objectCompactness;
      objectNumberOfHoles = selection->objectNumberOfHoles;
      objectRoughness = selection->objectRoughness;
      objectLength = selection->objectLength;
      objectBreadth = selection->objectBreadth;
      objectElongation = selection->objectElongation;
      objectSumPixel = selection->objectSumPixel;
      objectMinPixel = selection->objectMinPixel;
      objectMaxPixel = selection->objectMaxPixel;
      objectMeanPixel = selection->objectMeanPixel;
      objectSigmaPixel = selection->objectSigmaPixel;
      objectSumPixelSquared = selection->objectSumPixelSquared;
      objectCenterOfGravityX = selection->objectCenterOfGravityX;
      objectCenterOfGravityY = selection->objectCenterOfGravityY;
      objectInnerDiameter = selection->objectInnerDiameter;
      objectInnerVolume = selection->objectInnerVolume;
      objectCorrespondingSphere = selection->objectCorrespondingSphere;
      objectCorrespondingDiameter = selection->objectCorrespondingDiameter;


void CResultsViewSelectionPage::getData()
      ASSERT(selection != NULL);


      selection->fieldCount = fieldCount;
      selection->fieldObjectCount = fieldObjectCount;
      selection->fieldAreaOfRoi = fieldAreaOfRoi;
      selection->fieldAreaInRoi = fieldAreaInRoi;
      selection->fieldAreaFraction = fieldAreaFraction;
      selection->fieldArea = fieldArea;
      selection->fieldPerimeter = fieldPerimeter;
      selection->fieldFeretX = fieldFeretX;
      selection->fieldFeretY = fieldFeretY;
      selection->fieldFeretMinDiameter = fieldFeretMinDiameter;
      selection->fieldFeretMinAngle = fieldFeretMinAngle;
      selection->fieldFeretMaxDiameter = fieldFeretMaxDiameter;
      selection->fieldFeretMaxAngle = fieldFeretMaxAngle;
      selection->fieldFeretMeanDiameter = fieldFeretMeanDiameter;
      selection->fieldFeretElongation = fieldFeretElongation;
      selection->fieldFeretMinVolume = fieldFeretMinVolume;
      selection->fieldFeretMaxVolume = fieldFeretMaxVolume;
      selection->fieldFeretMeanVolume = fieldFeretMeanVolume;
      selection->fieldConvexPerimeter = fieldConvexPerimeter;
      selection->fieldCompactness = fieldCompactness;
      selection->fieldNumberOfHoles = fieldNumberOfHoles;
      selection->fieldRoughness = fieldRoughness;
      selection->fieldLength = fieldLength;
      selection->fieldBreadth = fieldBreadth;
      selection->fieldElongation = fieldElongation;
      selection->fieldSumPixel = fieldSumPixel;
      selection->fieldMinPixel = fieldMinPixel;
      selection->fieldMaxPixel = fieldMaxPixel;
      selection->fieldMeanPixel = fieldMeanPixel;
      selection->fieldSigmaPixel = fieldSigmaPixel;
      selection->fieldSumPixelSquared = fieldSumPixelSquared;
      selection->fieldCenterOfGravityX = fieldCenterOfGravityX;
      selection->fieldCenterOfGravityY = fieldCenterOfGravityY;
      selection->fieldInnerDiameter = fieldInnerDiameter;
      selection->fieldInnerVolume = fieldInnerVolume;
      selection->fieldCorrespondingSphere = fieldCorrespondingSphere;
      selection->fieldCorrespondingDiameter = fieldCorrespondingDiameter;
      // Object
      selection->objectArea = objectArea;
      selection->objectPerimeter = objectPerimeter;
      selection->objectFeretX = objectFeretX;
      selection->objectFeretY = objectFeretY;
      selection->objectFeretMinDiameter = objectFeretMinDiameter;
      selection->objectFeretMinAngle = objectFeretMinAngle;
      selection->objectFeretMaxDiameter = objectFeretMaxDiameter;
      selection->objectFeretMaxAngle = objectFeretMaxAngle;
      selection->objectFeretMeanDiameter = objectFeretMeanDiameter;
      selection->objectFeretElongation = objectFeretElongation;
      selection->objectFeretMinVolume = objectFeretMinVolume;
      selection->objectFeretMaxVolume = objectFeretMaxVolume;
      selection->objectFeretMeanVolume = objectFeretMeanVolume;
      selection->objectConvexPerimeter = objectConvexPerimeter;
      selection->objectCompactness = objectCompactness;
      selection->objectNumberOfHoles = objectNumberOfHoles;
      selection->objectRoughness = objectRoughness;
      selection->objectLength = objectLength;
      selection->objectBreadth = objectBreadth;
      selection->objectElongation = objectElongation;
      selection->objectSumPixel = objectSumPixel;
      selection->objectMinPixel = objectMinPixel;
      selection->objectMaxPixel = objectMaxPixel;
      selection->objectMeanPixel = objectMeanPixel;
      selection->objectSigmaPixel = objectSigmaPixel;
      selection->objectSumPixelSquared = objectSumPixelSquared;
      selection->objectCenterOfGravityX = objectCenterOfGravityX;
      selection->objectCenterOfGravityY = objectCenterOfGravityY;
      selection->objectInnerDiameter = objectInnerDiameter;
      selection->objectInnerVolume = objectInnerVolume;
      selection->objectCorrespondingSphere = objectCorrespondingSphere;
      selection->objectCorrespondingDiameter = objectCorrespondingDiameter;

void CResultsViewSelectionPage::OnSelectAllFieldParams()
      ASSERT(selection != NULL);



void CResultsViewSelectionPage::OnSelectNoFieldParams()
      ASSERT(selection != NULL);



void CResultsViewSelectionPage::OnSelectAllObjectParams()
      ASSERT(selection != NULL);




void CResultsViewSelectionPage::OnSelectNoObjectParams()
      ASSERT(selection != NULL);



// -------------------------------------------------------------------------------------------------

void CResultsViewSelectionPage::setSelectedFieldParams(__int64 params)

void CResultsViewSelectionPage::setSelectedObjectParams(__int64 params)

LVL 44

Expert Comment

ID: 10685151
I don't see anything obvious in there apart from this selection pointer which is a protected var and never being set to any value.  What happens if you have
in your constructor?

Author Comment

ID: 10685293
The selection pointer is set in the constructor for the PropertySheet, see below.

CResultsSheet::CResultsSheet(CCategoryList* list, CFieldIdentityList* fieldIDList, CResultViewSelection* currentSelection, UINT nIDCaption, CSelectedStatisticValues& selectedStatisticValues, CDocument* pDoc, CWnd* pParentWnd, UINT iSelectPage)
      :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
      ASSERT(list != NULL);
      ASSERT(currentSelection != NULL);

      m_psh.dwFlags |= PSH_NOAPPLYNOW;
      m_psh.dwFlags &= ~(PSH_HASHELP);

      showPage.categoryList = list;
      showPage.fieldIdentityList = fieldIDList;
      showPage.selection = currentSelection;

      histogramPage.categoryList = list;
      histogramPage.selection = currentSelection;

      exportPage.categoryList = list;
      exportPage.fieldIdentityList = fieldIDList;
      exportPage.selection = currentSelection;

      viewSelectionPage.selection = currentSelection;

      statisticsSelectionPage.selection = &selectedStatisticValues;
LVL 44

Expert Comment

ID: 10685358
OK.  That looks in order.

I'm puzzled.  To me it looks like you are running out of resources somewhere but there doesn't seem to be any obvious allocation that should be giving this problem.  You are just opening and closing, not performing button presses as well so that the 4 event handlers are not actually being used.

Can you track the state of this 'currentSelection' as you open/close the property sheet?
LVL 44

Expert Comment

ID: 10685454
Two other simple things to try.

comment out all of the DoDataExchange routine.  (No interaction with the selection).  Does it still fail?
instead of
CResultsSheet dlg(...)

CResultsSheet* pDlg = new CResultsSheet();
delete pDlg;

or vice-versa to modify where the memory comes from and see if you still experience this behaviour.
LVL 44

Expert Comment

ID: 10685455
Two other simple things to try.

comment out all of the DoDataExchange routine.  (No interaction with the selection).  Does it still fail?
instead of
CResultsSheet dlg(...)

CResultsSheet* pDlg = new CResultsSheet();
delete pDlg;

or vice-versa to modify where the memory comes from and see if you still experience this behaviour.

Author Comment

ID: 10685532
I noticed those unused event handlers that I forgot to remove, but those were only used for tracing and were not there when the problem first occured.

I have tried to comment out the DoDataExchange routine, but it still fails.

I have also tried new/delete as you suggested, but with the same result.
LVL 44

Expert Comment

ID: 10685591
I am stumped.  Bug in OP system?
Do you have the latest service packs for VC and OP system installed?  Does it fail on another PC in the same way'
If I think of anything else I post another comment.

Author Comment

ID: 10685785
My OS is WinXP Home edition 2002 SP1 and I am using Visual C++ 6.0. The problem has occured on at least two other computers, both using WinXP. I am not sure which SP I have to VC++, but I will try to install SP5.

I have tried to strip all functions from any actions. Removed all other PropertyPages, all DataExchange and function calls on the PropertyPage but still the same result.

CResultsSheet::CResultsSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
      :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)

void CImageAnalysisDoc::OnResultsShow()
      CResultsSheet resultsSheet(IDS_RESULTS);
      if(resultsSheet.DoModal() == IDOK)

Expert Comment

ID: 10686646
I had designed in my earlier project a PropertyPage which had more than 255 controls in a single page. I guess there is no problem of resources unless you create them on heap. As I can see they are all statically created.
Only problem could arise is from DoDataExchange() and the selection pointer as pointed out by AndyAinscow

One more pointed i noticed is DDX_Check takes parameter as a reference to an integer. You have defined them as BOOL. I checked out that in one of the defines that BOOL is defined as int so there should be no problem. But ideally all must be type casted to boolean value whenever you assign any value.

Author Comment

ID: 10701898
akalmani>> I have tried to comment out the DoDataExchange() part but the proplem still occurs.

When trying on a Win2000 computer the problem does not occur! Could it be something that is not compatible between WinXP and VC++ 6.0?

Author Comment

ID: 10702032
I did some more testing on my Win2000 computer and the problem occured after about 70 attempts! (The test procedure of this is very boring...). I have installed VisualStudion 6.0 SP5 but that did not help.

Expert Comment

ID: 10702091
Are you using any API's which are not supported on XP ? Usually MS supports its API's but crosscheck once if they are really supported?

Expert Comment

ID: 10702094
Ohh please ignore my last comments...I did not read it thoroughly...Sorry...

Author Comment

ID: 10702162
If I make a loop to show the PropertySheet then the problem does not occur - at least not after 150 attempts...

void CImageAnalysisDoc::OnResultsShow()

bool CImageAnalysisDoc::resultsShow()
      bool idok=false;
      CResultsSheet resultsSheet(&categoryList, &fieldIdentityList, &selectedParameters, IDS_RESULTS, selectedStatisticValues, this);
      if(resultsSheet.DoModal() == IDOK)
      return idok;
LVL 44

Expert Comment

ID: 10702371
If I make a loop to show the PropertySheet then the problem does not occur - at least not after 150 attempts...

Please post the code of how you do it manually, or is your resultsShow function called from a button press?

Author Comment

ID: 10702462
The resultsShow function is called from a button press. If you change while(resultsShow()); into resultsShow(); in OnResultsShow() above then you have the normal function call.

Author Comment

ID: 10703175
I think I've got it now!

My main menu has two recent file lists in two pop-up menus. It also has a pop-up menu that should not be shown to all users. This recent file lists are updated and the pop-up menu is removed in an OnUpdate...() function call. Since I have two different recent file lists I have not used the AddToRecentFileList() function. Instead I have four extra items in the two pop-up menus and removing those that have empty strings. For some reason that I don't understand I need to update this list for each OnUpdate...() call instead of only when a new file is opened.

If I use two separate menus, one with the extra pop-up menu (IDR_MAINFRAME_EXTRA) and one without (IDR_MAINFRAME) and use one of those instead of removing the pop-up menu then everything works. I still don't know why this would destroy my PropertyPage, but as long as it works I'm satisfied...

LVL 44

Expert Comment

ID: 10703215
Somewhere in that code you are probably leaking resources (and may still be doing so) hence this failure.

Author Comment

ID: 10703286
Here's the modified menu update code. Is it still leaking resources?

void CImageAnalysisDoc::OnUpdateMacroRun(CCmdUI* pCmdUI)

void CImageAnalysisDoc::macroUpdateMenu()
                CMenu menu;
      int i=0, found=-1;

      CString menuItem;
      while(i<menu.GetMenuItemCount( ) && found <0)
            menu.GetMenuString(i, menuItem, MF_BYPOSITION);
                  int pos;
                  CString fName;
                  CMenu *pSubMenu=menu.GetSubMenu(i);
                        pSubMenu->RemoveMenu(ID_MACROFILE4, MF_BYCOMMAND);
                        pSubMenu->RemoveMenu(ID_MACROFILE3, MF_BYCOMMAND);
                        pSubMenu->RemoveMenu(ID_MACROFILE2, MF_BYCOMMAND);
                        pSubMenu->RemoveMenu(ID_MACROFILE1, MF_BYCOMMAND);
                        pSubMenu->RemoveMenu(pSubMenu->GetMenuItemCount()-1, MF_BYPOSITION);
                  CMainFrame* wnd = (CMainFrame*)AfxGetMainWnd();
                  wnd->SetMenu( &menu );
LVL 44

Accepted Solution

AndyAinscow earned 500 total points
ID: 10703339
From help files

void CMainFrame::OnReplaceMenu()
   // Load the new menu.

   // Remove and destroy the old menu

   // Add the new menu

   // Assign default menu
   m_hMenuDefault = m_NewMenu.GetSafeHmenu();  // or m_NewMenu.m_hMenu;

I think you never destroyed the previous menu associated with the frame

Author Comment

ID: 10713489
Thanks Andy for all the help. I think I have got it working completely now. I reduced the number of SetMenu calls to just one in the initialization and work with GetMenu() directly instead when updating the menus.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
Folder Comparison 12 55
Best tools for Backup and restore of Wordpress site 6 58
changeXy challenge 13 93
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question