Heres my problem,i coded a app that uses mdi and had all the child windows like mini clients that let u connect to multiple server simutaniously and comunicate with them.The problem is to preserve all the child windows control handles I had to create ever child window in a new thread and to top it off i had to create thread for each connection.The only thing is how do I effectively get child window in one thread to communicatenwith the winsock thread,like to send data,receiving is ok. I tryed events there not every effective.also if theres away to preserve the control handles with make new thread and setting everything using LOCAL etc...due tell
Posted on 2003-12-29 10:27:48 by Webring
Having many threads is not good, especially if you're a newbie with it - because you may be lucky to make the program work ok, but if you don't make an excellent locking/synchronization system, you'll end up sometimes with strange GPFs , locks of the PC and garbage data . If you have 1 thread, it'll all be ok.
There are several ways to get out of your problem (if you insist on having threads), but they lead to a little different ways of program workflow.
1) To get thread ID, and verify if code is working in some thread, also you'll have to store the threads in some array
2) To send initialization value of CreateThread (the last argument), and to use it the way you want, usually in a "local" var
3) To set the window's USER_DATA to the thread's ID or anything you can identify a thread with. Use the SetWindowLong and "invoke GetWindowLong,hWnd,GWL_USERDATA".
4) GetTopWindow might be of some help
5) invoke GetWindow,hWnd,GW_CHILD

But I really recommend you don't use threads, and use the GetWindowLong to store/get pointer to a structure of your own, that describes the window with as many variables as you want :) .
Since you want many child windows that will behave independently but alike, you can use OOP, you can use my OOP macros at

you can ask for as much help as you need :alright:
Posted on 2003-12-29 16:42:20 by Ultrano