Ejemplo n.º 1
0
BOOL TransfersPanel::CopyTransferInfo(TransferItem * t_item)
{
	if (!t_item)
		return TRUE;

	OpString str, string;

	g_languageManager->GetString(Str::DI_IDL_SOURCE, string);
	str.Append(string);
	str.Append(": ");

	OpString url_string;
	t_item->GetURL()->GetAttribute(URL::KUniName_Username_Password_Hidden, url_string);

	if(t_item->GetType() == TransferItem::TRANSFERTYPE_CHAT_UPLOAD ||
	   t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
		str.Append(t_item->GetStorageFilename()->CStr());
	else
		str.Append(url_string);

	str.Append(NEWLINE);

	g_languageManager->GetString(Str::DI_IDL_DESTINATION, string);
	str.Append(string);
	str.Append(": ");

	if(t_item->GetType() == TransferItem::TRANSFERTYPE_CHAT_UPLOAD ||
	   t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
		str.Append(url_string);
	else
		str.Append(t_item->GetStorageFilename()->CStr());

	str.Append(NEWLINE);

	g_languageManager->GetString(Str::DI_IDL_SIZE, string);
	str.Append(string);
	str.Append(": ");

	OpString sizestring;
	if (sizestring.Reserve(256))
	{
		StrFormatByteSize(sizestring, t_item->GetSize(), SFBS_ABBRIVATEBYTES|SFBS_DETAILS);
		str.Append(sizestring.CStr());
		str.Append(NEWLINE);

		g_languageManager->GetString(Str::DI_IDL_TRANSFERED, string);
		str.Append(string);
		str.Append(": ");

		StrFormatByteSize(sizestring, t_item->GetHaveSize(), SFBS_ABBRIVATEBYTES|SFBS_DETAILS);
		str.Append(sizestring.CStr());
	}
	str.Append(NEWLINE);

	g_desktop_clipboard_manager->PlaceText(str.CStr(), g_application->GetClipboardToken());
#if defined(_X11_SELECTION_POLICY_)
	g_desktop_clipboard_manager->PlaceText(str.CStr(), g_application->GetClipboardToken(), true);
#endif
	return TRUE;
}
Ejemplo n.º 2
0
void CRepositoryBrowser::FillListCtrlForShadowTree(CShadowFilesTree* pTree)
{
	for (TShadowFilesTreeMap::iterator itShadowTree = pTree->m_ShadowTree.begin(); itShadowTree != pTree->m_ShadowTree.end(); ++itShadowTree)
	{
		int icon = m_nIconFolder;
		if (!(*itShadowTree).second.m_bFolder)
			icon = SYS_IMAGE_LIST().GetFileIconIndex((*itShadowTree).second.m_sName);

		int indexItem = m_RepoList.InsertItem(m_RepoList.GetItemCount(), (*itShadowTree).second.m_sName, icon);

		m_RepoList.SetItemData(indexItem, (DWORD_PTR)&(*itShadowTree).second);
		if (!(*itShadowTree).second.m_bFolder)
		{
			CString temp;

			temp = CPathUtils::GetFileExtFromPath((*itShadowTree).second.m_sName);
			m_RepoList.SetItemText(indexItem, eCol_Extension, temp);

			StrFormatByteSize((*itShadowTree).second.m_iSize, temp.GetBuffer(20), 20);
			temp.ReleaseBuffer();
			m_RepoList.SetItemText(indexItem, eCol_FileSize, temp);
		}
	}

	CRepoListCompareFunc compareFunc(&m_RepoList, m_currSortCol, m_currSortDesc);
	m_RepoList.SortItemsEx(&CRepoListCompareFunc::StaticCompare, (DWORD_PTR)&compareFunc);

	SetSortArrowA(&m_RepoList, m_currSortCol, !m_currSortDesc);
}
Ejemplo n.º 3
0
tstring CPicture::GetFileSizeAsText(bool bAbbrev /* = true */)
{
	TCHAR buf[100] = {0};
	if (bAbbrev)
		StrFormatByteSize(m_nSize, buf, _countof(buf));
	else
		_stprintf_s(buf, _T("%ld Bytes"), m_nSize);

	return tstring(buf);
}
/**
 * @brief 显示虚拟内存的概况
 */
void ShowVirtualMemory()
{
	// 首先,让我们获得系统信息
	SYSTEM_INFO si;
	ZeroMemory(&si, sizeof(si));
	GetSystemInfo(&si);

	// 使用外壳辅助程序对一些尺寸进行格式化
	TCHAR szPageSize[MAX_PATH];
	StrFormatByteSize(si.dwPageSize, szPageSize, MAX_PATH);

	DWORD dwMemSize = (DWORD)si.lpMaximumApplicationAddress - (DWORD)si.lpMinimumApplicationAddress;
	TCHAR szMemSize[MAX_PATH];
	StrFormatByteSize(dwMemSize, szMemSize, MAX_PATH);

	// 将内存信息显示出来
	_tprintf(TEXT("Virtual memory page size: %s\n"), szPageSize);
	_tprintf(TEXT("Minimum application address: 0x%08x\n"), (DWORD)si.lpMinimumApplicationAddress);
	_tprintf(TEXT("Maximum application address: 0x%08x\n"), (DWORD)si.lpMaximumApplicationAddress);
	_tprintf(TEXT("Total available virtual memory: %s\n"), szMemSize);
}
Ejemplo n.º 5
0
BOOL CAddEdit_Attachment::OnInitDialog()
{
  CAddEdit_PropertyPage::OnInitDialog();

  // Get Add/Edit font
  Fonts *pFonts = Fonts::GetInstance();
  CFont *pFont = pFonts->GetAddEditFont();

  // Change font size of the attachment name and file name fields
  GetDlgItem(IDC_ATT_NAME)->SetFont(pFont);
  GetDlgItem(IDC_ATT_FILE)->SetFont(pFont);

  // Check initial state
  if (!M_pci()->HasAttRef()) {
    m_attType = NO_ATTACHMENT;
  } else {
    // m_attachment() set in CAddEdit_PropertySheet::SetupInitialValues()
    // If we have an attachment, load & preview
    m_AttName = M_attachment().GetTitle();
    m_AttFileName = M_attachment().GetFilePath() + M_attachment().GetFileName();

    // Get other properties
    m_csMediaType = M_attachment().GetMediaType().c_str();
    if (m_csMediaType == L"unknown") {
      m_csMediaType.LoadString(IDS_UNKNOWN);
    }

    wchar_t szFileSize[256];
    StrFormatByteSize(M_attachment().GetContentSize(), szFileSize, 256);
    m_csSize = szFileSize;

    m_csFileCTime = M_attachment().GetFileCTime().c_str();
    if (m_csFileCTime.IsEmpty())
      m_csFileCTime.LoadString(IDS_NA);

    m_csFileMTime = M_attachment().GetFileMTime().c_str();
    if (m_csFileMTime.IsEmpty())
      m_csFileMTime.LoadString(IDS_NA);

    ShowPreview();
  }

  UpdateData(FALSE);
  UpdateControls();

  m_bInitdone = true;

  return TRUE;  // return TRUE unless you set the focus to a control
}
BOOL COptionsStats::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

	CTime time(CGetSetOptions::GetTotalDate());
	m_eAllDate = time.Format("%m/%d/%Y %I:%M %p");
	m_eAllCopies.Format(_T("%d"), CGetSetOptions::GetTotalCopyCount());
	m_eAllPastes.Format(_T("%d"), CGetSetOptions::GetTotalPasteCount());

	CTime time2(CGetSetOptions::GetTripDate());
	m_eTripDate = time2.Format("%m/%d/%Y %I:%M %p");
	m_eTripCopies.Format(_T("%d"), CGetSetOptions::GetTripCopyCount());
	m_eTripPastes.Format(_T("%d"), CGetSetOptions::GetTripPasteCount());

	m_eClipsSent.Format(_T("%d"), theApp.m_lClipsSent);
	m_eClipsRecieved.Format(_T("%d"), theApp.m_lClipsRecieved);
	m_eLastStarted = theApp.m_oldtStartUp.Format(_T("%m/%d/%y %I:%M:%S"));
	if(theApp.m_oldtStartUp.GetHour() > 12)
		m_eLastStarted += " PM";
	else
		m_eLastStarted += " AM";

	COleDateTimeSpan span = COleDateTime::GetCurrentTime() - theApp.m_oldtStartUp;

	CString csSpan;
	csSpan.Format(_T("  -  %d.%d.%d (D.H.M)"), (long)span.GetTotalDays(), span.GetHours(), span.GetMinutes());
	m_eLastStarted += csSpan;

	try
	{
		m_eSavedCopies.Format(_T("%d"), theApp.m_db.execScalar(_T("SELECT COUNT(lID) FROM Main")));
		m_eSavedCopyData.Format(_T("%d"), theApp.m_db.execScalar(_T("SELECT COUNT(lID) FROM Data")));
	}
	CATCH_SQLITE_EXCEPTION
	
	__int64 size = FileSize(GetDBName());			

	const int MAX_FILE_SIZE_BUFFER = 255;
	TCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
	StrFormatByteSize(size, szFileSize, MAX_FILE_SIZE_BUFFER);

	m_eDatabaseSize = szFileSize;

	UpdateData(FALSE);

	theApp.m_Language.UpdateOptionStats(this);
		
	return TRUE;
}
Ejemplo n.º 7
0
DWORD addFileToListView (HWND hDlg, WIN32_FIND_DATA* findData, UINT itemId, LVITEM* lvI)
{
	SYSTEMTIME stUTC; 
	SYSTEMTIME stLocal;
	TCHAR str1 [MAX_PATH];
	TCHAR* tmpStr1;
	
	if (lstrcmp(findData->cFileName, L".") == 0)
	{
		return FM_AFTLV_NO;
	}

	// Занести данные из findData
	lvI->lParam = (LPARAM) fmLocalAlloc (sizeof(WIN32_FIND_DATA));
	CopyMemory ((VOID*)lvI->lParam, (const VOID*) findData, sizeof (WIN32_FIND_DATA));
	
	// Создать новую строку
	lvI->iSubItem = 0;
	lvI->pszText[0] = L'\0';
	lvI->mask = LVIF_PARAM;
	SendDlgItemMessage (hDlg, itemId, LVM_INSERTITEM, (WPARAM)0, (LPARAM)lvI);
	
	
	lvI->mask = LVIF_TEXT;
	// Файл или папка
	if (findData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
	{	
		// если папка
		lvI->iSubItem = FM_COLUMN_NAME;
		lstrcpy (lvI->pszText, findData->cFileName);
		SendDlgItemMessage(hDlg, itemId, LVM_SETITEM, (WPARAM)0, (LPARAM)lvI);
		
		lvI->iSubItem = FM_COLUMN_TYPE;
		lstrcpy (lvI->pszText, FM_DIRTYPE_STUB);
		SendDlgItemMessage(hDlg, itemId, LVM_SETITEM, (WPARAM)0, (LPARAM)lvI);
	}
	else 
	{	
		// Если файл, то тип файла
		lvI->iSubItem = FM_COLUMN_TYPE;
		tmpStr1 = lstrrchr (findData->cFileName, L'.');
		if (tmpStr1 != NULL)
		{
			++ tmpStr1;
			lstrcpy (lvI->pszText, tmpStr1);
			SendDlgItemMessage (hDlg, itemId, LVM_SETITEM, (WPARAM)0, (LPARAM)lvI);
		}
		
		// имя файла
		lvI->iSubItem = FM_COLUMN_NAME;
		lstrcpy (lvI->pszText, findData->cFileName);
		lcutrchr (lvI->pszText, L'.');
		SendDlgItemMessage(hDlg, itemId, LVM_SETITEM, (WPARAM)0, (LPARAM)lvI);

		// размер файла
		UINT64 fs = findData->nFileSizeLow | (UINT64(findData->nFileSizeHigh) << 32);
		StrFormatByteSize (LONGLONG(fs), str1, sizeof (str1) / sizeof (str1[0]));
		lvI->iSubItem = FM_COLUMN_SIZE;
		lstrcpy (lvI->pszText, str1);
		SendDlgItemMessage (hDlg, itemId, LVM_SETITEM, (WPARAM)lvI->iItem, (LPARAM)lvI);
	}

	// Дата файла или папки
	lvI->iSubItem = FM_COLUMN_DATE;
	FileTimeToSystemTime(&findData->ftLastWriteTime, &stUTC);
	SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
	wsprintf(str1, L"%02u-%02u-%02u %02u:%02u", stLocal.wYear, stLocal.wMonth,
		stLocal.wDay, stLocal.wHour, stLocal.wMinute);
	lstrcpy (lvI->pszText, str1);
	SendDlgItemMessage (hDlg, itemId, LVM_SETITEM, (WPARAM)0, (LPARAM)lvI);
	
	return FM_AFTLV_OK;
}
Ejemplo n.º 8
0
/***********************************************************************************
**  WebStorageQuotaDialog::OnInit
************************************************************************************/
void
WebStorageQuotaDialog::OnInit()
{
    OpWidget* label = GetWidgetByName("webstorage_description");
    if(label)
    {
        OpString text;
        OpString final_string;
        int expected_len;

        // format the description and replace %1 with the site domain
        if(OpStatus::IsSuccess(label->GetText(text)))
        {
            expected_len = text.Length() + 256;
            uni_char* mess_p = final_string.Reserve(expected_len);
            if (mess_p)
            {
                uni_snprintf_ss(mess_p, expected_len, text.CStr(), m_server_name.CStr(), NULL);
                label->SetText(final_string.CStr());
            }
        }
    }
    label = GetWidgetByName("webstorage_current_limit");
    if(label)
    {
        // show the current limit in a nice localized format
        OpString sizestring;

        if(sizestring.Reserve(64))
        {
            StrFormatByteSize(sizestring, m_current_limit, SFBS_ABBRIVATEBYTES);
            label->SetText(sizestring.CStr());
        }
    }
    OpDropDown* dropdown = (OpDropDown*)GetWidgetByName("webstorage_requested_limit");
    if(dropdown)
    {
        BOOL found_default = FALSE;

        // add all the different predefined sizes as ratios of the current limit
        if ( m_current_limit != 0)
        {
            for (size_t i = 0; i < ARRAY_SIZE(ratios); i++)
            {
                OpString sizestring;

                UINT32 size = m_current_limit * ratios[i];

                if(sizestring.Reserve(64))
                {
                    StrFormatByteSize(sizestring, size, SFBS_ABBRIVATEBYTES);

                    dropdown->AddItem(sizestring.CStr(), -1, NULL, (size / 1024));	// divide by 1024 to avoid overflow

                    // make the requested limit from the web page the default, unless it's above 2GB
                    if(size == m_requested_limit && m_requested_limit <= MAX_WEBSTORAGE_QUOTA_HINT)
                    {
                        found_default = TRUE;
                        dropdown->SelectItem(i, TRUE);
                    }
                }
            }
        }
        if(!found_default && m_requested_limit)
        {
            // add and select the requested value
            OpString sizestring;

            if(sizestring.Reserve(64))
            {
                INT32 index;
                StrFormatByteSize(sizestring, m_requested_limit, SFBS_ABBRIVATEBYTES);

                if(OpStatus::IsSuccess(dropdown->AddItem(sizestring.CStr(), -1, &index, (m_requested_limit / 1024))))
                {
                    if(m_requested_limit <= MAX_WEBSTORAGE_QUOTA_HINT)
                    {
                        dropdown->SelectItem(index, TRUE);
                    }
                }
            }
        }
        // add an unlimited entry at the end
        OpString str;

        g_languageManager->GetString(Str::S_UNLIMITED, str);

        dropdown->AddItem(str.CStr(), -1, NULL);
    }
    CompressGroups();
}
Ejemplo n.º 9
0
void TransfersPanel::UpdateDetails(TransferItem* t_item,
								   BOOL onlysize)
{

	if(!t_item)	//clear the fields
	{
		m_item_details_from_info_label->SetText(UNI_L(""));
		m_item_details_to_info_label->SetText(UNI_L(""));
		m_item_details_size_info_label->SetText(UNI_L(""));
		m_item_details_transferred_info_label->SetText(UNI_L(""));
		m_item_details_connections_info_label->SetText(UNI_L(""));
		m_item_details_activetransfers_info_label->SetText(UNI_L(""));
		return;
	}

	if(!onlysize)
	{
		if(t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
		{
			OpString filename;

			m_item_details_from_info_label->SetText(t_item->GetStorageFilename()->CStr());

			t_item->GetDownloadDirectory(filename);

			UINT32 idx = filename.FindLastOf(PATHSEPCHAR);

			if(idx + 1 != 0)
			{
				filename.Append(PATHSEP);
			}
			filename.Append(*(t_item->GetStorageFilename()));
			m_item_details_to_info_label->SetText(filename.CStr());

			ShowExtraInformation(TRUE);
		}
		else
		{
			OpString url_string;
			t_item->GetURL()->GetAttribute(URL::KUniName_Username_Password_Hidden, url_string);
			m_item_details_from_info_label->SetText(url_string.CStr());
			m_item_details_to_info_label->SetText(t_item->GetStorageFilename()->CStr());

			ShowExtraInformation(FALSE);
		}
	}
	if(t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
	{
		OpString loc_conns;
		OpString loc_trans;
		OpString ui_text;
		OP_STATUS err;

		err = g_languageManager->GetString(Str::S_TRANSFERS_PANEL_CONNECTION_VERBOSE, ui_text);

		// Seeds: %d, Peers: %d (Total seeds/peers: %d/%d)

		if(OpStatus::IsSuccess(err))
		{
			loc_conns.AppendFormat(ui_text.CStr(),
				t_item->GetConnectionsWithCompleteFile(),
				t_item->GetConnectionsWithIncompleteFile(),
				t_item->GetTotalWithCompleteFile(),
				t_item->GetTotalDownloaders());
		}

#ifdef DEBUG_BT_TRANSFERPANEL

		BTDownload *download = (BTDownload *)g_Downloads->GetDownloadFromTransferItem(t_item);

		OpString debug_info;
		debug_info.AppendFormat(UNI_L(" (DEBUG: Unchoked: %d, Interested: %d, Interesting: %d)"),
//			download ? download->ClientConnectors()->GetCount() : 0,
//			g_Transfers->GetTotalCount(),
			download ? download->GetUploads()->GetTransferCount(upsUnchoked) : 0,
			download ? download->GetUploads()->GetTransferCount(upsInterested) : 0,
			download ? download->GetTransferCount(dtsCountInterestingPeers) : 0
			);

		loc_conns.Append(debug_info);
#endif
		m_item_details_connections_info_label->SetText(loc_conns.CStr());

		loc_trans.AppendFormat(UNI_L("%d / %d"),
			t_item->GetDownloadConnections(),
			t_item->GetUploadConnections());

		m_item_details_activetransfers_info_label->SetText(loc_trans.CStr());
	}

	OpString sizestring;
	OpString appendedsizestring;
	if (!sizestring.Reserve(256))
		return;

	OpFileLength downloaded_size = t_item->GetHaveSize();
	OpFileLength reported_size = t_item->GetSize();

	if(reported_size < downloaded_size)
		sizestring.Set("?");
	else
		StrFormatByteSize(sizestring, reported_size, SFBS_ABBRIVATEBYTES|SFBS_DETAILS);

	m_item_details_size_info_label->SetText(sizestring.CStr());
	if(t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
	{
		StrFormatByteSize(sizestring, downloaded_size, SFBS_ABBRIVATEBYTES|SFBS_DETAILS);
		appendedsizestring.Set(sizestring);
		appendedsizestring.Append(" / ");
		StrFormatByteSize(sizestring, t_item->GetUploaded(), SFBS_ABBRIVATEBYTES|SFBS_DETAILS);
		appendedsizestring.Append(sizestring);
		m_item_details_transferred_info_label->SetText(appendedsizestring.CStr());
	}
	else
	{
		StrFormatByteSize(sizestring, downloaded_size, SFBS_ABBRIVATEBYTES|SFBS_DETAILS);
		m_item_details_transferred_info_label->SetText(sizestring.CStr());
	}
}
/**
 * @brief   遍历虚拟内存
 * 
 * @details 遍历指定进程的整个虚拟内存并对用户显示其属性的工作程序的方法 
 *  
 * @param hProcess 待遍历的进程的进程句柄
 */
void WalkVM(HANDLE hProcess)
{
	// 首先,获得系统信息
	SYSTEM_INFO si;
	ZeroMemory(&si, sizeof(si));
	GetSystemInfo(&si);

	// 分配要存放信息的缓冲区
	MEMORY_BASIC_INFORMATION mbi;
	ZeroMemory(&mbi, sizeof(mbi));

	// 循环整个应用程序地址空间
	LPCVOID pBlock = (LPVOID)si.lpMinimumApplicationAddress;
	while (pBlock < si.lpMaximumApplicationAddress)
	{
		// 获得下一个虚拟内存块的信息
		if (VirtualQueryEx(
			hProcess,        // 相关的进程
			pBlock,          // 开始位置
			&mbi,            // 缓冲区
			sizeof(mbi)      // 大小的确认
			) == sizeof(mbi))
		{
			// 计算块的结尾及其大小
			LPCVOID pEnd = (PBYTE)pBlock + mbi.RegionSize;
			TCHAR szSize[MAX_PATH];
			StrFormatByteSize(mbi.RegionSize, szSize, MAX_PATH);

			// 显示块地址和大小
			_tprintf(TEXT("%08x-%08x"), (DWORD)pBlock, (DWORD)pEnd);
			_tprintf(TEXT(" (%7s) "), szSize);
			switch (mbi.State)
			{
			case MEM_COMMIT:
				_tprintf(TEXT("Committed"));
				break;
			case MEM_FREE:
				_tprintf(TEXT("Free"));
				break;
			case MEM_RESERVE:
				_tprintf(TEXT("Reserved"));
				break;
			}

			// 显示保护
			if (mbi.Protect == 0 && mbi.State != MEM_FREE)
				mbi.Protect = PAGE_READONLY;
			ShowProtection(mbi.Protect);

			// 显示类型
			switch (mbi.Type)
			{
			case MEM_IMAGE:
				_tprintf(TEXT(", Image"));
				break;
			case MEM_MAPPED:
				_tprintf(TEXT(", Mapped"));
				break;
			case MEM_PRIVATE:
				_tprintf(TEXT(", Private"));
				break;
			}

			// 检验可执行的影像
			TCHAR szFilename[MAX_PATH];
			if (GetModuleFileName(
				(HMODULE)pBlock,
				szFilename,
				MAX_PATH
				) > 0)
			{
				// 除去路径并显示
				PathStripPath(szFilename);
				_tprintf(TEXT(", Module: %s"), szFilename);
			}

			_putts(TEXT(""));

			// 移动块指针以获得下一个块
			pBlock = pEnd;
		}
	}
}
Ejemplo n.º 11
0
void CAddEdit_Attachment::ShowPreview()
{
  CItemAtt &att = M_attachment();
  HRESULT hr(S_OK);

  int rc(0);

  // Assume not an image
  m_attType = ATTACHMENT_NOT_IMAGE;

  if (!att.HasContent()) {
    // No content so filename must not be empty
    if (m_AttFileName.IsEmpty())
      return;

    int status = att.Import(LPCWSTR(m_AttFileName));
    if (status != PWScore::SUCCESS) {
      // most likely file error - TBD better error reporting
      rc = 1;
      goto load_error;
    }

    // Get media type before we find we can't load it
    m_csMediaType = att.GetMediaType().c_str();

    // Get other properties
    wchar_t szFileSize[256];
    StrFormatByteSize(att.GetContentSize(), szFileSize, 256);
    m_csSize = szFileSize;
    m_csFileCTime = att.GetFileCTime().c_str();
    if (m_csFileCTime.IsEmpty())
      m_csFileCTime.LoadString(IDS_NA);
    m_csFileMTime = att.GetFileMTime().c_str();
    if (m_csFileMTime.IsEmpty())
      m_csFileMTime.LoadString(IDS_NA);

    if (m_csMediaType.Left(5) == L"image") {
      // Should be an image file - but may not be supported by CImage - try..
      hr = m_AttImage.Load(m_AttFileName);
      if (SUCCEEDED(hr)) {
        hr = m_stImgAttachment.Load(m_AttFileName);
      } 

      if (SUCCEEDED(hr)) {
        // Success - was an image
        m_attType = ATTACHMENT_IS_IMAGE;
      }
    }

    // Create UUID if not already present
    if (!att.HasUUID())
      att.CreateUUID();
  } else {// att.HasContent()
    // This should only be the case during the InitDialog - maybe m_bInitDone
    // in the logic for this processing rather than att.HasContent
    ASSERT(!m_bInitdone);

    if (m_csMediaType.Left(5) == L"image") {
      // Should be an image file - but may not be supported by CImage - try..
      // Allocate attachment buffer
      UINT imagesize = (UINT)att.GetContentSize();
      HGLOBAL gMemory = GlobalAlloc(GMEM_MOVEABLE, imagesize);
      ASSERT(gMemory);

      if (gMemory == NULL) {
        rc = 2;
        goto load_error;
      }

      BYTE *pBuffer = (BYTE *)GlobalLock(gMemory);
      ASSERT(pBuffer);

      if (pBuffer == NULL) {
        rc = 3;
        GlobalFree(gMemory);
        goto load_error;
      }

      // Load image into buffer
      att.GetContent(pBuffer, imagesize);

      // Put it into a IStream
      IStream *pStream = NULL;
      hr = CreateStreamOnHGlobal(gMemory, FALSE, &pStream);
      if (SUCCEEDED(hr)) {
        // Load it
        hr = m_AttImage.Load(pStream);
        if (SUCCEEDED(hr)) {
          hr = m_stImgAttachment.Load(pStream);
        }
      }

      // Clean up - no real need to trash the buffer
      if (pStream != NULL)
        pStream->Release();

      GlobalUnlock(gMemory);
      GlobalFree(gMemory);

      // Check image load (or previous error of putting content into an IStream)
      if (FAILED(hr)) {
        goto load_error;
      }

      // Success - was an image
      m_attType = ATTACHMENT_IS_IMAGE;
    }
  }

  return;

load_error:
  // Ooops???
  m_stImgAttachment.IssueError(rc, hr);
}