none
Suggestion requested for Class designing for Tab control RRS feed

  • Question

  • Hi,

    I am having a tab control on my dialog based MFC application.

    That tab control have 5 tabs. Each tab page is having different controls

    I am developing in VC++2012.

    I am looking for the suggestion how the structure/architecture of the project should be.

    Weather I make 1 individual class for each tab, to store the settings done by the user on that page? Or should I create 1 class to storing all the tab settings done by user?

    As finally I have to run the execution based on the setting done by the user in all the tabs?

    Kindly suggest,

    Thanks in Advance.


    Thanks & Regards, Mayank Agarwal

    Tuesday, September 27, 2016 7:23 AM

Answers

  • Hi MayankAg,

    thanks for posting here.

    >>Weather I make 1 individual class for each tab, to store the settings done by the user on that page? Or should I create 1 class to storing all the tab settings done by user?

    Which settings are you going to store?

    If you want to store user defined data type, I suggest you a base class and one derived class for each tab. Store the general settings in derived class and specific settings for each tab.

    Actually you could associate application-defined data with each tab. For example, you might save information about each page with its corresponding tab. By default, a tab control allocates four extra bytes per tab for application-defined data. You can change the number of extra bytes per tab by using the TCM_SETITEMEXTRA message. You can only use this message when the tab control is empty.

    The application-defined data is specified by the lParam member of the TCITEM structure. If you use more than 4 bytes of application-defined data, you need to define your own structure and use it instead of TCITEM. You can retrieve and set application-defined data the same way you retrieve and set other information about a tab—by using the TCM_GETITEM and TCM_SETITEM messages.

    For more information, please refer to this document.

    https://msdn.microsoft.com/en-us/library/windows/desktop/bb760550%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396#tab_attributes

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    • Proposed as answer by Baron Bi Monday, October 10, 2016 6:17 AM
    • Marked as answer by Hart WangModerator Monday, October 10, 2016 6:20 AM
    Wednesday, September 28, 2016 6:44 AM

All replies

  • Each tab is a class with access to a settings class that keeps track of all the settings maybe?
    Tuesday, September 27, 2016 1:17 PM
  • Why not use CPropertySheet and CPropertyPage? This is usually much easier than using the tab control.

    Each tab will have its own CPropertyPage-derived class.


    David Wilkinson | Visual C++ MVP

    Tuesday, September 27, 2016 2:46 PM
  • Hi MayankAg,

    thanks for posting here.

    >>Weather I make 1 individual class for each tab, to store the settings done by the user on that page? Or should I create 1 class to storing all the tab settings done by user?

    Which settings are you going to store?

    If you want to store user defined data type, I suggest you a base class and one derived class for each tab. Store the general settings in derived class and specific settings for each tab.

    Actually you could associate application-defined data with each tab. For example, you might save information about each page with its corresponding tab. By default, a tab control allocates four extra bytes per tab for application-defined data. You can change the number of extra bytes per tab by using the TCM_SETITEMEXTRA message. You can only use this message when the tab control is empty.

    The application-defined data is specified by the lParam member of the TCITEM structure. If you use more than 4 bytes of application-defined data, you need to define your own structure and use it instead of TCITEM. You can retrieve and set application-defined data the same way you retrieve and set other information about a tab—by using the TCM_GETITEM and TCM_SETITEM messages.

    For more information, please refer to this document.

    https://msdn.microsoft.com/en-us/library/windows/desktop/bb760550%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396#tab_attributes

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    • Proposed as answer by Baron Bi Monday, October 10, 2016 6:17 AM
    • Marked as answer by Hart WangModerator Monday, October 10, 2016 6:20 AM
    Wednesday, September 28, 2016 6:44 AM