Hello,
Ehsan Akhgari wrote:
You can send a 'window' message, but what I meant was a 'thread message' (a message associated with a thread, instead of one window). You post such a message using PostThreadMessage( ). This requires you be aware of the target thread's ID, and this doesn't make it impossible to port to other platforms, since I can't think of any hypothetical platform which 'knows' which thread you mean without you specifying some kind of an ID. :-)
Aha yes you're right, I didn't know about PostThreadMessage(), I thought you were talking about sending a 'window message' to a window. However after reading the documentation on PostThreadMessage() I must conclude that it doesn't really change the point I made: the thread still has to have a message queue. While theoretically it's not impossible to port it to other platforms, it's still a significant amount of work to implement the whole message queue idea on another platform. It also looks to me as if the gtk equivalent of PostThreadMessage() would be the g_idle_add() that I mentioned before, with the slight difference that functions added with g_idle_add() would only be executed when there are no other messages in th gtk event queue, while PostThreadMessage() would inject them into the windows event queue.
Thanks for pointing out this function to me; I think I can write an abstraction layer that would hide the differences between g_idle_add() and PostThreadMessage() so that those parts can go into the platform-specific parts of the program, along with the gui stuff. I'll still have a problem when I decide to make a console frontend but hey, in Dutch we have saying 'he who then lives, then worries' ;)
Again thanks for all in the replies to this thread; I have a better understanding of how things (in particular threads) work now. Now all I have to do this weekend is test whether that understanding is enough to make my program work :)
cheers,
roel
