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 sheet before close ask...

    Hi !,

    I have a property sheet, and I want that when the users presses over the close button of the window, ask if he really want to close the window ( without save, bla bla...), I have tried with OnCancel Method and with Close method, but none of this methods are called when I debug the application, anybody can help me ?

    Thanks, Bye !

    Braulio



  2. #2
    Join Date
    May 1999
    Posts
    116

    Re: Property sheet before close ask...

    In CPropertyPage there is a overridable called OnQueryCancel. This is called by the propertysheet when a user click the Cancel / Close button. If you catch this for each of your property pages you could call into a function in your CPropertySheet class to do some validation before closing.


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

    Thanks but...

    Thanks, but...

    I would like to let the user the chance of not close the property sheet ( is something like "Loose changes ? Yes/No", and if it's no keep on showing the property sheet.

    Can you help me a little bit more ? , Thanks, Bye !
    Braulio


  4. #4
    Join Date
    May 1999
    Posts
    116

    Re: Thanks but...

    yes, you return false from the OnQueryCancel and the property sheet dont close.


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

    Re: Thanks but...

    Thanks but...

    I have taked one page and I have return FALSE always, to see if the property sheet is not closed, but is closed...

    What have I made wrong ? Thanks, Bye !
    Braulio



  6. #6
    Join Date
    May 1999
    Posts
    116

    Re: Thanks but...

    In your PropertySheet derived class (if you have one) add a function to validate the close.BOOl CMyPropertySheet::OkToClose()
    {
    return m_bOkToClose;
    }

    Then in each of your propertypages override OnQueryCancel and do something like this:BOOL CMyPropPage1::OnQueryCancel()
    {
    CMyPropertySheet *pPropSheet = (CMyPropertySheet *)GetParent();
    return pPropSheet->OkToClose();
    }

    and this should do it for u.

    Note, I assume you are trying to catch this on the Close/Cancel button and not OK, or Finish or whatever....


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

    Thanks !

    Hi,

    Thanks, now works !, I didn't knew that I had to return FALSE in all the pages, Thanks, Bye !
    Braulio


  8. #8
    Join Date
    May 1999
    Posts
    116

    Re: Thanks !

    Neither did I but it was worth a try :-)
    Actually I think it might only be the page that is active when you try to close the sheet. But seeing as you dont know which page will be active you have to check in all pages.

    Brian


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