Click here to Skip to main content
15,881,882 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 278.1K   998   70  
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.
#include "StdAfx.h"
#include "PropDlg.h"

extern void FormatDateTime(FILETIME ft, LPTSTR sz);

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

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

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

	TCHAR sz[64];
	FormatDateTime(fd.ftLastAccessTime, sz);
	SetDlgItemText(IDC_MODIFIED, sz);

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

	// Set the attributes
	Button_SetCheck(GetDlgItem(IDC_CHECK1), (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK2), (fd.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK4), (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK5), (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK6), (fd.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? 1: 0);
#ifdef _WIN32_WCE
	Button_SetCheck(GetDlgItem(IDC_CHECK3), (fd.dwFileAttributes & FILE_ATTRIBUTE_INROM) ? 1: 0);
	Button_SetCheck(GetDlgItem(IDC_CHECK7), (fd.dwFileAttributes & FILE_ATTRIBUTE_ROMMODULE) ? 1: 0);
#endif
	if (NULL != m_pClient)
	{
		// 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;
}

{
}

BOOL CePropertiesDlg::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)
	{
		switch (wId)
		{
		case IDC_CHECK1:
		case IDC_CHECK4:
		case IDC_CHECK5:
		case IDC_CHECK6:
			if (wNotify == BN_CLICKED)
				m_bChangedAttributes = true;
		}
	}

	return bRet;
}


void CePropertiesDlg::OnOK()
{
	if (m_bChangedAttributes)
	{
		DWORD dwAttrib = ::GetFileAttributes(m_strFile);

		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;

		::SetFileAttributes(m_strFile, dwAttrib);
	}

	CeDialog::OnOK();
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions