Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

System Dialogs

, , 21 Aug 2004
This article shows you a very simple way to show system dialogs like Internet Options, Add/Remove Programs, and etc.
systemdialogs_demo.zip
res
SystemDialogs_Demo.ico
Release
SystemDialogs_Demo.exe
SystemDialogs_Demo.clw
SystemDialogs_Demo.dsp
SystemDialogs_Demo.dsw
systemdialogs_src.zip
// SystemDialogs_DemoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SystemDialogs_Demo.h"
#include "SystemDialogs_DemoDlg.h"
#include "SystemDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSystemDialogs_DemoDlg dialog

CSystemDialogs_DemoDlg::CSystemDialogs_DemoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSystemDialogs_DemoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSystemDialogs_DemoDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSystemDialogs_DemoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSystemDialogs_DemoDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSystemDialogs_DemoDlg, CDialog)
	//{{AFX_MSG_MAP(CSystemDialogs_DemoDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_ADD_REMOVE_PROGRAM, OnAddRemoveProgram)
	ON_BN_CLICKED(IDC_DATE_TIME, OnDateTime)
	ON_BN_CLICKED(IDC_DEVICE_MANAGER, OnDeviceManager)
	ON_BN_CLICKED(IDC_DISPLAY, OnDisplay)
	ON_BN_CLICKED(IDC_FORMAT, OnFormat)
	ON_BN_CLICKED(IDC_GAME_CONTROLERS, OnGameControlers)
	ON_BN_CLICKED(IDC_INTERNET_OPTION, OnInternetOption)
	ON_BN_CLICKED(IDC_KEYBOARD, OnKeyboard)
	ON_BN_CLICKED(IDC_MODEM, OnModem)
	ON_BN_CLICKED(IDC_MOUSE, OnMouse)
	ON_BN_CLICKED(IDC_MULTIMEDIA, OnMultimedia)
	ON_BN_CLICKED(IDC_NETWORK, OnNetwork)
	ON_BN_CLICKED(IDC_PASSWORD, OnPassword)
	ON_BN_CLICKED(IDC_REGIONAL_SETTINGS, OnRegionalSettings)
	ON_BN_CLICKED(IDC_SOUND, OnSound)
	ON_BN_CLICKED(IDC_SYSTEM, OnSystem)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSystemDialogs_DemoDlg message handlers

BOOL CSystemDialogs_DemoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSystemDialogs_DemoDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSystemDialogs_DemoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CSystemDialogs_DemoDlg::OnAddRemoveProgram() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_ADD_REMOVE_PROGRAMS, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnDateTime() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_DATE_TIME, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnDeviceManager() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_DEVICE_MANAGER, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnDisplay() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_DISPLAY, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnFormat() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_FORMAT, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnGameControlers() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_GAME_CONTROLLERS, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnInternetOption() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_INTERNET_OPTIONS, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnKeyboard() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_KEYBOARD, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnModem() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_MODEM, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnMouse() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_MOUSE, m_hWnd);	
}

void CSystemDialogs_DemoDlg::OnMultimedia() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_MULTIMEDIA, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnNetwork() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_NETWORK, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnPassword() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_PASSWORD, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnRegionalSettings() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_REGIONAL_SETTINGS, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnSound() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_SOUNDS, m_hWnd);
}

void CSystemDialogs_DemoDlg::OnSystem() 
{
	CSystemDialog dlg;
	dlg.DoModal(SD_SYSTEM, m_hWnd);
}

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

Share

About the Authors

A. Riazi
CEO Misbah3Com
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acqusition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competetion, my articles are:

You can see list of my articles, by clicking here


Shafiee
Web Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 22 Aug 2004
Article Copyright 2004 by A. Riazi, Shafiee
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid