-
May 17th, 2009, 10:35 AM
#1
TabCtrl saving tab (dialog) changes...
We are using vc++ v6 and an existing application.
I am taking an existing application that had several separate dialogs and combining them into a new tabbed dialog.
I have never worked with the tabctrl but searched the net and found some tutorials that worked for what I need. I based alot of my changes off of:
http://www.codersource.net/mfc_ctabctrl.html
although there is more direct help here.
Here is my situation... I have this working, and have four different tabs with the appropriate dialog boxes appearing in the tabs. Three of the tabs allow for changes to be made on that tab and those changes need to be checked and saved when done. The original code for the individual dialog had a "SAVE" button that fired a function called OnSave().
I need to automatically fire that routine if the user clicks on another tab or closes the main dialog box. If their is an error (such as an improper or missing data), I need to stay on the tab and let them fix it after an error message.
I am not sure what is the best way to do this or if there is a function or variable I am not aware of to help with this. Can someone give me some ideas, examples, or directions on how to do this.
Thanks
Last edited by pbrama; May 17th, 2009 at 08:50 PM.
-
May 17th, 2009, 11:35 AM
#2
Re: TabCtrl saving tab (dialog) changes...
Handle the TCN_SELCHANGING notification in the parent dialog of the tab control.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
May 17th, 2009, 08:53 PM
#3
Re: TabCtrl saving tab (dialog) changes...
Not to be a novice here.... but how do I use that? I used the TCN_SELCHANGE by setting up a Member Function according to the tutorial but even that was the first time using that and I verbatim copied it.
I understand the concept but not sure how to call the SAVE function based off this call.
Thanks again...
-
May 17th, 2009, 09:24 PM
#4
Re: TabCtrl saving tab (dialog) changes...
You actually need to handle TCN_SELCHANGING.
This notification is sent before the tab selection changes.
If you return TRUE from this handler, the tab selection will be denied.
-
May 18th, 2009, 08:35 PM
#5
Re: TabCtrl saving tab (dialog) changes...
Thank you... this works for using the GetCurFocus() call to see what tab I am on.
This may be a simple question related to this but for the life of me I am drawing a blank....
I need to call the OnNext() function of the dialog that is on the 3rd tab. The dialogs are in an array (according to the tutorial I copied from). Because I am on a different class than the dialog, and the actual class for that dialog is a derived class, and the parent class does NOT have the OnNext() function... I am at a loss to figure out how to call it from the TCN_SELCHANGING function.
Hope I didn't confuse everyone on this... it's confusing trying to adapt someone elses code like I am... I really don't want to rewrite everything.
-
May 19th, 2009, 04:33 AM
#6
Re: TabCtrl saving tab (dialog) changes...
You can use CTabCtrl::GetCurSel to get the currently selected tab index.
I think you can use that as an index into the array to call OnNext.
-
May 19th, 2009, 07:52 AM
#7
Re: TabCtrl saving tab (dialog) changes...
I tried
m_dialog[nCur]->OnNext()
but that errored out saying that OnNext() was not a member function of CDialog. It's a member function of a derived class of CDialog.
-
May 19th, 2009, 12:39 PM
#8
Re: TabCtrl saving tab (dialog) changes...
The simple answer is, cast to the derived class, then make the call to OnNext.
It seems like a good place to use a common base class that defines a virtual OnNext function that all of the derived classes implement.
Kelly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|