Solved

CPropertySheet vs. CTabCtrl

Posted on 2000-02-28
3
1,273 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 30

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 30

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now