Solved

Modeless Property Sheet disappears

Posted on 2002-03-31
4
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 178
if loop in java 3 174
sum13 challenge 24 148
NotAlone Challenge 20 92
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 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