How to update a tab on tab control based on a change to another tab

I am new to MFC and am working on this existig project in MFC. With this in mind,I have been assigned to add new options on a tab to user(which I have done). But when the user selects an option, the main tab needs to reflect the users selection without clicking a button.For example, On tab 2, there is an edit box and as soon as the user enters "3", the user sholud be able to view this on the main tab without clicking a button on the tab that the user just changed. The main tab has all the options that are on the other tabs but are presented in a list view control. All the other tabs follow this but I have no clue where in the code it is doing this. With this in mind, I want to know how can a tab be updated as soon as a selection is made my a user in another tab. I have looked to see if UpdateData or OnTimer() is allowing this but, do't have no clue. Any help on ths will help!!Thank in advance!!


  • [color=Blue]If your MFC code uses CPropertySheet/CPropertyPage combination to display set of tabs and their pages then you need to override the function called [italic]OnSetActive[/italic] for the main tab and do the visual changes there.

    This is just one part - before the work in OnSetActive is done you need to SAVE the changes made in other tab(s) in their (tabs) [italic]OnKillActive[/italic] method.

    It means that when the whole thing opens you need to have some temporary storage where all options are stored. It may be some allocated object or a database table(s).

    If you have OK/Apply buttons then situation is even more complex, because until you have clicked those buttons the user changes for options cannot be saved into root storage, but user still want to SEE the changes in main tab.

    There is another way - you can provide a pointer to each tab and store it into main sheet. Also, provide the main sheet pointer to each tab, so they can communicate. When this is done, you can directly modify the UI controls on a main tab and other tabs if needed. Then you do not need the temporary options storage.[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion