Click here to Skip to main content
15,892,575 members
Articles / Programming Languages / C#

Using the Windows 2000/XP Object Selection Dialog

Rate me:
Please Sign up or sign in to vote.
4.92/5 (29 votes)
21 Nov 2005CPOL14 min read 251.3K   4.5K   57  
This article describes how to use the "Select Users or Groups" system dialog.
/*
	$Workfile:$
	$Header:$

	Copyright � 2002 Friedrich Brunzema
	All rights reserved.

	@doc
	@module AdvancedProperties.cpp - Advanced Properties Dialog |

	Revision History:
		2002-12-31	Initial Rev

	$Log$ 
*/

#include "stdafx.h"
#include "objsel.h"
#include "SelectUsersOrGroups.h"
#include "AdvancedProperties.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/*
	Name:				CAdvancedProperties::CAdvancedProperties
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Constructor
	@parm 				CWnd*	 | pParent	 | Parent window
*/
CAdvancedProperties::CAdvancedProperties(CWnd* pParent)
	: CDialog(CAdvancedProperties::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAdvancedProperties)
	//}}AFX_DATA_INIT

	// initial settings for the checkboxes(all bits set)
	m_flOptions = 0;
	m_dlgScopeType.m_flags	= DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | 
								DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN | 
								DSOP_SCOPE_TYPE_GLOBAL_CATALOG |
								DSOP_SCOPE_TYPE_ENTERPRISE_DOMAIN |
								DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN |
								DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN |
								DSOP_SCOPE_TYPE_TARGET_COMPUTER |
								DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE |
								DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE;
	m_dlgBoth.m_flags		= DSOP_FILTER_USERS | DSOP_FILTER_GLOBAL_GROUPS_DL;
	m_dlgMixed.m_flags		= 0x0;
	m_dlgNative.m_flags		= 0x0;
	m_dlgDownLevel.m_flags  = DSOP_DOWNLEVEL_FILTER_USERS | DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS;;
	m_dlgScopeFlag.m_flags  = DSOP_SCOPE_FLAG_WANT_PROVIDER_WINNT | DSOP_SCOPE_FLAG_DEFAULT_FILTER_USERS |
								DSOP_SCOPE_FLAG_DEFAULT_FILTER_GROUPS | DSOP_SCOPE_FLAG_STARTING_SCOPE;

}

/*
	Name:				CAdvancedProperties::DoDataExchange
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		For Data Exchange
	@parm 				CDataExchange*	 | pDX	 | A pointer to a Data Exchange Thingy Class
	@rdesc				void - n/a
*/
void CAdvancedProperties::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAdvancedProperties)
	DDX_Control(pDX, IDC_STATIC_SCOPE, m_staticScope);
	DDX_Control(pDX, IDC_DOWNLEVEL, m_staticDownLevel);
	DDX_Control(pDX, IDC_NATIVE_ONLY, m_staticNative);
	DDX_Control(pDX, IDC_MIXED_MODE, m_staticMixed);
	DDX_Control(pDX, IDC_BOTH_MODES, m_staticBoth);
	DDX_Control(pDX, IDC_SCOPE_TYPE_FLAGS, m_staticScopeType);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAdvancedProperties, CDialog)
	//{{AFX_MSG_MAP(CAdvancedProperties)
	ON_BN_CLICKED(IDC_SCOPE_TYPE_BUTTON, OnScopeTypeButton)
	ON_BN_CLICKED(IDOK2, OnOk2)
	ON_BN_CLICKED(IDCANCEL2, OnCancel2)
	ON_BN_CLICKED(IDC_UPLEVEL_FILTER_FLAGS_BOTH, OnUplevelFilterFlagsBoth)
	ON_BN_CLICKED(IDC_UPLEVEL_FILTER_FLAGS_MIXED, OnUplevelFilterFlagsMixed)
	ON_BN_CLICKED(IDC_UPLEVEL_FILTER_FLAGS_NATIVE, OnUplevelFilterFlagsNative)
	ON_BN_CLICKED(IDC_DOWNLEVEL_FILTER, OnDownlevelFilter)
	ON_BN_CLICKED(IDC_SCOPE_FLAGS, OnScopeFlags)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/*
	Name:				CAdvancedProperties::OnInitDialog
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Called before the dlg is shown
	@rdesc				BOOL - return TRUE
*/
BOOL CAdvancedProperties::OnInitDialog() 
{
	CString str;

	CDialog::OnInitDialog();

	str.Format(_T("0x%08lx"), m_dlgScopeType.m_flags);
	m_staticScopeType.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgScopeFlag.m_flags);
	m_staticScope.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgBoth.m_flags);
	m_staticBoth.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgMixed.m_flags);
	m_staticMixed.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgNative.m_flags);
	m_staticNative.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgNative.m_flags);
	m_staticNative.SetWindowText(str);

	str.Format(_T("0x%08lx"), m_dlgDownLevel.m_flags);
	m_staticDownLevel.SetWindowText(str);

	if (m_flOptions & DSOP_FLAG_MULTISELECT)
		((CButton*)GetDlgItem(IDC_MULTISELECT))->SetCheck(TRUE);

	if (m_flOptions & DSOP_FLAG_SKIP_TARGET_COMPUTER_DC_CHECK)
		((CButton*)GetDlgItem(IDC_DC_CHECK))->SetCheck(TRUE);

	
	return TRUE; 
}


/*
	Name:				CAdvancedProperties::OnOk2
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles the OK Button
		
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnOk2() 
{
	
	// pick up the optional settings
	if (((CButton*)GetDlgItem(IDC_MULTISELECT))->GetCheck())
		m_flOptions |= DSOP_FLAG_MULTISELECT;

	// pick up the second one
	if (((CButton*)GetDlgItem(IDC_DC_CHECK))->GetCheck())
		m_flOptions |= DSOP_FLAG_SKIP_TARGET_COMPUTER_DC_CHECK;

	EndDialog(0);	
}



/*
	Name:				CAdvancedProperties::OnCancel2
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles the Cancel Button
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnCancel2() 
{
	EndDialog(IDCANCEL);	
}


/*
	Name:				CAdvancedProperties::OnScopeTypeButton
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles Scope Type Button
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnScopeTypeButton() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog
	
	// show the dialog
	nRet = m_dlgScopeType.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgScopeType.m_flags);

		// set the string in the static field
		m_staticScopeType.SetWindowText(str);
	}

}



/*
	Name:				CAdvancedProperties::OnUplevelFilterFlagsBoth
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles Filter Flags Both button
		
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnUplevelFilterFlagsBoth() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog

	// show the dialog
	nRet = m_dlgBoth.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgBoth.m_flags);

		// set the string in the static field
		m_staticBoth.SetWindowText(str);
	}
}



/*
	Name:				CAdvancedProperties::OnUplevelFilterFlagsMixed
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles Filter Flags Mixed button
		
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnUplevelFilterFlagsMixed() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog

	// show the dialog
	nRet = m_dlgMixed.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgMixed.m_flags);

		// set the string in the static field
		m_staticMixed.SetWindowText(str);
	}	
}



/*
	Name:				CAdvancedProperties::OnUplevelFilterFlagsNative
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles the Native Button
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnUplevelFilterFlagsNative() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog

	// show the dialog
	nRet = m_dlgNative.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgNative.m_flags);

		// set the string in the static field
		m_staticNative.SetWindowText(str);
	}	
}



/*
	Name:				CAdvancedProperties::OnDownlevelFilter
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		Handles the Downlevel Filter button
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnDownlevelFilter() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog

	// show the dialog
	nRet = m_dlgDownLevel.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgDownLevel.m_flags);

		// set the string in the static field
		m_staticDownLevel.SetWindowText(str);
	}
}


/*
	Name:				CAdvancedProperties::OnScopeFlags
	Type:				Protected
	Override:			No
	@mfunc
	Description:
		When we hit the Scope Flags button
	@rdesc				void - n/a
*/
void CAdvancedProperties::OnScopeFlags() 
{
	CString		str;		// display string
	int			nRet;		// return from dialog

	// show the dialog
	nRet = m_dlgScopeFlag.DoModal();
	if (IDOK == nRet)
	{
		// format a hex representation of the bit pattern
		str.Format(_T("0x%08lx"), m_dlgScopeFlag.m_flags);

		// set the string in the static field
		m_staticScope.SetWindowText(str);
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) AB SCIEX
Canada Canada
I was born and grew up in Northern Germany grew up in Quebec in a French Language environment. I finished High School in Fergus, Ontario. After a 4 year training as a Pipe Organ Builder in Germany, I returned to Canada to get a B.Sc. in Computer Science. I'm currently working for a company called AB SCIEX working on Mass Spectrometer Software, am married, and have three often wonderful children. What you believe in matters - I am a follower of Jesus Christ - we attend a German-Lutheran congregation in downtown Toronto.

Comments and Discussions