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

A comprehensive CE class library to replace ATL and MFC

, 4 Oct 2000 CPOL
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.
kgwince-old.zip
WinCe
BeamEx
app.ico
BeamEx.dsp
BeamEx.dsw
BeamEx.ini
BeamEx.plg
bitmap1.bmp
bmp00001.bmp
bmp00002.bmp
calc.bmp
calc16.bmp
circ_cross.ico
cir_cross.ico
cross_4.ico
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico00005.ico
ico00008.ico
ico00009.ico
ico00010.ico
icon1.ico
icon2.ico
icon4.ico
id_downl.bmp
Install
BeamEx.inf
BeamEx.ini
BeamEx.MIPS_PPCBW.CAB
BeamEx.MIPS_PPCColor.CAB
BeamEx.SH3_PPCColor.CAB
Setup.exe
i_cross.ico
l_cross.ico
magenic.ico
mssccprj.scc
obl_corss.ico
obl_cross.ico
options.bmp
options1.bmp
ping16.bmp
rect_cross.ico
scene_5.ico
scene_6.ico
tri_cross.ico
vssver.scc
CeLib
CeLabel.inl
CeLib.aps
CeLib.dsp
CeLib.dsw
CeLib.old
CeLib.plg
CeLib.vcp
CeMisc.inl
CeProperty.inl
CeTab.inl
CeWnd.inl
mssccprj.scc
vssver.scc
WinLib.dsp
WinLib.dsw
dbView
bitmap1.bmp
bmp00001.bmp
db5.bmp
dbView.aps
DbView.dsp
dbView.dsw
dbView.old
dbView.plg
DbView.vcp
deldb.bp2
deldb5.bmp
delrec.bp2
delrecor.bmp
help16.bmp
help4.bmp
icon1.ico
icon2.ico
Install
dbView.inf
dbView.ini
Setup.exe
magenic.bmp
magenic.ico
mssccprj.scc
vssver.scc
ftpView
appicon.ico
bitmap1.bmp
bitmap2.bmp
bitmap3.bmp
bitmap4.bmp
bmp00001.bmp
bmp00002.bmp
db5.bmp
deldb.bp2
delrec.bp2
FtpView.dsp
ftpView.dsw
FtpView.old
ftpView.plg
FtpView.vcl
FtpView.vcp
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico171.ico
ico35.ico
icon1.ico
icon2.ico
imagelis.bmp
IMAGES.bmp
Install
ftpView.inf
ftpView.ini
Setup.exe
vssver.scc
magenic.bmp
magenic.ico
mssccprj.scc
options.bmp
options1.bmp
seperato.bmp
vssver.scc
Setup
ico101.ico
Setup.aps
Setup.dsp
setup.ico
Setup.plg
WinCe.dsw
WinLib.dsw
kgwince.zip
app.ico
BeamEx.dsp
BeamEx.dsw
BeamEx.ini
BeamEx.plg
BeamEx.vcl
BeamEx.vcp
bitmap1.bmp
bmp00001.bmp
bmp00002.bmp
calc.bmp
calc16.bmp
circ_cross.ico
cir_cross.ico
cross_4.ico
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico00005.ico
ico00008.ico
ico00009.ico
ico00010.ico
icon1.ico
icon2.ico
icon4.ico
id_downl.bmp
BeamEx.inf
BeamEx.ini
Setup.exe
i_cross.ico
l_cross.ico
magenic.ico
mssccprj.scc
obl_corss.ico
obl_cross.ico
options.bmp
options1.bmp
ping16.bmp
rect_cross.ico
scene_5.ico
scene_6.ico
tri_cross.ico
vssver.scc
CeFtp.vcp
CeFtp.vcw
CeLabel.inl
CeLib.aps
CeLib.dsp
CeLib.dsw
CeLib.plg
CeLib.vcl
CeLib.vcp
CeMisc.inl
CeProperty.inl
CeTab.inl
CeWnd.inl
mssccprj.scc
vssver.scc
WinLib.dsp
WinLib.dsw
bitmap1.bmp
bitmap2.bmp
bmp00001.bmp
db5.bmp
DbView.dsp
dbView.dsw
dbView.plg
DbView.vcl
DbView.vcp
deldb.bp2
deldb5.bmp
delrec.bp2
delrecor.bmp
help16.bmp
help4.bmp
icon1.ico
icon2.ico
dbView.inf
dbView.ini
Setup.exe
magenic.bmp
magenic.ico
menu1_5.bmp
mssccprj.scc
vssver.scc
appicon.ico
bitmap1.bmp
bitmap2.bmp
bitmap3.bmp
bitmap4.bmp
bmp00001.bmp
bmp00002.bmp
db5.bmp
deldb.bp2
delrec.bp2
FtpView.dsp
ftpView.dsw
ftpView.plg
FtpView.vcl
FtpView.vcp
FtpView.vcw
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico171.ico
ico35.ico
icon1.ico
icon2.ico
imagelis.bmp
IMAGES.bmp
ftpView.inf
ftpView.ini
Setup.exe
vssver.scc
magenic.bmp
magenic.ico
mssccprj.scc
newmenu.bmp
options.bmp
options1.bmp
rcdata1.bin
seperato.bmp
toolbar1.bmp
vssver.scc
WinCe.dsw
WinCe.vcw
#include "StdAfx.h"
#include "PropertyDlg.h"

extern void FormatDateTime(FILETIME ft, LPTSTR sz);

///////////////////////////////////////////////////////////////////////////////

CeFtpPage::CeFtpPage():
	CeTabPage(IDD_SITE_PROPERTIES, _T("Site"))
{
}

BOOL CeFtpPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT;

	m_labelName.ReplaceWindow(IDC_EDITNAME, m_hWnd, dwStyle);
	m_labelName.SetWindowText(m_site.m_strName);
	if (!m_site.m_strName.IsEmpty())
		m_labelName.SetReadOnly();

	m_labelIP.ReplaceWindow(IDC_EDITIP, m_hWnd, dwStyle);
	m_labelIP.SetWindowText(m_site.m_strAddress);

	m_labelUser.ReplaceWindow(IDC_EDITUSER, m_hWnd, dwStyle);
	m_labelUser.SetWindowText(m_site.m_strUser);

	m_labelPassword.ReplaceWindow(IDC_EDITPASS, m_hWnd, dwStyle|ES_PASSWORD);
	m_labelPassword.SetWindowText(m_site.m_strPassword);

	Button_SetCheck(GetDlgItem(IDC_ANON), (m_site.m_bAnon) ? BST_CHECKED: BST_UNCHECKED);
	Button_SetCheck(GetDlgItem(IDC_PASSIVE),  (m_site.m_bPassive) ? BST_CHECKED: BST_UNCHECKED);

	return bRet;
}

void CeFtpPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
}

BOOL CeFtpPage::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	BOOL bRet = CeDialog::OnCommand(wParam, lParam, bHandled);

	WORD wNotify = HIWORD(wParam);	// notification code 
	WORD wId	 = LOWORD(wParam);	// item, control, or accelerator identifier 
	HWND hwndCtl = (HWND) lParam;	// handle of control 

	bHandled = true;

	if (hwndCtl != NULL)
	{
		if (IDC_ANON == wId && BN_CLICKED == wNotify)
		{
			if (BST_CHECKED == Button_GetCheck(hwndCtl))
			{
				m_labelUser.SetWindowText(_T("anonymous"));
				m_labelPassword.SetWindowText(_T("anonymous@anon.com"));
			}
			else
			{
				m_labelUser.SetWindowText(_T(""));
				m_labelPassword.SetWindowText(_T(""));
			}
		}
	}

	return TRUE;
}


void CeFtpPage::OnApply()
{
	m_site.m_strName = CeString(GetDlgItem(IDC_EDITNAME));
	if (m_site.m_strName.IsEmpty() || m_site.m_strName == _T("<...>"))
		return;

	m_site.m_strAddress = CeString(GetDlgItem(IDC_EDITIP));
	if (m_site.m_strAddress == _T("<...>"))
		m_site.m_strAddress.Empty();

	m_site.m_strUser = CeString(GetDlgItem(IDC_EDITUSER));
	if (m_site.m_strUser == _T("<...>"))
		m_site.m_strUser.Empty();

	m_site.m_strPassword = CeString(GetDlgItem(IDC_EDITPASS));
	if (m_site.m_strPassword == _T("<...>"))
		m_site.m_strPassword.Empty();

	m_site.m_bAnon = (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_ANON)));
	m_site.m_bPassive = (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_PASSIVE)));

	m_site.Update();
	
	CeDialog::OnOK();
}

///////////////////////////////////////////////////////////////////////////////

extern BOOL GetShFileInfo(LPCTSTR lpszName, DWORD dwAttrib, SHFILEINFO & shinfo, int nFlags, bool bLocal);

///////////////////////////////////////////////////////////////////////////////

CeFilePage::CeFilePage():
	CeTabPage(IDD_FILE_PROPERTIES, _T("General"))
{
	m_bLocal = true;
	m_bChangedAttributes = false;
}


void CeFilePage::SetFile(CeString & strDir, WIN32_FIND_DATA & findData, bool bLocal)
{
	m_finddata = findData;
	m_bLocal = bLocal;
	m_strDirectory = strDir;

	CeString str = strDir;

	if (! (m_finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
		str += m_finddata.cFileName;

	UINT nFlags =
		SHGFI_ICON |
		SHGFI_LARGEICON |
		SHGFI_TYPENAME |	// type name (e.g., CPP File)
		SHGFI_DISPLAYNAME;	// display name (no extension)

	if (! bLocal)
		nFlags |= SHGFI_USEFILEATTRIBUTES;

	GetShFileInfo(str, m_finddata.dwFileAttributes, m_shinfo, nFlags, bLocal);
}


bool CeFilePage::IsShortcut() const
{
	return (_tcscmp(m_shinfo.szTypeName, _T("Shortcut")) == 0);
}


BOOL CeFilePage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	// get the files properties and display them
	SetDlgItemText(IDC_TYPE, m_shinfo.szTypeName);
	SetDlgItemText(IDC_NAME, m_finddata.cFileName);

	if (! m_bLocal)
		::SendMessage(GetDlgItem(IDC_NAME), EM_SETREADONLY, TRUE, 0);

	FILETIME ft = m_finddata.ftLastAccessTime;
	if (m_bLocal)
		// need to convert time to local displayable format
		FileTimeToLocalFileTime(&ft, &ft);
	TCHAR sz[64];
	FormatDateTime(ft, sz);
	SetDlgItemText(IDC_MODIFIED, sz);

	// set the file icon....
	::SendMessage(GetDlgItem(IDC_FILEICON), STM_SETIMAGE, IMAGE_ICON, (LPARAM)m_shinfo.hIcon);

#ifdef _WIN32_WCE
	CeString str;
	str.Format(_T("0x%08x"), m_finddata.dwOID);
	SetDlgItemText(IDC_OID, str);
#endif

	// Set the attributes
	Button_SetCheck(GetDlgItem(IDC_CHECK1),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK2),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK4),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK5),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK6),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? 1: 0);
#ifdef _WIN32_WCE
	Button_SetCheck(GetDlgItem(IDC_CHECK3),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_INROM) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK7),	(m_finddata.dwFileAttributes & FILE_ATTRIBUTE_ROMMODULE) ? 1: 0);
#endif
	if (! m_bLocal || (m_finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
	{
		// can't change attributes on FTP connections
		::EnableWindow(GetDlgItem(IDC_CHECK1), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK2), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK3), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK4), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK5), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK6), FALSE);
		::EnableWindow(GetDlgItem(IDC_CHECK7), FALSE);
	}

	return bRet;
}

void CeFilePage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
}

BOOL CeFilePage::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	BOOL bRet = CeTabPage::OnCommand(wParam, lParam, bHandled);

	WORD wNotify = HIWORD(wParam);	// notification code 
	WORD wId	 = LOWORD(wParam);	// item, control, or accelerator identifier 
	HWND hwndCtl = (HWND) lParam;	// handle of control 

	bHandled = true;

	if (hwndCtl != NULL)
	{
		switch (wId)
		{
		case IDC_CHECK1:
		case IDC_CHECK4:
		case IDC_CHECK5:
		case IDC_CHECK6:
			if (wNotify == BN_CLICKED)
				m_bChangedAttributes = true;
		}
	}

	return bRet;
}


void CeFilePage::OnApply()
{
	CeString str;

	if (m_bChangedAttributes && m_bLocal)
	{
		str = m_strDirectory;
		if (! (m_finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			str += m_finddata.cFileName;

		DWORD dwAttrib = ::GetFileAttributes(str);

		if (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_CHECK1)))
			dwAttrib |= FILE_ATTRIBUTE_READONLY;
		else
			dwAttrib &= ~FILE_ATTRIBUTE_READONLY;

		if (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_CHECK4)))
			dwAttrib |= FILE_ATTRIBUTE_HIDDEN;
		else
			dwAttrib &= ~FILE_ATTRIBUTE_HIDDEN;

		if (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_CHECK5)))
			dwAttrib |= FILE_ATTRIBUTE_SYSTEM;
		else
			dwAttrib &= ~FILE_ATTRIBUTE_SYSTEM;

		if (BST_CHECKED == Button_GetCheck(GetDlgItem(IDC_CHECK6)))
			dwAttrib |= FILE_ATTRIBUTE_ARCHIVE;
		else
			dwAttrib &= ~FILE_ATTRIBUTE_ARCHIVE;

		if (! ::SetFileAttributes(str, dwAttrib))
		{
			DWORD dw = GetLastError();
			MessageBox(_T("Failed to change file attributes"));
		}
		else
		{
			m_finddata.dwFileAttributes = dwAttrib;
		}
	}

	str.GetWindowText(GetDlgItem(IDC_NAME));
	if (m_bLocal && _tcscmp(str, m_finddata.cFileName) != 0)
	{
		CeString strNew = m_strDirectory;
		CeString strOld = m_strDirectory;

		strNew += str;
		strOld += m_finddata.cFileName;

		if (! MoveFile(strOld, strNew))
		{
			DWORD dwErr = GetLastError();
			MessageBox(_T("Rename failed!"), _T(""), MB_OK);
		}
		else
		{
			// update the properties we changed...
			_tcscpy(m_finddata.cFileName, str);
		}
	}

	CeTabPage::OnOK();
}


///////////////////////////////////////////////////////////////////////////////

CeShortcutPage::CeShortcutPage():
	CeTabPage(IDD_SHORTCUT_PROPERTIES, _T("Shortcut"))
{
}

void CeShortcutPage::SetFile(CeString & strDir, WIN32_FIND_DATA & findData)
{
	TCHAR szTarget[MAX_PATH];

	m_finddata = findData;
	m_strDirectory = strDir;

	CeString str = m_strDirectory;
		str += m_finddata.cFileName;

	TCHAR szBuf[MAX_PATH];
	_tcscpy(szBuf, str);

	BOOL bRet;
	bRet = ::SHGetShortcutTarget(szBuf, szTarget, 128);

	//
	// This call always returns an extra character, handle it
	if (bRet)
	{
		LPTSTR lpsz = szTarget;
		for (int ii = 0; *lpsz != 0; lpsz++)
		{
			if (*lpsz == _T('"'))
				continue;

			if (_istspace(*lpsz))
				break;

			szTarget[ii] = *lpsz;
			ii++;
		}
		szTarget[ii] = 0;

		int nFlags = SHGFI_TYPENAME | SHGFI_ICON | SHGFI_LARGEICON; // | SHGFI_DISPLAYNAME;

		GetShFileInfo(szTarget, 0, m_shinfo, nFlags, TRUE);
	}
}

BOOL CeShortcutPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	TCHAR szTarget[128];

	SetDlgItemText(IDC_TYPE, m_shinfo.szTypeName);

	CeString str = m_strDirectory;
		str += m_finddata.cFileName;

	::SHGetShortcutTarget(str, szTarget, 128);
	SetDlgItemText(IDC_TARGET, szTarget);

	return bRet;
}

void CeShortcutPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
}


void CeShortcutPage::OnApply()
{
	CeString str = m_strDirectory;
		str += m_finddata.cFileName;

	CeString strTarget( GetDlgItem(IDC_TARGET) );

	// This call always returns an extra character, handle it
	::SHCreateShortcut((LPTSTR) (LPCTSTR) str, (LPTSTR) (LPCTSTR) strTarget);
}


///////////////////////////////////////////////////////////////////////////////


CeSystemPage::CeSystemPage():
	CeTabPage(IDD_SYSTEM_PROPERTIES, _T("System"))
{
}

BOOL CeSystemPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	m_groupVersion.Subclass(GetDlgItem(IDC_OS));
	m_groupSystem.Subclass(GetDlgItem(IDC_HW));

	OSVERSIONINFO os;
	os.dwOSVersionInfoSize = sizeof OSVERSIONINFO;
	::GetVersionEx(&os);
	ASSERT(os.dwPlatformId == VER_PLATFORM_WIN32_CE);

	CeString strTmp;
	strTmp.Format(_T("%d.%02d Build %d"),
		(int) os.dwMajorVersion,
		(int) os.dwMinorVersion,
		(int) os.dwBuildNumber);

	SetDlgItemText(IDC_VERSION, strTmp);
	SetDlgItemText(IDC_EXTRA, os.szCSDVersion);

	SYSTEM_INFO si;
	GetSystemInfo(&si);

	switch (si.dwProcessorType)
	{
	case PROCESSOR_INTEL_386:		strTmp = _T("Intel 386"); break;
	case PROCESSOR_INTEL_486:		strTmp = _T("Intel 486"); break;
	case PROCESSOR_INTEL_PENTIUM:	strTmp = _T("Intel Pentium"); break;
	case PROCESSOR_MIPS_R3000:		strTmp = _T("MIPS R3000"); break;
	case PROCESSOR_MIPS_R4000:		strTmp = _T("MIPS R4000"); break;
	case PROCESSOR_HITACHI_SH3:		strTmp = _T("Hitachi SH3"); break;
//	case PROCESSOR_HITACHI_SH4:		strTmp = _T("Hitachi SH4"); break;

// Currently no handhelds support these...

//	case PROCESSOR_PPC_403:			strTmp = _T("PowerPC 403"); break;
//	case PROCESSOR_PPC_821:			strTmp = _T("PowerPC 821"); break;
//	case PROCESSOR_STRONGARM:		strTmp = _T("Strong ARM"); break;
//	case PROCESSOR_ARM720:			strTmp = _T("Arm 720"); break;
//	case PROCESSOR_ARM820:			strTmp = _T("Arm 820"); break;
//	case PROCESSOR_ARM920:			strTmp = _T("Arm 920"); break;
//	case PROCESSOR_ARM_7TDMI:		strTmp = _T("Arm 7TDMI"); break;
	default:
		break;
	}

	SetDlgItemText(IDC_PROCESSOR, strTmp);

	//si.dwPageSize;
	//si.lpMinimumApplicationAddress, si.lpMaximumApplicationAddress;
	//si.dwAllocationGranularity;

	STORE_INFORMATION storeinfo;
	if (GetStoreInformation(&storeinfo))
	{
		strTmp.SetULong(storeinfo.dwFreeSize);
		SetDlgItemText(IDC_FREE, strTmp);
		strTmp.SetULong(storeinfo.dwStoreSize);
		SetDlgItemText(IDC_ALLOC, strTmp);
	}

	DWORD dwStorePages;
	DWORD dwRamPages;
	DWORD dwPageSize;
	if (GetSystemMemoryDivision(&dwStorePages, &dwRamPages, &dwPageSize))
	{
		strTmp.SetULong(dwStorePages * dwPageSize + dwRamPages * dwPageSize);
		SetDlgItemText(IDC_TOTAL, strTmp);
		strTmp.SetULong(dwRamPages * dwPageSize);
		SetDlgItemText(IDC_RAM, strTmp);
		strTmp.SetULong(dwStorePages * dwPageSize);
		SetDlgItemText(IDC_STORE, strTmp);
		strTmp.SetULong(dwPageSize);
		SetDlgItemText(IDC_PAGESIZE, strTmp);
	}

	return bRet;
}

void CeSystemPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
}


///////////////////////////////////////////////////////////////////////////////

CeVersionPage::CeVersionPage():
	CeTabPage(IDD_VERSION_PROPERTIES, _T("Version"))
{
}


BOOL CeVersionPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	SetDlgItemText(IDC_VERSION, m_pVersion->m_wszFileVersion);
	SetDlgItemText(IDC_DESC, m_pVersion->m_wszFileDescription);
	SetDlgItemText(IDC_COPYRIGHT, m_pVersion->m_wszFileCopyright);

	HWND hList = GetDlgItem(IDC_LIST);

	// Add the columns for the values
	LV_COLUMN lvc;

	lvc.mask = LVCF_TEXT;
	lvc.pszText = _T("Item");
	ListView_InsertColumn(hList, 0, &lvc);
	lvc.pszText = _T("Value");
	ListView_InsertColumn(hList, 1, &lvc);

	LV_ITEM lvi;

	// Add the Values
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 0;
	lvi.iSubItem = 0;
	lvi.pszText = _T("Company Name");
	ListView_InsertItem(hList, &lvi);

	lvi.pszText = m_pVersion->m_wszCompanyName;
	lvi.iSubItem = 1;
	ListView_SetItem(hList, &lvi);
//
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 1;
	lvi.iSubItem = 0;
	lvi.pszText = _T("Internal Name");
	ListView_InsertItem(hList, &lvi);

	lvi.pszText = m_pVersion->m_wszInternalName;
	lvi.iSubItem = 1;
	ListView_SetItem(hList, &lvi);

//
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 2;
	lvi.iSubItem = 0;
	lvi.pszText = _T("Original name");
	ListView_InsertItem(hList, &lvi);

	lvi.pszText = m_pVersion->m_wszOriginalFilename;
	lvi.iSubItem = 1;
	ListView_SetItem(hList, &lvi);
//
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 3;
	lvi.iSubItem = 0;
	lvi.pszText = _T("Product Name");
	ListView_InsertItem(hList, &lvi);

	lvi.pszText = m_pVersion->m_wszProductName;
	lvi.iSubItem = 1;
	ListView_SetItem(hList, &lvi);
//
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 4;
	lvi.iSubItem = 0;
	lvi.pszText = _T("Product Version");
	ListView_InsertItem(hList, &lvi);

	lvi.pszText = m_pVersion->m_wszProductVerion;
	lvi.iSubItem = 1;
	ListView_SetItem(hList, &lvi);

	ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE_USEHEADER);
	ListView_SetColumnWidth(hList, 1, LVSCW_AUTOSIZE_USEHEADER);

	return bRet;
}

void CeVersionPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
}


///////////////////////////////////////////////////////////////////////////////

CePropertyDlg::CePropertyDlg():
	m_pageFtp(),
	m_pageFile(),
	m_pageShortcut(),
	m_pageSystem()
{
}

CePropertyDlg::~CePropertyDlg()
{
}

void CePropertyDlg::AddFtpSiteProperty(CeFtpSite& site)
{
	m_pageFtp.SetFtp(site);
	m_sheet.AddPage(&m_pageFtp);
}

void CePropertyDlg::AddFileProperty(CeString & strDir, WIN32_FIND_DATA & fd, bool bLocal)
{
	m_pageFile.SetFile(strDir, fd, bLocal);
	m_sheet.AddPage(&m_pageFile);

	OSVERSIONINFO osvi = {sizeof(osvi)};
	GetVersionEx(&osvi);

	if (bLocal && m_pageFile.IsShortcut() &&
		(osvi.dwMajorVersion == 2 && osvi.dwMinorVersion > 1))
	{
		m_pageShortcut.SetFile(strDir, fd);
		m_sheet.AddPage(&m_pageShortcut);
	}

	if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		return;

	//
	LPCTSTR lpsz = _tcsrchr(fd.cFileName, _T('.'));
	// extract the extension
	TCHAR szExt[32];
	_tcsncpy(szExt, lpsz, 32);
	szExt[31] = 0;

	if (_tcsicmp(szExt, L".EXE") == 0 || _tcsicmp(szExt, L".DLL") == 0 ||
		_tcsicmp(szExt, L".OCX") == 0 || _tcsicmp(szExt, L".CPL") == 0)
	{
		CeString str = strDir;
		str += _T('\\');
		str += fd.cFileName;

		CeResource res;
		if (! res.Load(str))
			return;

		DWORD	dwSize;
		HRSRC	hRes = res.FindResource(1, RT_VERSION);
		if (hRes)
		{
			LPVOID	pVoid = res.LoadResource(hRes, dwSize);
			m_pageVersion.m_pVersion = new CeVersionInfo;

			if (pVoid && m_pageVersion.m_pVersion->Load((BYTE*) pVoid))
				m_sheet.AddPage(&m_pageVersion);
		}
	}
}


void CePropertyDlg::AddSystemProperty()
{
	m_sheet.AddPage(&m_pageSystem);
}


BOOL CePropertyDlg::OnInitDialog()
{
	BOOL bRet = CeDialog::OnInitDialog();

// Fix the child sizes
	HWND hWnd = GetDlgItem(IDC_TABSHEET);
	HFONT hFont = (HFONT) ::SendMessage(hWnd, WM_GETFONT, 0, 0);

	RECT rc;
	::GetWindowRect(hWnd, &rc);
	ScreenToClient(&rc);

	// kill the old window
	::DestroyWindow(hWnd);

	// spread out the border of the tab control so the border
	// isn't visible
	rc.left -= 1;
	rc.right += 2;
	rc.bottom += 3;
	m_sheet.Create(WS_CHILD|WS_VISIBLE, rc, m_hWnd, 12);
	m_sheet.SetFont( hFont, TRUE );

	return bRet;
}

void CePropertyDlg::OnTimer( UINT nTimer, bool& bHandled )
{
}


LRESULT CePropertyDlg::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	switch (uMsg)
	{
	case WM_SETFONT:
		m_sheet.SetFont((HFONT) wParam, LOWORD(lParam));
		break;
	}

	return 0;
}

void CePropertyDlg::OnOK()
{
	m_sheet.Apply();
	CeDialog::OnOK();
}

void CePropertyDlg::OnCancel()
{
	m_sheet.Reset();
	CeDialog::OnCancel();
}

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)

Share

About the Author

Kenny G

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 5 Oct 2000
Article Copyright 2000 by Kenny G
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid