Thread: Refreshing a seperate Dialog

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    34

    Refreshing a seperate Dialog

    Hello everyone,

    I'm writing an MFC application and I need help with the GUI. So basically, I have some values that are stored as defaults to the registry and whenever the program is run/"Reset Defaults" button is clicked, all values revert to their defaults. I have been able to do this successfully for the dialog that the Reset Defaults button is in.

    However, there are values in another dialog that I also want refreshed when I click the button. I have been able to store the default values in the registry and even retrieve them when the program run and when the Reset Defaults button is clicked using static variables. Unfortunately, I have only been able to reflect any changes to the dialog upon runtime in the dialog itself, but not when Reset Defaults is hit.

    Is there some way that I can refresh the other dialog from the dialog that Reset Defaults is in so the different values are represented? Is there a better way to do this that I'm not seeing? Thanks.

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Just set the variables in your dialog that represent certain controls data to whatever you want through the dialog's object. You will usually also have to at some point call some DDX routine if the dialog is already showing. Otherwise DDX will be called if you set the variables before you display the dialog.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    34
    If I understand you correctly, wouldn't that only work if the data and the controls are in the same dialog?

  4. #4
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    No? The whole notion of a dialog in mfc is encapsulated in a class that derives from CDialog with the behavior that you want your dialog to have. That being said when you instantiate an object of your dialog class, your "dialog" is nothing more then a c++ object that behaves like any other c++ object.

    So you can either make your variables public, or write some accessor methods, either way if you don't set these variables before a routine that calls a DDX routine is called then you will need to make sure that when setting a variable in a dialog that you call UpdateData as this routine is responsible for actually sending the win32 messages to the child controls to set various properties. When you create a dialog in the resource editor, as you add variables "attached" to controls, the ddx routines will be updated by the designer.
    Last edited by valaris; 06-26-2009 at 09:02 AM.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    34
    I'm not sure we're on the same wavelength here, but I've isolated the problem a bit more. Basically, I have a group of tabs (File, Options, OS_Attitude, and two that aren't important) such that the Tabs dialog calls and creates OS_Attitude. Under Options, I have some settings regarding logs and modes. Long story short, is there a way to have OS_Attitude call functions that are in the Tabs file?

  6. #6
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Pass OS_Attitude a pointer to the Tabs dialog. Then it can call that objects methods. The point that I was trying to make is that you don't have to ask can I do this in MFC, but can I do that in c++.

    You're telling me that you have 2 objects and want them to interact, so just get some handle between the two and access the objects interface.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Edit controls of a dialog from another dialog...
    By Snake in forum Windows Programming
    Replies: 9
    Last Post: 07-01-2005, 02:18 PM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  4. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 02:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM