MFC中2个线程往CListBox添加内容,内容会被自动排序为啥呢?
我有2个线程,来演示的是线程的同步,每个线程中在CListBox添加自己的输出。同步效果出现了,也看到了显示的内容,但是不知道为啥每个线程的内容是紧挨着的。看图吧:
在生成内容的时候也看到了是线程1,线程2轮着出来内容的,但是出来后自动刷新下线程1的内容就挨着了,线程2的内容也挨着了。我想要的是
线程1...
线程2...
线程1...
线程2....
而不是图中的
线程1...
线程1...
线程2...
线程2...
那是怎么回事呢?我调用了UpdateData(TRUE) 也不行
[解决办法]
Call this member function to add a string to a list box. If the list box was not created with the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted. If the list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the framework sorts the list by one or more calls to the CompareItem member function.
[解决办法]
将ListBox属性中的Sort置成False。
[解决办法]
CListBox属性有个sort属性,看下是不是TRUE;