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. Call CListCtrl::GetItemCount() in work thread proble.

Call CListCtrl::GetItemCount() in work thread proble.

Scheduled Pinned Locked Moved C / C++ / MFC
c++designtutorialquestion
6 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.
  • Y Offline
    Y Offline
    yu jian
    wrote on last edited by
    #1

    I find that if the UI thread is block. it will be blocked when call CListCtrl::GetItemCount(). I want to know how the MFC low level to achieve this function? If I use the MsgWaitForMultiObjects to block UI thread. How to set the QS_ALLINPUTS?

    _ J 2 Replies Last reply
    0
    • Y yu jian

      I find that if the UI thread is block. it will be blocked when call CListCtrl::GetItemCount(). I want to know how the MFC low level to achieve this function? If I use the MsgWaitForMultiObjects to block UI thread. How to set the QS_ALLINPUTS?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      I'm not sure if I understand you correctly. But you can see how wait functions work here - Halt! Who Goes There?[^]

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      1 Reply Last reply
      0
      • Y yu jian

        I find that if the UI thread is block. it will be blocked when call CListCtrl::GetItemCount(). I want to know how the MFC low level to achieve this function? If I use the MsgWaitForMultiObjects to block UI thread. How to set the QS_ALLINPUTS?

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        Low level of MFC is the Win32 API. Open the context menu by right clicking on a call to CListCtrl::GetItemCount() and choose 'Go to definition'. You will see that it is an inline function that sends the LVM_GETITEMCOUNT message to the list control window. This message is not processed while your GUI thread is blocked. A general rule is: Never block GUI threads. If you have to wait for events, do this in worker threads.

        Y 1 Reply Last reply
        0
        • J Jochen Arndt

          Low level of MFC is the Win32 API. Open the context menu by right clicking on a call to CListCtrl::GetItemCount() and choose 'Go to definition'. You will see that it is an inline function that sends the LVM_GETITEMCOUNT message to the list control window. This message is not processed while your GUI thread is blocked. A general rule is: Never block GUI threads. If you have to wait for events, do this in worker threads.

          Y Offline
          Y Offline
          yu jian
          wrote on last edited by
          #4

          Hi Jochen Arndt, You are very nice. But why I cannot see the source code of CListCtrl::GetItemCount()? My develop tools is visual studio 2008.

          J 1 Reply Last reply
          0
          • Y yu jian

            Hi Jochen Arndt, You are very nice. But why I cannot see the source code of CListCtrl::GetItemCount()? My develop tools is visual studio 2008.

            J Offline
            J Offline
            Jochen Arndt
            wrote on last edited by
            #5

            I don't know why. You may also place the cursor on the call and press F12. With VS 2003 here, the MFC CListCtrl::GetItemCount() code is located in the VC subdirectory atlmfc\include\afxcmn.inl. I suggested to look on the MFC sources so that you can see that most functions will only (or besides other tasks) just send messages. If you don't have used the 'Go to definition' feature so far, give it a try. It is very useful. Not only for MFC functions, but also for your own ones to quickly see the source.

            Y 1 Reply Last reply
            0
            • J Jochen Arndt

              I don't know why. You may also place the cursor on the call and press F12. With VS 2003 here, the MFC CListCtrl::GetItemCount() code is located in the VC subdirectory atlmfc\include\afxcmn.inl. I suggested to look on the MFC sources so that you can see that most functions will only (or besides other tasks) just send messages. If you don't have used the 'Go to definition' feature so far, give it a try. It is very useful. Not only for MFC functions, but also for your own ones to quickly see the source.

              Y Offline
              Y Offline
              yu jian
              wrote on last edited by
              #6

              Thank you Jochen Arndt I search the visual studio installed folder, and then find this file. It's greatly thing to see the MFC controls source.

              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