Click here to Skip to main content
15,892,298 members
Articles / Desktop Programming / ATL

"Select Computer" Dialog

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
16 Apr 20013 min read 203K   4.4K   36  
The ATL and MFC versions of the class that implements a dialog for selecting users(computers) within the Windows Network.
#if !defined(AFX_SELECTCOMPUTERDIALOG_H__B4DBF4AF_B19D_4862_8507_0B086375B309__INCLUDED_)
#define AFX_SELECTCOMPUTERDIALOG_H__B4DBF4AF_B19D_4862_8507_0B086375B309__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SelectComputerDialog.h : header file
//
#include "stdafx.h"

#pragma warning(push)
#pragma warning(disable : 4786)

//resources
#include "SelectComputerResource.h"

#include "SelectComputerNetwork.h"
#include "Sizer.h"

//std lib
#include <vector>
#include <string>
#include <utility>
//~std lib

using namespace std;

/////////////////////////////////////////////////////////////////////////////
// CSelectComputerDialog dialog

class CSelectComputerDialog : public CDialog
{
// Construction
public:
	CSelectComputerDialog(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(CSelectComputerDialog)
	enum { IDD = IDD_SELECT_COMPUTER };
	CListCtrl	m_lstComputers;
	CComboBoxEx	m_cmbLookIn;
	CButton	m_btnOK;
	CButton m_btnCancel;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSelectComputerDialog)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CSelectComputerDialog)
	afx_msg void OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult);
	virtual BOOL OnInitDialog();
	afx_msg void OnSelchangeCombo();
	afx_msg void OnPaint();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnDropdownCombo();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

public:
	const pair<CString, CString> & GetComputerName() const
	{
		return m_Names[0];
	}

	const vector<pair<CString, CString> >& GetComputerNames() const
	{
		return m_Names;
	}

	bool SingleSelection(bool bSelectionMode = true)
	{	
		bool tmp = m_bSingleSelection;
		m_bSingleSelection = bSelectionMode;
		
		return tmp;
	}

	bool NoALLDomain(bool bOnlyOneDomainInTime = true)
	{
		bool tmp = m_bOnlyOneDomainInTime;
		m_bOnlyOneDomainInTime = bOnlyOneDomainInTime;

		return tmp;
	}

private:
	vector<pair<CString, CString> > m_Names;
	bool	m_bSingleSelection;
	bool	m_bOnlyOneDomainInTime;

private:
	void RefreshListControl(const basic_string<TCHAR>& strDomain);

private:
	bool InitComboBox();
	void InitListControl();
	void InitResizeService();

	vector<basic_string<TCHAR> > m_vecstrDomains;
	vector<basic_string<TCHAR> > m_vecstrServers;

	CSelectComputerNetwork		m_Network;
	CImageList					m_imagelist;

	auto_ptr<CSizerCollection> m_pSizerCollection;	
};

#pragma warning(pop)

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SELECTCOMPUTERDIALOG_H__B4DBF4AF_B19D_4862_8507_0B086375B309__INCLUDED_)

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Other
Australia Australia
Igor Sukhov is %a someone who can take your project from user requirements to successfull completion% residing in Sydney, NSW, Australia.

Igor has been working on design, development and maintenance (surprise!) of many large-scale business-critical enterprise applications.

Igor holds MS degree in Computer Science/Applied Mathematics from Kazan State University.

MCAD .NET

Tag cloud:

.NET 2.0

C#

Business applications

Design

Enterprise applications

Development

Sydney


Comments and Discussions