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