Sample: Manipulating controls on property page/Property Sheet 
Author Message
 Sample: Manipulating controls on property page/Property Sheet

Is there a sample to manipulate the controls on a
propertypage/propertysheet.  Anytime I try to update a listbox or an
edit control I get an assertion.

Thanks



Tue, 28 Sep 1999 03:00:00 GMT  
 Sample: Manipulating controls on property page/Property Sheet



Quote:
> >Is there a sample to manipulate the controls on a
> >propertypage/propertysheet.  Anytime I try to update a listbox or an
> >edit control I get an assertion.

> Can you be more specific about your problem? Are you trying to use MFC
> member variables before they're initialised? You can only use the
> member variables after the call to the default OnInitDialog.

I seem to remember that that property pages aren't initialised until the
first time
they are displayed (which makes sense for performance reasons).
So you can't set values on page 2 in response to actions on page 1, unless
page 2 has already been displayed.

A work around would be to store the values in DDX member
variables and only call UpdateData(FALSE) if the page has been initialised.
The default OnInitDialog will call UpdateData(FALSE).

--
Niels Ull Jacobsen, Price Waterhouse Denmark
Disclaimer: This message does not represent the views of Price Waterhouse

To mail me, please remove last X from my e-mail address - automatic
junk mail is getting to be a problem.

Quote:

> Dave
> ----
> Address is altered to discourage junk mail.
> Remove ".---" for the real address.



Sun, 03 Oct 1999 03:00:00 GMT  
 Sample: Manipulating controls on property page/Property Sheet


Fri, 19 Jun 1992 00:00:00 GMT  
 Sample: Manipulating controls on property page/Property Sheet

Quote:

> 97.4.28

> I receive the same problem with ListBox controls in property sheets.
> By the given docs, you are capable of manipulating member variables
> of property pages ~before~ adding them to the property sheet and
> calling DoModal() [see Adding User Interface...How to Use Property
> Pages...Manipulating Data Members -- VC5 Help].  Now I get an
> assertion error only on the ListBox and ~only~ when I attempt to call
> and CListBox member functions. Whether it's before adding the page
> to a property sheet, after doing so, or even ~inside~ the property page
> code (like OnInitDialog, constructor, anywhere!). Solution? That's easy.
> No calls to the control, no errors. One call, assertion error. All other
> member variables may be manipulated although I should add the other
> variables are not control classes (only ints and CStrings). This is my
> first attempt at implementing a Class Control in a property page (in a
> dialog box, no problems). Here's my sample code, see if anyone can
> figure it out:

>     COptionsSheet Options(_T("Options..."), this);

>     // Pages
>     CPageOne PgOne;
>     CPageTwo PgTwo;
>     CPageThree PgThree;

>     // Page One Settings
>     PgOne.m_string = GetCString();   // retrieves a CString from parent
>     PgOne.m_integer = GetInteger();  // retrieves an integer from parent
>     PgOne.m_bool = GetBoolean();  // retrieves a BOOL from parent
>     // ^^^ actual code, changed names for simplicity ^^^

>     // Page Two Settings
>     PgTwo.m_string = GetOtherCString();  // yep, another CString

>     // Page Three Settings   <----- THIS IS THE KILLER CODE
>     PgThree.m_listbox.AddString("It is gonna die here!");
>     PgThree.m_listbox.SetCurSel(0);

>     // Merge pages to sheet
>     Options.AddPage(&PgOne);
>     Options.AddPage(&PgTwo);
>     Options.AddPage(&PgThree);

You can't try to call any member functions for PgThree.m_listbox until
the listbox is created - and it won't be created until you call
Options.DoModal().  To fill the listbox, in PgThree::OnInitDialog() add
the code m_listbox.AddString("This is where I belong");

An aside, I usually place my AddPage() calls immediately after my page
declarations like so:

      COptionsSheet Options("Options...");

      // Pages
      CPageOne PgOne;
      CPageTwo PgTwo;
      CPageThree PgThree;

      // Merge pages to sheet
      Options.AddPage(&PgOne);
      Options.AddPage(&PgTwo);
      Options.AddPage(&PgThree);

      // Page One Settings
                ...

        etc.

        Rail
--
        Recording Engineer/Software Developer
        Rail Jon Rogut Software
        http://home.earthlink.net/~railro



Sat, 16 Oct 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Controls in a property sheet, outside property pages

2. Property Sheet and Property pages in ATL

3. How to disable property page on property sheet.

4. Property sheet in a property page

5. Property pages disappearing from property sheet on selection

6. questions regarding property sheet and property page

7. Problem with same property page in multiple property sheets

8. Sizing Property Sheets/Property Pages

9. Problems with property sheets and property pages

10. Property Sheet and Property Pages

11. Property Sheet on Property Page?

12. resizable property sheet and property page

 

 
Powered by phpBB® Forum Software