⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infodlg.cpp

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CPP
字号:
/*
Filename    : InfoDlg.cpp
Part of     : File Browser
Description : Implementation of File Browser's info dialog class
Version     : 3.2

This example is only to be used with PC Connectivity API version 3.2.
Compability ("as is") with future versions is not quaranteed.

Copyright (c) 2007 Nokia Corporation.
 
This material, including but not limited to documentation and any related 
computer programs, is protected by intellectual property rights of Nokia 
Corporation and/or its licensors.
All rights are reserved. Reproducing, modifying, translating, or 
distributing any or all of this material requires the prior written consent 
of Nokia Corporation. Nokia Corporation retains the right to make changes 
to this material at any time without notice. A copyright license is hereby 
granted to download and print a copy of this material for personal use only.
No other license to any other intellectual property rights is granted. The 
material is provided "as is" without warranty of any kind, either express or 
implied, including without limitation, any warranty of non-infringement, 
merchantability and fitness for a particular purpose. In no event shall 
Nokia Corporation be liable for any direct, indirect, special, incidental, 
or consequential loss or damages, including but not limited to, lost profits 
or revenue,loss of use, cost of substitute program, or loss of data or 
equipment arising out of the use or inability to use the material, even if 
Nokia Corporation has been advised of the likelihood of such damages occurring.
*/ 

#include "stdafx.h"
#include "FileBrowser.h"
#include "InfoDlg.h"

// CInfoDlg dialog

IMPLEMENT_DYNAMIC(CInfoDlg, CDialog)

CInfoDlg::CInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInfoDlg::IDD, pParent)
{
	m_pFolderInfo = NULL;
	m_pFileInfo = NULL;
}

CInfoDlg::~CInfoDlg()
{
}

//===================================================================
// OnInitDialog
//
// Initializes user interface
//
//===================================================================
BOOL CInfoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	// Initialize list view for showing item details
	m_ItemList.InsertColumn(0, _T("Field"));
	m_ItemList.SetColumnWidth(0, 120);
	m_ItemList.InsertColumn(1, _T("Data"));
	RECT rect;
	m_ItemList.GetClientRect(&rect);
	m_ItemList.SetColumnWidth(1, rect.right - 120);
	ViewFolderInfo();
	ViewFileInfo();
	return TRUE;  
}

void CInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_ITEM_LIST, m_ItemList);
}


BEGIN_MESSAGE_MAP(CInfoDlg, CDialog)
END_MESSAGE_MAP()

//===================================================================
// ViewFolderInfo 
//
// View details of folder in list view
//
//===================================================================
void CInfoDlg::ViewFolderInfo()
{
	if(!m_pFolderInfo)
	{
		return;
	}
	int iItemCount = 0;
	m_ItemList.InsertItem(iItemCount, L"Name");
	m_ItemList.SetItemText(iItemCount, 1, m_pFolderInfo->pstrName);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"Absolute path");
	m_ItemList.SetItemText(iItemCount, 1, m_pFolderInfo->pstrLocation);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"Type and permission");
	m_ItemList.SetItemText(iItemCount, 1, Permissions2String(m_pFolderInfo->dwAttributes));
	iItemCount++;
	WCHAR swTime[128];
	GetLocalFormattedDate(m_pFolderInfo->tFolderTime, swTime, 128);
	m_ItemList.InsertItem(iItemCount, L"Folder time");
	m_ItemList.SetItemText(iItemCount, 1, swTime);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"Label");
	m_ItemList.SetItemText(iItemCount, 1, m_pFolderInfo->pstrLabel);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"Memory type");
	m_ItemList.SetItemText(iItemCount, 1, m_pFolderInfo->pstrMemoryType);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"Identification ID");
	m_ItemList.SetItemText(iItemCount, 1, m_pFolderInfo->pstrID);
	iItemCount++;
	WCHAR swMemory[128];
	StrFormatByteSizeW(m_pFolderInfo->dlFreeMemory, swMemory, 128);
	m_ItemList.InsertItem(iItemCount, L"Free memory");
	m_ItemList.SetItemText(iItemCount, 1, swMemory);
	iItemCount++;
	StrFormatByteSizeW(m_pFolderInfo->dlTotalMemory, swMemory, 128);
	m_ItemList.InsertItem(iItemCount, L"Total memory");
	m_ItemList.SetItemText(iItemCount, 1, swMemory);
	iItemCount++;
	StrFormatByteSizeW(m_pFolderInfo->dlUsedMemory, swMemory, 128);
	m_ItemList.InsertItem(iItemCount, L"Used memory");
	m_ItemList.SetItemText(iItemCount, 1, swMemory);
	iItemCount++;
	if(m_pFolderInfo->dwContainFiles != -1)
	{
		_ltow_s(m_pFolderInfo->dwContainFiles, swMemory, 10);
		m_ItemList.InsertItem(iItemCount, L"Number of files");
		m_ItemList.SetItemText(iItemCount, 1, swMemory);
		iItemCount++;
	}
	if(m_pFolderInfo->dwContainFolders != -1)
	{
		_ltow_s(m_pFolderInfo->dwContainFolders, swMemory, 10);
		m_ItemList.InsertItem(iItemCount, L"Number of folders");
		m_ItemList.SetItemText(iItemCount, 1, swMemory);
		iItemCount++;
	}
	if(m_pFolderInfo->dlTotalSize != -1)
	{
		StrFormatByteSizeW(m_pFolderInfo->dlTotalSize, swMemory, 128);
		m_ItemList.InsertItem(iItemCount, L"Size of folder content");
		m_ItemList.SetItemText(iItemCount, 1, swMemory);
		iItemCount++;
	}
}

//===================================================================
// ViewFileInfo 
//
// View details of file in list view
//
//===================================================================
void CInfoDlg::ViewFileInfo()
{
	if(!m_pFileInfo)
	{
		return;
	}
	SetWindowText(L"File Info");
	int iItemCount = 0;
	m_ItemList.InsertItem(iItemCount, L"Name");
	m_ItemList.SetItemText(iItemCount, 1, m_pFileInfo->pstrName);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"File permission");
	m_ItemList.SetItemText(iItemCount, 1, Permissions2String(m_pFileInfo->dwAttributes));
	iItemCount++;
	WCHAR swTime[128];
	GetLocalFormattedDate(m_pFileInfo->tFileTime, swTime, 128);
	m_ItemList.InsertItem(iItemCount, L"File modified time");
	m_ItemList.SetItemText(iItemCount, 1, swTime);
	iItemCount++;
	WCHAR swSize[128];
	StrFormatByteSizeW(m_pFileInfo->dwFileSize, swSize, 128);
	m_ItemList.InsertItem(iItemCount, L"File size");
	m_ItemList.SetItemText(iItemCount, 1, swSize);
	iItemCount++;
	m_ItemList.InsertItem(iItemCount, L"MIME type");
	m_ItemList.SetItemText(iItemCount, 1, m_pFileInfo->pstrMIMEType);
	iItemCount++;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -