Solved

CPropertySheet vs. CTabCtrl

Posted on 2000-02-28
3
1,322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

695 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