Sign in to follow this  
fathom88

Question About PopUp Dialog Boxes

Recommended Posts

I'm trying to add a popup dialog box for my MFC VC++ application. I want to use it to modify settings in my app like display color. Hence, it has to be able read the current value and set a new value that is known throughout the application. For instance, my view window needs to know the current background color. I store it inside my CDocument and get a pointer to the document inside my FormView to get the color. The document/model view would work but the popup window is based on the a CDialog box. My problem is basically passing data between the popup and application. What is the correct method to pass back and forth application wide data to a popup window? Thanks.

Share this post


Link to post
Share on other sites
You can create a new message (WM_USER) to be sent in a particular situation with your specified WPARAM and LPARAM along with the message by using the Windows API function RegisterWindowMessage (). Then pass a pointer to your prefered object in WPARAM or LPARAM. For more details, refer to this Microsoft's MSDN article:

RegisterWindowMessage Function

I hope you'll find no troubles.
V@T

[Edit]
I didn't notice you're using MFC :-P

[Edited by - Skeleton_V@T on November 3, 2005 10:15:31 AM]

Share this post


Link to post
Share on other sites
MFC has a pretty fancy system for this called DDX I think it is. Its been a while since I used it but I think you just use the class wizard to add a new Dialog Box. The controls get wrapped in some of those crazy MFC macros and you're good to go.

But the basic approach is that you have a class that represents the dialog box and that class has member variables that correspond to the data you want the user to modify. So just before you put the dialog on the screen, you push the current values into it and display the dialog.

The function that puts the dialog on the screen won't return untill the dialog has been dismissed (since its modal) and so when it does, you check if the user pushed OK or Cancel. If they pushed OK, you pull the new values out of the dialog and do whatever with them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this