CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2009
    Posts
    103

    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.

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    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

  3. #3
    Join Date
    May 2009
    Posts
    103

    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...

  4. #4
    Join Date
    Feb 2009
    Location
    India
    Posts
    444

    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.
    «_Superman
    I love work. It gives me something to do between weekends.

    Microsoft MVP (Visual C++)

  5. #5
    Join Date
    May 2009
    Posts
    103

    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.

  6. #6
    Join Date
    Feb 2009
    Location
    India
    Posts
    444

    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.
    «_Superman
    I love work. It gives me something to do between weekends.

    Microsoft MVP (Visual C++)

  7. #7
    Join Date
    May 2009
    Posts
    103

    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.

  8. #8
    Join Date
    Jun 2002
    Location
    Colorado, U.S.A.
    Posts
    980

    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
  •  





Click Here to Expand Forum to Full Width

Featured