Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Modeless CPropertySheet destruction?

Modeless CPropertySheet destruction?

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Spawn Melmac
    wrote on last edited by
    #1

    Greetings, My problem is that I am spawning multiple modeless CPropertySheet dialogs from my application but the closure of the CPropertySheet dialog does not destroy the pages that have been added. I can see from the trace statements that the destructors for the individual pages are called but if I try to re-spawn the CPropertySheet I find it already has pages added???? I have tried creating my own class and using the following code in the destructor

    while (this->GetPageCount())
    {
    	this->RemovePage(this->GetPageCount());
    }
    

    This compiles ok but fails on execution. Where am I going wrong? Many thanks

    Alan

    L L 2 Replies Last reply
    0
    • S Spawn Melmac

      Greetings, My problem is that I am spawning multiple modeless CPropertySheet dialogs from my application but the closure of the CPropertySheet dialog does not destroy the pages that have been added. I can see from the trace statements that the destructors for the individual pages are called but if I try to re-spawn the CPropertySheet I find it already has pages added???? I have tried creating my own class and using the following code in the destructor

      while (this->GetPageCount())
      {
      	this->RemovePage(this->GetPageCount());
      }
      

      This compiles ok but fails on execution. Where am I going wrong? Many thanks

      Alan

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try this as the WM_DESTROY handler for the property sheet -

      BOOL CPropsSheet::DestroyWindow()
      {
      for (int p = GetPageCount () - 1;p > -1;p--)
      RemovePage (p);

      return CPropertySheet::DestroyWindow();
      

      }

      I suspect the problem lies in your RemovePage call. The page count page indices are 0-based; RemovePage(GetPageCount()) is trying to remove a non-existent page. [edit] edit for clarity [/edit]

      L u n a t i c F r i n g e

      modified on Tuesday, March 9, 2010 7:19 PM

      1 Reply Last reply
      0
      • S Spawn Melmac

        Greetings, My problem is that I am spawning multiple modeless CPropertySheet dialogs from my application but the closure of the CPropertySheet dialog does not destroy the pages that have been added. I can see from the trace statements that the destructors for the individual pages are called but if I try to re-spawn the CPropertySheet I find it already has pages added???? I have tried creating my own class and using the following code in the destructor

        while (this->GetPageCount())
        {
        	this->RemovePage(this->GetPageCount());
        }
        

        This compiles ok but fails on execution. Where am I going wrong? Many thanks

        Alan

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, 1. aren't the tab pages numbered from 0 to count-1, which would mean you are (not) removing a non-existing page forever? 2. you could remove the first tab page in a loop, until none remain. simpler code, the drawback is tab pages now could move on the screen while your loop executes. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


        S 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, 1. aren't the tab pages numbered from 0 to count-1, which would mean you are (not) removing a non-existing page forever? 2. you could remove the first tab page in a loop, until none remain. simpler code, the drawback is tab pages now could move on the screen while your loop executes. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


          S Offline
          S Offline
          Spawn Melmac
          wrote on last edited by
          #4

          Using the DestroyWindow seems to work fine and taking into accout the base for the count makes all the difference ;) ( Doh!) Thank you both.

          Alan

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups