We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

MFC DLL.

Medium Priority
2,483 Views
Last Modified: 2013-11-25
Hi,
   I need to write an MFC Dialog that communicates with a delphi program. The delphi program is the master which will call up this MFC dialog and communicate with it via windows messages. The delphi program and the MFC dialog must run in parallel.

I wrote the MFC Dialog as an MFC regular DLL. The dialog is created at the initinstance of the winApp in the MFC DLL.
However, the MFC Dialog does not seem to have its own message queue becoz it is not refreshed. What is the correct way to do this?

Thanks.


Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Modeless. Modal is not applicable because if the Dialog is modal, the master delphi program will not be able to continue until the user clicks on the OK button.

Commented:
Hi,
What do you mean by "it is not refreshed"? Do you send some 'refreshing' messages to the dialog and it doesn't react?

Author

Commented:
Let me rephrase the question.

I need to do some number crunching in a win32 console program and update a dialog as the number crunching progresses. Also, I want to write the modeless CDialog as a MFC regular DLL. How can I achieve this?

Do I need to create a separate thread for the message pump of the MFC DLL?
As it is now, when I add a message pump (while loop) to the winApp class, it seem to be taking up all the processing time and I am not able to return to the number crunching program to do my data processing.

How do I make the MFC DLL's message pump run on a separate thread?

Please advise.

Thanks.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
>Do I need to create a separate thread for the message pump of the MFC DLL?

No. Why do you think it is a message pump problem? What exactly is the problem? Please respond to nonubik's question.

Author

Commented:
Thanks for all the help.

Lakshman: Do I still need to do all that if I am already wusing CWinApp? As far as i know, CWinApp is derived from CWinThread.

ChenSu: I think (though I am not sure) it is a message pump problem because i read from MSDN that for a modeless dialog in a MFC regular DLL, the message pump is owned by the application calling it.

The paragraph below is from MSDN TN011.
"Note that the CWinApp::Run mechanism doesn't apply to a DLL, since the application owns the main message pump. If your DLL brings up modeless dialogs or has a main frame window of its own, your application's main message pump must call a DLL-exported routine that calls CWinApp::PreTranslateMessage."

In my case, the win32 console program calling the MFC Dialog in the regular DLL does not have any message pump. What do I do?

Thanks.
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.