Thread and Dialog
Posted on 2001-06-26
Hi, first of all, I know nothing about MFC programming, I was a unix/server programmer.
So I have this task:
1. Start the application and draw all the windows (already done)
2. Near last step of initialization, create a thread that broadcast a message to LAN and listen for responses for about 10 seconds. Can be no response, or can be many responses. Store any response into a data structure. Then returns.
3. Last step, start another thread to listen to a port until the application exits. When this application on another machine does #2 above, this thread will respond, then go back to listen again.
#2 and #3 are supposed to be some kinda class, or routine, or API to the main program, and are the ones that I have to write.
If #2 has response, the main program should display a dialog containing the response info (in data structure). When the dialog is displayed, user should not be able to click on any other window/dialog of the application, but, the application must be able to continue processing whatever that has started, e.g. search for a file. I heard about modal dialog, but not sure if it is applicable here.
My friend told me #2 should use SendMessage to tell the main program that it should display a dialog because I should never display a dialog from a thread, I asked what is the difference to use return code of #2 to tell the calling program (in this case, main) that it should display a dialog.
I'd appreciate if you can explain how my task can be done, and perhaps what MFC programmers will generally do to handle this task. Do #2 and #2 have any flaw, etc. Simple example, or algorithm will be even better!
Also, if you know any online MFC tutorial for dummy, please provide the url. The msdn site is just too overwhelming or I'm not looking at the right page...