So I have a list box in my dialog, and I am using SendMessage as such: SendMessage(hListBox, LB_GETTEXTLEN, 0, 0);
I am trying to get the length of the text in the first item. MSDN says that the index is zero-based and that it goes in wParam, so I'm using 0 for wParam as it's the first item, but it keeps returning LB_ERR for no obvious reason. This function is only called when the list box actually has any text; I can even see the text in the list box. It is definitely in the first item, so I'm wondering why this function is failing... can anyone help me out? Should I provide any more info?
EDIT: also, would there be any chance of multithreading being related to this?
EDIT 2: Stupid, stupid, stupid... realised I cleared the listbox beforehand... LOL
This was probably the cause after all >.>
What I was doing was sending a custom message (WM_USER + x) to the UI thread from my other / worker thread. The handler then called the SendMessage... does that count as accessing it from another thread?
No, that's a good thing to do. But if you attempt to measure strings like that, where's the gain? Nowhere. You'll be synchronizing your worker threads with the UI thread and no performance gain is achieved.
Sorry... I don't really understand what you mean. Sending this message is only a small part of the task that the worker thread does, which I shifted to a worker thread so my main window could still function while the task was in progress. Also, this has been my first venture into multithreading (you can probably tell :P) and I'm okay with just one extra thread for the moment.