CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    Property pages... How can I know when one page has never been showed ?

    Hi,

    I have a little problem with property sheets/pages:

    I have some variables that I need to share from the pages to my property sheet, but the problem is when one page is never selected then its variables has garbage, Is there any way to know if one property page has been initialized ( showed at least one time) ?

    I have tried to, to initialize all the pages ( with the Premature flag), but gives me a compiler error, don't recognizes this flag ! ( I'm using 5.0).

    Anybody can help me ? Thanks, Bye !
    Braulio


  2. #2
    Join Date
    May 1999
    Posts
    28

    Re: Property pages... How can I know when one page has never been showed ?

    try using counter variable for each page


  3. #3
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    Thanks But...

    Thanks But...

    What you told me is to put member variables on the property sheet, and on the InitDialog of every page when is called put the variables to TRUE.

    I think this will work, but is a little bit bad that MFC doesn't has anything for this thing ( i think that is a normal thing, sometimes you need to know before close wich thing has been modified or not, or...), but... "**** happens" ;-)

    Thanks, Bye !
    Braulio


  4. #4
    Guest

    Re: Thanks But...

    Simple!

    Just derive your own CMyPropertyPage from CPropertyPage, and then
    derive the member function

    CPropertyPage::OnSetActive() which is called when a page is entered

    Use a Boolean Variable for each Page to indicate it has been shown or not.

    Uli



  5. #5
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: Property pages... How can I know when one page has never been showed ?

    Check to see if the page's HWND is non zoer or not, that should indicate if the page has been shown or not...

    Sally


  6. #6
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    Thanks !, Good idea !

    Thanks,

    Good Idea !

    Bye
    Braulio


  7. #7
    Join Date
    Apr 1999
    Location
    Portland, OR, USA
    Posts
    29

    Re: Property pages... How can I know when one page has never been showed ?

    You should always supply default values to those variables, and they should be set in the pages themselves. For example, if you have two pages that each have two edit boxes, you should do the following:


    CMySheet sheet;
    CMyPage1 page1;
    CMyPage2 page2;

    CString s1 = "Foo";
    CString s2 = "Bar";
    CString s3 = "Hello";
    CString s4 = "World";

    page1.edit1 = s1;
    page1.edit2 = s2;
    page2.edit1 = s3;
    page2.edit2 = s4;

    sheet.AddPage(page1);
    sheet.AddPage(page2);

    if (IDOK == sheet.DoModal())
    {
    s1 = page1.edit1;
    s2 = page1.edit2;
    s3 = page2.edit1;
    s4 = page2.edit2;
    }




    This way, all the variables on all your pages have valid values when the user clicks "OK", and you don't have to worry about whether or not the page has been accessed. Anyway, I hope this helps! Good luck, and happy coding.

    =================================================
    Valerie L. Bradley
    Software Engineer
    Intel Corporation

    * All opinions expressed are mine and not those of my employer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured