Solved

Modeless Property Sheet disappears

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
tripleUp challenge 7 86
Execute multiple curl cmds with sleep and send output to file 10 104
scoreUp challenge 14 64
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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