Solved

CPropertySheet vs. CTabCtrl

Posted on 2000-02-28
3
1,289 Views
Last Modified: 2013-11-20
I'm making a new application..
I want the main window to be a Dialog, which consists of a CListCtrl, and a CPropertySheet (or CTabCtrl).

The Tab-window should consist of three different dialogs.

How do I do this?? Does anyone have some sample source??


Eks. of Dialog :

--------------------------------
|  ---------------------       |
|  | List              |       |
|  ---------------------       |
|  |                   |       |
|  |                   |       |
|  ---------------------       |
|                              |
|  ---- ---- ----              |
|  |D1| |D2| |D3|              |
|  |   ---------------------   |
|  |                       |   |
|  |                       |   |
|  |     Tab-Dialog 1      |   |
|  |                       |   |
|  |                       |   |
|  -------------------------   |
|                              |
--------------------------------
0
Comment
Question by:lar_jens
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 280 total points
ID: 2565189
Hi lar_jens,

try it like this:

1. Create your dialog resource including the list and the tab control and add a picture control with id IDC_STATIC_DUMMY of wanted size and position of the child dialogs within the tab control and remove the 'Visible' style.

2. Create the three child dialogs with style 'Child', no border and no caption.

3. Create classes for these dialogs, e.g. CTabDlg, CMyDlg1, CMyDlg2, CMyDlg3.

4. In CTabDlg do following:
-add a CTabCtrl member for the tab control with ClassWizard, i.e. m_tab

// In header file CTabDlg.h
#include "MyDlg1.h"
#include "MyDlg2.h"
#include "MyDlg3.h"

class CTabDlg...
{
 ...
 CMyDlg1* m_pDlg1;
 CMyDlg2* m_pDlg2;
 CMyDlg3* m_pDlg3;

 void ShowChild( int id );
....
}

// In implementation file CTabDlg.cpp
// Override OnInitialUpdate()
BOOL CTabDlg::OnInitDialog()
{
 CDialog::OnInitDialog();
      
 // create new dialogs
 m_pDlg1 = new CMyDlg1;
 m_pDlg2 = new CMyDlg2;
 m_pDlg3 = new CMyDlg3;

 m_pDlg1->Create( CMyDlg1::IDD, this );
 m_pDlg2->Create( CMyDlg2::IDD, this );
 m_pDlg3->Create( CMyDlg3::IDD, this );

 // position childs
 CRect rect;
 GetDlgItem( IDC_STATIC_DUMMY )->GetWindowRect( rect );
 ScreenToClient( rect );

 m_pDlg1->MoveWindow( rect );
 m_pDlg2->MoveWindow( rect );
 m_pDlg3->MoveWindow( rect );

 // insert tab control items
 m_tab.InsertItem( 0, "Dialog 1" );
 m_tab.InsertItem( 1, "Dialog 2" );
 m_tab.InsertItem( 2, "Dialog 3" );

 ShowChild( 0 );
 return TRUE;
}

void CTabDlg::ShowChild( int id )
{
 m_pDlg1->ShowWindow( ( id == 0 ) ? SW_SHOW : SW_HIDE );
 m_pDlg2->ShowWindow( ( id == 1 ) ? SW_SHOW : SW_HIDE );
 m_pDlg3->ShowWindow( ( id == 2 ) ? SW_SHOW : SW_HIDE );
}

// add TCN_SELCHANGE notification message handler with ClassWizard
void CTabDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
 int id = m_tab.GetCurSel();

 ShowChild( id );

 *pResult = 0;
}

// cleanup
BOOL CTabDlg::DestroyWindow()
{
 m_pDlg1->DestroyWindow();      
 delete m_pDlg1;
 m_pDlg2->DestroyWindow();      
 delete m_pDlg2;
 m_pDlg3->DestroyWindow();      
 delete m_pDlg3;

 return CDialog::DestroyWindow();
}

handle child dialog's data exchange within overriden CTabDlg::OnOK() ...

hope that helps,

ZOPPO
0
 
LVL 1

Author Comment

by:lar_jens
ID: 2565536
Thnx..

I'm sorry but I haven't got the time to evaluate your answer, but it souds sain enough to me..

Thanks for the tip (right now, I'm trying another solution involving propertypages, but I'll get back to this one)...

0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2565557
you're welcome    :)

you can take a look at http://www.codeproject.com/property/saprefs.asp, there you can find source code for making property sheet similar to i.e. netscape's options dialog (with the tree instead of the tab buttons). Perhaps this is a useful sample for you.

have a nice day,

ZOPPO
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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