Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easiest way to create tabs

Status
Not open for further replies.

victor7

Programmer
Jul 30, 2002
11
0
0
US
The project I'm working on has a window split into two frames. the left frame has buttons which then display different forms on the right frame. So instead of having buttons I want to be able to switch between the pages using tabs. The pages that are displayed on the right frame are of type CFormView. What would be a simple implementation? Any thoughts would be greatly appreciated.

Thanks
 
You might want to look into "PropertySheet" ..... there are numerous examples I found online "Piperopoulos Panagiotis"

here's one by


#include <afxwin.h>
#include <afxdlgs.h>
#include &quot;resource.h&quot;

class CSheet : public CPropertySheet
{
public:

CPropertyPage Page1;
CPropertyPage Page2;
CPropertyPage Page3;
CPropertyPage Page4;
CMenu Menu;

CSheet() : CPropertySheet( &quot;CPropertySheet By Piperopoulos Panagiotis&quot; )
{
Page1.Construct( IDD_VIEW1 );
Page2.Construct( IDD_VIEW2 );
Page3.Construct( IDD_VIEW3 );
Page4.Construct( IDD_VIEW4 );
AddPage( &Page1 );
AddPage( &Page2 );
AddPage( &Page3 );
AddPage( &Page4 );
}

~CSheet(){}

BOOL OnInitDialog( )
{
CPropertySheet::OnInitDialog();

GetDlgItem( IDOK )->ShowWindow( SW_HIDE );
GetDlgItem( IDCANCEL )->ShowWindow( SW_HIDE );
GetDlgItem( ID_APPLY_NOW )->ShowWindow( SW_HIDE );

Menu.LoadMenu( IDR_MENU );
SetMenu( &Menu );

// NEW LINES START

// Load the app icons
SetIcon( AfxGetApp()->LoadIcon( IDI_ICONS ), FALSE );
SetIcon( AfxGetApp()->LoadIcon( IDI_ICONB ), TRUE );

// add the minimize button to the window
::SetWindowLong( m_hWnd, GWL_STYLE, GetStyle() | WS_MINIMIZEBOX );

// add the minimize command to the system menu
GetSystemMenu( FALSE )->InsertMenu( -1, MF_BYPOSITION | MF_STRING,
SC_ICON, &quot;Minimize&quot; );

// activate the new sysmenu
DrawMenuBar();

// NEW LINES END

return TRUE;
}

void DisplayPage( int Page )
{
switch( Page )
{
case IDM_1 :
SetActivePage( &Page1 );
break;
case IDM_2 :
SetActivePage( &Page2 );
break;
case IDM_3 :
SetActivePage( &Page3 );
break;
case IDM_4 :
SetActivePage( &Page4 );
break;
}
}

DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP( CSheet, CPropertySheet )
ON_COMMAND_RANGE( IDM_1, IDM_4, DisplayPage )
END_MESSAGE_MAP()


class TheApp : public CWinApp
{
public:

TheApp(){}
~TheApp(){}

virtual BOOL InitInstance()
{
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif

CSheet ps;
m_pMainWnd = &ps;
ps.DoModal();

return FALSE;
}
};

TheApp MyApp;
 
Thank you so much. I've been stuck on this for a while and kind of put it off to the side to work on some other stuff. Hopefully it'll work for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top