Solved

Modeless Property Sheet disappears

Posted on 2002-03-31
4
326 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 109
conditional code and condition difference 9 77
abstract class with all non abstract mentods 6 76
wordmultiple challenge 12 117
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

919 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

16 Experts available now in Live!

Get 1:1 Help Now