The problem is, the main thread is waiting on a mutex, which is held by the thread that's logging. And the thread that's doing the logging at the moment is locked in SendMessage() waiting for the main thread to wake up. *scream*
So I got around to making a simple Log class, that lets me do things nicely. When I log something to the window now, I allocate a buffer (from a free list, to help performance and fragmentation), copy the text into it, and use PostMessage() to post it to the log window. The log window adds the text and then frees the buffer.
It also allows me to add more functions like Log::Format(), Log::System(), Log::ToFile(), and so on without any extra hastle. Yay.
As far as I can tell, the socket code is working. I still haven't got the threads sorted yet, and I still haven't posted about that either. I'll have a think about it on the train on the way home, and if I can't think of anything, I'll try posting about it.
End of lunch, back to work...