• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

PropertyPage disappears mysteriously

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!

  • 16
  • 13
  • 3
  • +1
1 Solution
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.
AndyAinscowFreelance programmer / ConsultantCommented:
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).
P1RAuthor Commented:
* 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?)
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

P1RAuthor Commented:
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.
AndyAinscowFreelance programmer / ConsultantCommented:
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.
P1RAuthor Commented:
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.
AndyAinscowFreelance programmer / ConsultantCommented:
resource handles not system memory
P1RAuthor Commented:
Do you mean the number of threads and processes? Those are constant during the test.
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.
AndyAinscowFreelance programmer / ConsultantCommented:
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.
P1RAuthor Commented:
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.
AndyAinscowFreelance programmer / ConsultantCommented:
can you post the code of this page4 here?  (not just a little bit of the page, the whole lot).
P1RAuthor Commented:
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)

AndyAinscowFreelance programmer / ConsultantCommented:
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?
P1RAuthor Commented:
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;
AndyAinscowFreelance programmer / ConsultantCommented:
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?
AndyAinscowFreelance programmer / ConsultantCommented:
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.
AndyAinscowFreelance programmer / ConsultantCommented:
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.
P1RAuthor Commented:
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.
AndyAinscowFreelance programmer / ConsultantCommented:
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.
P1RAuthor Commented:
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)
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.
P1RAuthor Commented:
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?
P1RAuthor Commented:
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.
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?
Ohh please ignore my last comments...I did not read it thoroughly...Sorry...
P1RAuthor Commented:
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;
AndyAinscowFreelance programmer / ConsultantCommented:
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?
P1RAuthor Commented:
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.
P1RAuthor Commented:
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...

AndyAinscowFreelance programmer / ConsultantCommented:
Somewhere in that code you are probably leaking resources (and may still be doing so) hence this failure.
P1RAuthor Commented:
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 );
AndyAinscowFreelance programmer / ConsultantCommented:
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
P1RAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 16
  • 13
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now