Solved

Adding tabs to the MainFrame in an MDI application.

Posted on 1998-08-04
5
550 Views
Last Modified: 2013-11-19
I have an MDI application and would like to add tabs to the MainFrame (the CMDIFrameWnd derived class) so that the child windows are added to the tab control without losing the other MDI functionality (cascade, tile, etc).  This would create a "workbook" feel in the MDI application. The tabs would act just like selcting a child window from the "Window" menu. I've tried changing the window class to "SysTabControl32" in the CREATESTRUCT but have had no luck. Has anyone tried this or have any ideas? I've been told that there are some software packages available that can extend MFC in this manner, unfortunately my funds are very limited.  Thanks for any help.
0
Comment
Question by:westine
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Andy_Keys earned 100 total points
ID: 1320263
the best way I've found is to write a resizeable prortertysheet so and use that to determine the size then resize each page to match it.  You can then trap the WM_Size in each page and resize the contols etc.  If you need help with the resizeable property sheet let me know.
0
 

Author Comment

by:westine
ID: 1320264
Hi Andy,  Thanks for the quick response.  Will the other MDI features work the same with this solution?  For instance, if the MDIFrameWnd works like a tab control will selecting Window->Tile from the main menu still tile the child windows within the Frame/TabControl and then selecting a tab would just give the related child window focus (likewise, when the child windows are maximized, selecting a tab will display that child window)?  If so, this sounds a solution I can use. Also, I would appreciate any help with the resizeable property sheet...  Thanks, Jim
0
 
LVL 1

Expert Comment

by:Andy_Keys
ID: 1320265
What I would do is to create a FormView that has no contorls on it and add a ResizePropertySheet as a member that get created in the OnInit override.  Then also overide the ONSize to resize it to fill the form.  This keep the Doc-view architecture.
following is the code for a resize Property Sheet.  You may not need all of it as it also modify style etc to make it have resize boder which you will not require.
// ResizePropertySheet.cpp : implementation file
//
 
#include "stdafx.h"
#include "ResizePropertySheet.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
#define  TOP_OFFSET   (30)
#define  LEFT_OFFSET   (10)
#define  BOTTOM_OFFSET  (8)
#define  RIGHT_OFFSET  (8)
 
/////////////////////////////////////////////////////////////////////////////
// CResizePropertySheet
 
IMPLEMENT_DYNAMIC(CResizePropertySheet, CPropertySheet)
 
CResizePropertySheet::CResizePropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
 :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
 
CResizePropertySheet::CResizePropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
 :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
}
 
CResizePropertySheet::~CResizePropertySheet()
{
}
 

BEGIN_MESSAGE_MAP(CResizePropertySheet, CPropertySheet)
 //{{AFX_MSG_MAP(CResizePropertySheet)
 ON_WM_SIZE()
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CResizePropertySheet message handlers
 

void CResizePropertySheet::PreSubclassWindow()
{
 ModifyStyle ( 0, WS_SIZEBOX);
 CPropertySheet::PreSubclassWindow();
}
 
void CResizePropertySheet::OnSize(UINT nType, int cx, int cy)
{
 CPropertySheet::OnSize(nType, cx, cy);
 
 CRect   WinRect;
 CRect   TabWinRect;
 CTabCtrl  *pTabCtrl;
 CPropertyPage *pPage;
 unsigned int a,ct;
 
 GetWindowRect( &WinRect );
 pTabCtrl = GetTabControl();
 if(NULL != pTabCtrl)
 {
  WinRect.top += TOP_OFFSET;
  WinRect.left += LEFT_OFFSET;
  WinRect.right -= RIGHT_OFFSET;
  WinRect.bottom -= BOTTOM_OFFSET;
  ScreenToClient( &WinRect );
  pTabCtrl->MoveWindow( &WinRect );
  pTabCtrl->AdjustRect( FALSE, &WinRect );
 
  ct = m_pages.GetSize();
  for(a = 0; a < ct; a++)
  {
   pPage = (CPropertyPage*)m_pages[a];
   if( NULL != pPage->m_hWnd )
   {
    pPage->MoveWindow( &WinRect );
    //pPage->SendMessage( WM_SIZE, SIZE_RESTORED, MAKELONG( WinRect.Width(), WinRect.Height() ) );
   }
  }
 }
}
 

void CResizePropertySheet::HideAllButtons()
{
 unsigned int idButtons[] = {IDOK,IDCANCEL,ID_APPLY_NOW,ID_WIZBACK,ID_WIZNEXT,ID_WIZFINISH};
 

 CWnd   *pWnd;
 unsigned int  a,ct;
 

 ct = sizeof(idButtons) / sizeof(idButtons[0]);
 for(a = 0; a < ct ; a++)
 {
  pWnd = GetDlgItem( idButtons[a] ) ;
  if( NULL != pWnd )
  {
   pWnd->ShowWindow( FALSE );
  }
 }
}
 
BOOL CResizePropertySheet::OnInitDialog()
{
 BOOL bResult = CPropertySheet::OnInitDialog();
 CTabCtrl   *pTabCtrl;
 CRect    WinRect;
 
 HideAllButtons();
 GetWindowRect( &WinRect );
 pTabCtrl = GetTabControl();
 if( NULL != pTabCtrl )
 {
  WinRect.top += TOP_OFFSET;
  WinRect.left += LEFT_OFFSET;
  WinRect.right -= RIGHT_OFFSET;
  WinRect.bottom -= BOTTOM_OFFSET;
  ScreenToClient( &WinRect );
  pTabCtrl->MoveWindow( &WinRect );
 }
 return bResult;
}

0
 

Author Comment

by:westine
ID: 1320266
Thanks Andy!  I'll give this a shot and see if it does the trick.
0
 

Author Comment

by:westine
ID: 1320267
Thanks Andy...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
Separate files macro - Errors on larger data set 18 73
fizzArray2 challenge 1 91
java ^ examples 8 69
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question