Tab control can also be added to any Window class (e.g. a CWnd derived class), however VC++ does not provide any visual way to do so, everything has to be done by writing code.
(2) Click on the "Win32" tab of the RadVC toolbox and select the tool button "CRtabCtrl"
(3) Drop an instance of the tab control inside the form.
(4) Now is the time to create tab pages for our control. In RadVC, any control can qualify to be a tab page. However, since we want our tab pages to "contain" other controls, so we will use RAD C++ controls as tab pages.
Creating a skeleton RAD C++ control is extremely easy. First right-click on anywhere on the RadVC toolbox, and select the context menu item "Create New C++ Control". This will bring a dialog as shown below. In this dialog, change the name of the new RAD C++ control to something like "CTabPage1". Optionally, you can also change the bitmap of the new control by clicking on the "Edit.." button.
One important note is that we will not check the checkbox "Add to Control Repository" in the dialog. This is so, because we want our tab pages to be part of our project only. Checking this checkbox would have placed the tab page in the RadVC control repository, which in turn makes it available to all VC++ projects.
Now click on the "OK" button. This will create a new control in your project and add a tool icon on the RadVC toolbox. In addition to this, RadVC will display a blank form inside Developer Studio's client area as shown below.
(5) The blank form represents the control (CTabPage1) we have just created and will serve as our first tab page. You can now design this page by adding other controls from RadVC toolbox to this form (as shown below).
(6) Follow steps (4) and (5) to create additional pages for our tab control. Each time you create a tab page, you will see a corresponding icon on the RadVC toolbox. For this tutorial, we have created two tab pages called "CTabPage1" and "CTabPage2". They are shown by two icons "T1" and "T2" respectively on the RadVC toolbox.
(7) Now open the main form again and create two instances of the tab pages, we have just created. The main form will look something like this:
You shouldn't be worried about the location and sizes of the tab page control on the form. During runtime, the tab control will position and stretch the pages so that they all fit inside the client area of the tab control.
(8) To add the tab page to the tab control, simply right-click on the tab page icon and select "Add To > m_RTabCtrl" menu item as shown below. RadVC will add necessary code in the form's "Load" event handler. In case if the main form is a VC++ wizard - generated view class, RadVC will insert the code inside the view's "OnCreate(..)" message handler.
After inserting the code, RadVC will open the form's implementation file (form1.cpp, in our case) and highlight the "Form_Load" event handler.
(9) At this stage, you may want to modify the "AddItem" function call to specify the caption of the newly added tab page. The code will look something like this:
(10) Follow steps (8) and (9) to add tab page 2 to the tab control.
Now build the project and run.
|[ Home ][ Order Now ][Feedback][ Contact Us ][ About CapitolSoft ]|
|[ Features ][ Tutorial ][ Samples ][ F.A.Q.s ][ Download ][ CDK ]|