Exemplo n.º 1
0
void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
    const NOverwriteDialog::CFileInfo &fileInfo)
{
  UString sizeString;
  if (fileInfo.SizeIsDefined)
    sizeString = MyFormatNew(IDS_FILE_SIZE,
        #ifdef LANG
        0x02000982,
        #endif
        NumberToString(fileInfo.Size));

  UString reducedName;
  const int kLineSize = 88;
  for (int i = 0; i < fileInfo.Name.Length();)
  {
    reducedName += fileInfo.Name.Mid(i, kLineSize);
    reducedName += L" ";
    i += kLineSize;
  }

  UString fullString = reducedName;
  fullString += L"\n";
  fullString += sizeString;
  fullString += L"\n";

  if (fileInfo.TimeIsDefined)
  {
    UString timeString;
    FILETIME localFileTime;
    if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
      throw 4190402;
    timeString = ConvertFileTimeToString(localFileTime);

    fullString +=
    #ifdef LANG
    LangString(IDS_FILE_MODIFIED, 0x02000983);
    #else
    MyLoadStringW(IDS_FILE_MODIFIED);
    #endif

    fullString += L" ";
    fullString += timeString;
  }

  NWindows::NControl::CDialogChildControl control;
  control.Init(*this, textID);
  control.SetText(fullString);

  SHFILEINFO shellFileInfo;
  if (::SHGetFileInfo(
      GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
      sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
  {
    NControl::CStatic staticContol;
    staticContol.Attach(GetItem(iconID));
    staticContol.SetIcon(shellFileInfo.hIcon);
  }
}
Exemplo n.º 2
0
void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
    const NOverwriteDialog::CFileInfo &fileInfo)
{
  UString sizeString;
  if (fileInfo.SizeIsDefined)
    sizeString = MyFormatNew(IDS_FILE_SIZE,
        #ifdef LANG
        0x02000982,
        #endif
        NumberToString(fileInfo.Size));

  const UString &fileName = fileInfo.Name;
  int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
  UString s1, s2;
  if (slashPos >= 0)
  {
    s1 = fileName.Left(slashPos + 1);
    s2 = fileName.Mid(slashPos + 1);
  }
  else
    s2 = fileName;
  ReduceString(s1);
  ReduceString(s2);
  
  UString fullString = s1 + L'\n' + s2;
  fullString += L'\n';
  fullString += sizeString;
  fullString += L'\n';

  if (fileInfo.TimeIsDefined)
  {
    UString timeString;
    FILETIME localFileTime;
    if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
      throw 4190402;
    timeString = ConvertFileTimeToString(localFileTime);

    fullString +=
    #ifdef LANG
    LangString(IDS_FILE_MODIFIED, 0x02000983);
    #else
    MyLoadStringW(IDS_FILE_MODIFIED);
    #endif

    fullString += L" ";
    fullString += timeString;
  }

  NWindows::NControl::CDialogChildControl control;
  control.Init(*this, textID);
  control.SetText(fullString);

  SHFILEINFO shellFileInfo;
  if (::SHGetFileInfo(
      GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
      sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
  {
    NControl::CStatic staticContol;
    staticContol.Attach(GetItem(iconID));
    staticContol.SetIcon(shellFileInfo.hIcon);
  }
}