www.pudn.com > ComputerInformation.zip > KeyBoardInfoPage.cpp


// Disclaimer and Copyright Information 
// Pardesi Services LLC.  Copyright (c) 2001 
//						  All rights reserved. 
// KeyBoardInfoPage.cpp : implementation file 
// 
// All rights reserved. 
// 
// Written by Naveen K Kohli (naveenkohli@netzero.net) 
// Version 1.0 
// 
// Distribute freely, except: don't remove my name from the source or 
// documentation (don't take credit for my work), mark your changes (don't 
// get me blamed for your possible bugs), don't alter or remove this 
// notice. 
// No warrantee of any kind, express or implied, is included with this 
// software; use at your own risk, responsibility for damages (if any) to 
// anyone resulting from the use of this software rests entirely with the 
// user. 
// 
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to 
// naveenkohli@netzero.net 
/////////////////////////////////////////////////////////////////////////////// 
 
// Revision History: 
//	4/16/2001	Initial Creation 
// 
 
 
#include "stdafx.h" 
#include "SystemApplication.h" 
#include "KeyBoardInfoPage.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// KeyBoardInfoPage property page 
 
IMPLEMENT_DYNCREATE(KeyBoardInfoPage, CPropertyPage) 
 
KeyBoardInfoPage::KeyBoardInfoPage() : CPropertyPage(KeyBoardInfoPage::IDD) 
{ 
	//{{AFX_DATA_INIT(KeyBoardInfoPage) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
KeyBoardInfoPage::~KeyBoardInfoPage() 
{ 
} 
 
void KeyBoardInfoPage::DoDataExchange(CDataExchange* pDX) 
{ 
	CPropertyPage::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(KeyBoardInfoPage) 
	DDX_Control(pDX, IDC_KEYBOARD_INFO_LIST, m_wndListCtrl); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(KeyBoardInfoPage, CPropertyPage) 
	//{{AFX_MSG_MAP(KeyBoardInfoPage) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// KeyBoardInfoPage message handlers 
 
BOOL KeyBoardInfoPage::OnInitDialog()  
{ 
	CPropertyPage::OnInitDialog(); 
	 
	ISystemInformation4 *pSysInfo4 = NULL; 
 
	if (FAILED (m_pSystemInfo->QueryInterface (IID_ISystemInformation4, 
		reinterpret_cast(&pSysInfo4)))) 
	{ 
		return FALSE; 
	} 
	if (FAILED (pSysInfo4->GetKeyboardInfo (&m_bstrType, &m_nFunctionKeys))) { 
		pSysInfo4->Release (); 
		return FALSE; 
	} 
	 
	SetListData(); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void KeyBoardInfoPage::SetListData() 
{ 
	CString tmpStr; 
	LV_ITEM item; 
	LV_COLUMN leftCol, rightCol; 
 
	leftCol.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; 
	leftCol.fmt = LVCFMT_LEFT; 
	leftCol.iSubItem = 0; 
	leftCol.cx = 130; 
	leftCol.pszText = _T ("Parameter"); 
 
	rightCol.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; 
	rightCol.fmt = LVCFMT_LEFT; 
	rightCol.iSubItem = 1; 
	rightCol.cx = 225; 
	rightCol.pszText = _T ("Value"); 
 
	m_wndListCtrl.InsertColumn (0, &leftCol); 
	m_wndListCtrl.InsertColumn (1, &rightCol); 
 
	item.mask = LVIF_TEXT; 
	item.iItem = 0; 
	item.iSubItem = 0; 
	item.pszText = _T ("Type:"); 
	m_wndListCtrl.InsertItem (&item); 
	tmpStr = this->m_bstrType; 
	m_wndListCtrl.SetItemText (0, 1, tmpStr); 
 
	item.iItem = 1; 
	item.pszText = _T ("Function Keys:"); 
	m_wndListCtrl.InsertItem (&item); 
	tmpStr.Format (_T ("%d"), this->m_nFunctionKeys); 
	m_wndListCtrl.SetItemText (1, 1, tmpStr); 
}