?
Solved

CPropertySheet vs. CTabCtrl

Posted on 2000-02-28
3
Medium Priority
?
1,332 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 1120 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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