Processing messages in a modal dialog box.
I am working on a modal dialog application, I would like to display dynamic data in the box. The problem I am encountering is the applicatioon no longer responds to the buttons on the dialog, additionally the background of the dynamic data is white.
I am writing the application to learn and I am using LCC Win32 so solutions must use the standard Win32 API.
Any help would be graetly appreciated.
Jonsey
# 1 Re: Processing messages in a modal dialog box.
Hi,
I guess you will need to implement your worker function as a thread. The Modal box works on one thread, so when you do some lengthy calculation (or when your app is in an infinite loop) the box stops responding. The way out of this is to start a tread in your Button - click - event - handler that does the actual calculation. This new thread can then post back some messages to the dialog (e.g. as to what the progress of the calculation is).
Cheers,
D
# 2 Re: Processing messages in a modal dialog box.
Thanks for the fast response I will need a little help understanding what you are saying. In other words how do I define a function as a thread? Can that function return control to the dialog message loop?
Thanks
Jonesy
# 3 Re: Processing messages in a modal dialog box.
look up afxbeginthread() function for a simple threading library. Also make sure your project is multi-threaded (linked against multi thread libs) in the project settings (I think, by default, gui apps are set up for this).
Its pretty simple, you make a function of type UINT that takes a pointer to your parameters (you might wrap these in an array or a struct if you have more than one/none) and call afxbeginthread with the function name as a parameter. But there are examples and all in the help.
jonnin at 2007-11-11 21:00:41 >

# 4 Re: Processing messages in a modal dialog box.
Thanks for reply, afxbeginthread seems to be an MFC library, I am using LCCWin32 is there another way to start a thread?
# 6 Re: Processing messages in a modal dialog box.
Thanks for your help everyone, you got me looking in the right places. My solution was to use CreateThread in my message loop.