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. Threads & CPropertySheet

Threads & CPropertySheet

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialdebuggingquestion
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.
  • P Offline
    P Offline
    pmarki
    wrote on last edited by
    #1

    Hello I have problems with adding a property page in a new thread. The problem is CPropertyPage::AddPage() always produces debug assertion failure, when running from a thread. it looks like this: UINT SomeThread(LPVOID p) { ... CMyPropertyPage* newpage; newpage=new CMyPropertyPage; pdlg->m_PropertySheet.AddPage(newpage); //debug asertion failed ... } pdlg in this example was restored from the FromHandle function. I know that this error is caused by the fact that AddPage() is run in separate thread. Anyone knows how to do it properly ? I will appreciate any suggestions... thanks

    B 1 Reply Last reply
    0
    • P pmarki

      Hello I have problems with adding a property page in a new thread. The problem is CPropertyPage::AddPage() always produces debug assertion failure, when running from a thread. it looks like this: UINT SomeThread(LPVOID p) { ... CMyPropertyPage* newpage; newpage=new CMyPropertyPage; pdlg->m_PropertySheet.AddPage(newpage); //debug asertion failed ... } pdlg in this example was restored from the FromHandle function. I know that this error is caused by the fact that AddPage() is run in separate thread. Anyone knows how to do it properly ? I will appreciate any suggestions... thanks

      B Offline
      B Offline
      Bill Wilson
      wrote on last edited by
      #2

      Post a message to the original thread to add the page. (PostThreadMessage) Good Luck, Bill

      P 1 Reply Last reply
      0
      • B Bill Wilson

        Post a message to the original thread to add the page. (PostThreadMessage) Good Luck, Bill

        P Offline
        P Offline
        pmarki
        wrote on last edited by
        #3

        Thanks for the reply... ..but the thread in which CPropertySheet was created is the main user interface thread... and I don't know how to send it a ThreadMessage... Is there any other solution ?

        P 1 Reply Last reply
        0
        • P pmarki

          Thanks for the reply... ..but the thread in which CPropertySheet was created is the main user interface thread... and I don't know how to send it a ThreadMessage... Is there any other solution ?

          P Offline
          P Offline
          Prem Kumar
          wrote on last edited by
          #4

          Ok, Problem : Cannot get window handle to CPropertySheet Solution : No problem, all we need is the thread handle and we can post a msg to it. Analysis : Ok, every MFC project contains the global CWinApp derived object. Use that to get the handle of the main thread, and do a PostThreadMessage. MFC takes care of the routing, so dont worry. Just make sure that the id of the msg is unique and there is a handle in the CProp(Page)(Sheet) you want to handle the message.

          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