Solved

Modeless Property Sheet disappears

Posted on 2002-03-31
4
323 Views
Last Modified: 2013-11-20
Hello fellow experts,
I'm trying to write an application which loads a modeless property sheet (Attributes.h) with two tab pages.  In order to do this, I'm using CPropertySheet.create().  The dialog displays, but only for a brief second and then closes.  Any suggestions on how to fix it?  Thanks!

Here's my code for creating the sheet:
//includes
#include "Attributes.h"
#include "LightProperties.h"
#include "MaterialProperties.h"

//here is where i try to open the sheet
BOOL OpenGLDlg::OnInitDialog()
{
     CDialog::OnInitDialog();
         
     Attributes attributes("Attributes", NULL, 0);
     LightProperties light;
     attributes.AddPage(&light);
     MaterialProperties material;
     attributes.AddPage(&material);
     attributes.Create(this, WS_CHILD);
     attributes.ShowWindow(SW_NORMAL);
//............
0
Comment
Question by:SileNcer
4 Comments
 
LVL 3

Expert Comment

by:cypherljk
ID: 6909596
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 200 total points
ID: 6909676
I understabd ur problem. U r making the dialog in a local scope.
That is

In a {} bracket block u declared a dialog
like

{
....
CDlg oDlg;
oDlg.Create(...);
oDlg.ShowWindow(SW_SHOW);
....
}

So when it reaches the closing bracket ur dlg scope will ends...
So it calls its destructor, In destructor, the dialog class will call DestroyWindow...

So the remedy is
1. create the member in a global scope ie class member
2. create the member with new operator...and eqate that operator for future deletion...otherwise it causes memory leak
3. The Domodal is the other way- But u need parent messages this is not my suggession...

GOOD LUCK
0
 

Author Comment

by:SileNcer
ID: 6909680
THANK YOU BOTH FOR YOUR HELP :)
Roshmon,
You were right... I needed to put the line:
Attributes attributes("Attributes");
outside of this function as a global.  Runs great now!
0
 

Expert Comment

by:FelixShen
ID: 6909907
try this, it work well.

    MyPropertySheet *pattributes=new MyPropertySheet("");
    PropertyOne *light = new PropertyOne();
    pattributes->AddPage(light);
    PropertyTwo *material = new PropertyTwo();
    pattributes->AddPage(material);
    pattributes->Create();

just use "new" to create your property page and property sheet. And delete them when you close property sheet window.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now