Solved

PropertyPage disappears mysteriously

Posted on 2004-03-25
34
466 Views
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:
WM_NCCREATE
WM_NCCALCSIZE
WM_CREATE
WM_SIZE
WM_MOVE
WM_SETFONT
WM_INITDIALOG
... and a lot more.

When it fails the following messages are received:
WM_NCCREATE
WM_NCCALCSIZE
WM_CREATE
WM_SIZE
WM_MOVE
WM_SETFONT
WM_DESTROY
WM_NCDESTROY

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!
/P1R

0
Comment
Question by:P1R
  • 16
  • 13
  • 3
  • +1
34 Comments
 
LVL 6

Expert Comment

by:joghurt
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
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).
0
 

Author Comment

by:P1R
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?)
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:P1R
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.
0
 
LVL 44

Expert Comment

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



Suggestions?

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.
0
 

Author Comment

by:P1R
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 10676671
resource handles not system memory
0
 

Author Comment

by:P1R
ID: 10676791
Do you mean the number of threads and processes? Those are constant during the test.
0
 
LVL 6

Expert Comment

by:joghurt
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
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.
0
 

Author Comment

by:P1R
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.
0
 
LVL 44

Expert Comment

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

Author Comment

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

#if !defined(AFX_RESULTSVIEWSELECTIONPAGE_H__CDAC1C53_04CD_11D1_99F4_0020AF563EB1__INCLUDED_)
#define AFX_RESULTSVIEWSELECTIONPAGE_H__CDAC1C53_04CD_11D1_99F4_0020AF563EB1__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CResultsViewSelectionPage dialog

class CResultsViewSelectionPage : public CPropertyPage
{
friend class CResultsSheet;

      DECLARE_DYNCREATE(CResultsViewSelectionPage)

// Construction
public:
      void setSelectedObjectParams(__int64 params);
      void setSelectedFieldParams(__int64 params);
      CResultsViewSelectionPage();
      ~CResultsViewSelectionPage();

// Dialog Data
      //{{AFX_DATA(CResultsViewSelectionPage)
      enum { IDD = IDD_RESULTS_VIEW_SELECTION_PAGE };
      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;
      //}}AFX_DATA


// Overrides
      // ClassWizard generate virtual function overrides
      //{{AFX_VIRTUAL(CResultsViewSelectionPage)
      public:
      virtual BOOL OnKillActive();
      virtual BOOL OnSetActive();
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:
      CResultViewSelection* selection;

      void setData();
      void getData();

      // Generated message map functions
      //{{AFX_MSG(CResultsViewSelectionPage)
      afx_msg void OnSelectAllFieldParams();
      afx_msg void OnSelectAllObjectParams();
      afx_msg void OnSelectNoFieldParams();
      afx_msg void OnSelectNoObjectParams();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()

};

//{{AFX_INSERT_LOCATION}}
// 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__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CResultsViewSelectionPage property page

IMPLEMENT_DYNCREATE(CResultsViewSelectionPage, CPropertyPage)

CResultsViewSelectionPage::CResultsViewSelectionPage() : CPropertyPage(CResultsViewSelectionPage::IDD)
      {
      //{{AFX_DATA_INIT(CResultsViewSelectionPage)
      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;
      //}}AFX_DATA_INIT

      m_psp.dwFlags &= ~(PSP_HASHELP);
      }

CResultsViewSelectionPage::~CResultsViewSelectionPage()
{
}

void CResultsViewSelectionPage::DoDataExchange(CDataExchange* pDX)
{
      CPropertyPage::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CResultsViewSelectionPage)
      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);
      //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResultsViewSelectionPage, CPropertyPage)
      //{{AFX_MSG_MAP(CResultsViewSelectionPage)
      ON_BN_CLICKED(IDC_SELECT_ALL_FIELD_PARAMS, OnSelectAllFieldParams)
      ON_BN_CLICKED(IDC_SELECT_ALL_OBJECT_PARAMS, OnSelectAllObjectParams)
      ON_BN_CLICKED(IDC_SELECT_NO_FIELD_PARAMS, OnSelectNoFieldParams)
      ON_BN_CLICKED(IDC_SELECT_NO_OBJECT_PARAMS, OnSelectNoObjectParams)
      ON_WM_DESTROY()
      ON_WM_KILLFOCUS()
      ON_WM_LBUTTONDOWN()
      ON_WM_PAINT()
      ON_WM_SHOWWINDOW()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResultsViewSelectionPage message handlers

BOOL CResultsViewSelectionPage::OnKillActive()
      {
      getData();
      
      return CPropertyPage::OnKillActive();
      }

BOOL CResultsViewSelectionPage::OnSetActive()
      {
      setData();
      
      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;

      UpdateData(FALSE);
      }

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

      UpdateData();

      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);
      
      getData();

      selection->selectAllFieldParams();

      setData();
      }

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

      selection->deSelectAllFieldParams();

      setData();
      }

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

      getData();

      selection->selectAllObjectParams();

      setData();
      }

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

      getData();

      selection->deSelectAllObjectParams();

      setData();
      }
// -------------------------------------------------------------------------------------------------

void CResultsViewSelectionPage::setSelectedFieldParams(__int64 params)
{
      selection->setSelectedFieldParams(params);
}

void CResultsViewSelectionPage::setSelectedObjectParams(__int64 params)
{
      selection->setSelectedObjectParams(params);
}

0
 
LVL 44

Expert Comment

by:AndyAinscow
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
selection=NULL;
in your constructor?
0
 

Author Comment

by:P1R
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;
      showPage.doc=pDoc;
      AddPage(&showPage);

      histogramPage.categoryList = list;
      histogramPage.selection = currentSelection;
      AddPage(&histogramPage);

      exportPage.categoryList = list;
      exportPage.fieldIdentityList = fieldIDList;
      exportPage.selection = currentSelection;
      AddPage(&exportPage);

      viewSelectionPage.selection = currentSelection;
      AddPage(&viewSelectionPage);

      statisticsSelectionPage.selection = &selectedStatisticValues;
      AddPage(&statisticsSelectionPage);
}
0
 
LVL 44

Expert Comment

by:AndyAinscow
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?
0
 
LVL 44

Expert Comment

by:AndyAinscow
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(...)
dlg.DoModal();

use
CResultsSheet* pDlg = new CResultsSheet();
pDlg->DoModal();
delete pDlg;

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

Expert Comment

by:AndyAinscow
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(...)
dlg.DoModal();

use
CResultsSheet* pDlg = new CResultsSheet();
pDlg->DoModal();
delete pDlg;

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

Author Comment

by:P1R
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
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.
0
 

Author Comment

by:P1R
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)
{
      AddPage(&viewSelectionPage);
}

void CImageAnalysisDoc::OnResultsShow()
{                              
      CResultsSheet resultsSheet(IDS_RESULTS);
      if(resultsSheet.DoModal() == IDOK)
      {
      }
      else
      {
      }
}
0
 
LVL 3

Expert Comment

by:akalmani
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.
0
 

Author Comment

by:P1R
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?
0
 

Author Comment

by:P1R
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.
0
 
LVL 3

Expert Comment

by:akalmani
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?
0
 
LVL 3

Expert Comment

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

Author Comment

by:P1R
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()
{
      while(resultsShow());
}

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

Expert Comment

by:AndyAinscow
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?
0
 

Author Comment

by:P1R
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.
0
 

Author Comment

by:P1R
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...

0
 
LVL 44

Expert Comment

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

Author Comment

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

void CImageAnalysisDoc::OnUpdateMacroRun(CCmdUI* pCmdUI)
{
      macroUpdateMenu();
}

void CImageAnalysisDoc::macroUpdateMenu()
{      
                CMenu menu;
      if(!extraLicensed)
            menu.LoadMenu(IDR_MAINFRAME);
      else
            menu.LoadMenu(IDR_MAINFRAME_EXTRA);
      int i=0, found=-1;

      CString menuItem;
      while(i<menu.GetMenuItemCount( ) && found <0)
      {
            menu.GetMenuString(i, menuItem, MF_BYPOSITION);
            if(menuItem.Find("M&acro")>=0)
            {
                  int pos;
                  CString fName;
                  CMenu *pSubMenu=menu.GetSubMenu(i);
                  if(macroFile4.GetLength()==0)
                  {
                        pSubMenu->RemoveMenu(ID_MACROFILE4, MF_BYCOMMAND);
                  }
                  if(macroFile3.GetLength()==0)
                  {
                        pSubMenu->RemoveMenu(ID_MACROFILE3, MF_BYCOMMAND);
                  }
                  if(macroFile2.GetLength()==0)
                  {
                        pSubMenu->RemoveMenu(ID_MACROFILE2, MF_BYCOMMAND);
                  }
                  if(macroFile1.GetLength()==0)
                  {
                        pSubMenu->RemoveMenu(ID_MACROFILE1, MF_BYCOMMAND);
                        pSubMenu->RemoveMenu(pSubMenu->GetMenuItemCount()-1, MF_BYPOSITION);
                  }
                  CMainFrame* wnd = (CMainFrame*)AfxGetMainWnd();
                  wnd->SetMenu( &menu );
                  wnd->DrawMenuBar();
                  found=i;
            }
            else
                            i++;
      }
}
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 10703339
From help files

void CMainFrame::OnReplaceMenu()
{
   // Load the new menu.
   m_NewMenu.LoadMenu(IDR_SHORT_MENU);
   ASSERT(m_NewMenu);

   // Remove and destroy the old menu
   SetMenu(NULL);
   ::DestroyMenu(m_hMenuDefault);

   // Add the new menu
   SetMenu(&m_NewMenu);

   // 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
0
 

Author Comment

by:P1R
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 185
substring method in java 1 122
wordmultiple challenge 12 133
x-bar in Google Sheets 2 54
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 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