HRESULT STDMETHODCALLTYPE CBeikeSafeInstallKavEngineDlg::OnDownloadFile( LPCWSTR lpszFileName, DWORD dwTotalSize, DWORD dwDownloadedSize) { if (0 != m_nUpdateTotalFileCount) { if (m_strUpdatingFile != lpszFileName) { m_nUpdatingFileItem ++; m_wndListProgress.SetItem(m_nUpdatingFileItem, 0, LVIF_IMAGE, NULL, 4, 0, 0, 0); m_wndListProgress.EnsureVisible(m_nUpdatingFileItem, FALSE); m_strUpdatingFile = lpszFileName; } CString strText; CString strTotalSize, strReadSize; FormatSizeString(dwTotalSize, strTotalSize); FormatSizeString(dwDownloadedSize, strReadSize); strText.Format(BkString::Get(IDS_VIRSCAN_2573), strReadSize, strTotalSize); m_wndListProgress.SetItemText(m_nUpdatingFileItem, 1, strText); _PostProgress(StepUpdate, (m_nUpdatedFileCount * dwTotalSize + dwDownloadedSize) * 100 / m_nUpdateTotalFileCount / dwTotalSize); } return m_bCancel ? E_ABORT : S_OK; }
BOOL CBeikeSafeInstallKavEngineDlg::DownloadProgress(DWORD dwTotalSize, DWORD dwReadSize) { _PostProgress(StepDownload, dwReadSize * 100 / dwTotalSize); CString strText; CString strTotalSize, strReadSize; FormatSizeString(dwTotalSize, strTotalSize); FormatSizeString(dwReadSize, strReadSize); strText.Format(BkString::Get(IDS_VIRSCAN_2573), strReadSize, strTotalSize); m_wndListProgress.SetItemText(0, 1, strText); return !m_bCancel; }
void SetRelateInfo(CRichEditCtrlEx &ctlRichEdit, T_VulListItemData *pItemData, BOOL bOfferOperate) { // Set Info Page Data ctlRichEdit.ClearText(); if(pItemData->nType==VTYPE_IGNORED) { CString str; str.Format(_T("%s,已经无效, 无需修复"), pItemData->strName); ctlRichEdit.AddText( str ); } else { CString strFileSize; FormatSizeString(pItemData->nFileSize, strFileSize); ctlRichEdit.AddText(_T("补丁名称: "), true); ctlRichEdit.AddText(pItemData->strName); ctlRichEdit.AddNewLine(); // 软件的话, 提供操作 if(pItemData->nType==VTYPE_SOFTLEAK && bOfferOperate) { ctlRichEdit.AddText(_T("操作: "), true); // int state = GetSoftItemState( pItemData ); ctlRichEdit.AddLink( SoftVulStatusOP[state] ); } else { ctlRichEdit.AddText(_T("补丁大小: "), true); ctlRichEdit.AddText(strFileSize); } ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T("发布日期: "), true); ctlRichEdit.AddText(pItemData->strPubDate); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T("漏洞影响: "), true); ctlRichEdit.AddText(pItemData->strAffects); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T("漏洞描述: "), true); ctlRichEdit.AddText(pItemData->strDesc); ctlRichEdit.AddNewLine(); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T(" ")); ctlRichEdit.AddLink(_T("了解更多")); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T("")); } }
NS_IMETHODIMP nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, nsISupports *aCtxt, nsIDirIndex *aIndex) { nsresult rv; if (!aIndex) return NS_ERROR_NULL_POINTER; nsCString pushBuffer; pushBuffer.AppendLiteral("<tr"); // We don't know the file's character set yet, so retrieve the raw bytes // which will be decoded by the HTML parser. nsXPIDLCString loc; aIndex->GetLocation(getter_Copies(loc)); // Adjust the length in case unescaping shortened the string. loc.Truncate(nsUnescapeCount(loc.BeginWriting())); if (loc.First() == char16_t('.')) pushBuffer.AppendLiteral(" class=\"hidden-object\""); pushBuffer.AppendLiteral(">\n <td sortable-data=\""); // The sort key is the name of the item, prepended by either 0, 1 or 2 // in order to group items. uint32_t type; aIndex->GetType(&type); switch (type) { case nsIDirIndex::TYPE_SYMLINK: pushBuffer.Append('0'); break; case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.Append('1'); break; default: pushBuffer.Append('2'); break; } nsAdoptingCString escaped(nsEscapeHTML(loc)); pushBuffer.Append(escaped); pushBuffer.AppendLiteral("\"><table class=\"ellipsis\"><tbody><tr><td><a class=\""); switch (type) { case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.AppendLiteral("dir"); break; case nsIDirIndex::TYPE_SYMLINK: pushBuffer.AppendLiteral("symlink"); break; default: pushBuffer.AppendLiteral("file"); break; } pushBuffer.AppendLiteral("\" href=\""); // need to escape links nsAutoCString locEscaped; // Adding trailing slash helps to recognize whether the URL points to a file // or a directory (bug #214405). if ((type == nsIDirIndex::TYPE_DIRECTORY) && (loc.Last() != '/')) { loc.Append('/'); } // now minimally re-escape the location... uint32_t escFlags; // for some protocols, we expect the location to be absolute. // if so, and if the location indeed appears to be a valid URI, then go // ahead and treat it like one. nsAutoCString scheme; if (mExpectAbsLoc && NS_SUCCEEDED(net_ExtractURLScheme(loc, scheme))) { // escape as absolute escFlags = esc_Forced | esc_AlwaysCopy | esc_Minimal; } else { // escape as relative // esc_Directory is needed because directories have a trailing slash. // Without it, the trailing '/' will be escaped, and links from within // that directory will be incorrect escFlags = esc_Forced | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory; } NS_EscapeURL(loc.get(), loc.Length(), escFlags, locEscaped); // esc_Directory does not escape the semicolons, so if a filename // contains semicolons we need to manually escape them. // This replacement should be removed in bug #473280 locEscaped.ReplaceSubstring(";", "%3b"); nsAdoptingCString htmlEscapedURL(nsEscapeHTML(locEscaped.get())); pushBuffer.Append(htmlEscapedURL); pushBuffer.AppendLiteral("\">"); if (type == nsIDirIndex::TYPE_FILE || type == nsIDirIndex::TYPE_UNKNOWN) { pushBuffer.AppendLiteral("<img src=\"moz-icon://"); int32_t lastDot = locEscaped.RFindChar('.'); if (lastDot != kNotFound) { locEscaped.Cut(0, lastDot); nsAdoptingCString htmlFileExt(nsEscapeHTML(locEscaped.get())); pushBuffer.Append(htmlFileExt); } else { pushBuffer.AppendLiteral("unknown"); } pushBuffer.AppendLiteral("?size=16\" alt=\""); nsXPIDLString altText; rv = mBundle->GetStringFromName(MOZ_UTF16("DirFileLabel"), getter_Copies(altText)); if (NS_FAILED(rv)) return rv; AppendNonAsciiToNCR(altText, pushBuffer); pushBuffer.AppendLiteral("\">"); } pushBuffer.Append(escaped); pushBuffer.AppendLiteral("</a></td></tr></tbody></table></td>\n <td"); if (type == nsIDirIndex::TYPE_DIRECTORY || type == nsIDirIndex::TYPE_SYMLINK) { pushBuffer.Append('>'); } else { int64_t size; aIndex->GetSize(&size); if (uint64_t(size) != UINT64_MAX) { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(size); pushBuffer.AppendLiteral("\">"); nsAutoCString sizeString; FormatSizeString(size, sizeString); pushBuffer.Append(sizeString); } else { pushBuffer.Append('>'); } } pushBuffer.AppendLiteral("</td>\n <td"); PRTime t; aIndex->GetLastModified(&t); if (t == -1LL) { pushBuffer.AppendLiteral("></td>\n <td>"); } else { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(static_cast<int64_t>(t)); pushBuffer.AppendLiteral("\">"); nsAutoString formatted; mDateTime->FormatPRTime(nullptr, kDateFormatShort, kTimeFormatNone, t, formatted); AppendNonAsciiToNCR(formatted, pushBuffer); pushBuffer.AppendLiteral("</td>\n <td>"); mDateTime->FormatPRTime(nullptr, kDateFormatNone, kTimeFormatSeconds, t, formatted); // use NCR to show date in any doc charset AppendNonAsciiToNCR(formatted, pushBuffer); } pushBuffer.AppendLiteral("</td>\n</tr>"); return SendToListener(aRequest, aCtxt, pushBuffer); }
INT_PTR CSplitFileDialog::OnInitDialog() { SHFILEINFO shfi; DWORD_PTR dwRes = SHGetFileInfo(m_strFullFilename.c_str(),0,&shfi,sizeof(shfi),SHGFI_ICON); if(dwRes != 0) { ICONINFO ii; GetIconInfo(shfi.hIcon,&ii); SendDlgItemMessage(m_hDlg,IDC_SPLIT_STATIC_ICON,STM_SETIMAGE, IMAGE_BITMAP,reinterpret_cast<LPARAM>(ii.hbmColor)); DeleteObject(ii.hbmColor); DeleteObject(ii.hbmMask); DestroyIcon(shfi.hIcon); } SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_FILENAME,m_strFullFilename.c_str()); HANDLE hFile = CreateFile(m_strFullFilename.c_str(),GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); if(hFile != INVALID_HANDLE_VALUE) { LARGE_INTEGER lFileSize; GetFileSizeEx(hFile,&lFileSize); ULARGE_INTEGER ulFileSize; ulFileSize.QuadPart = lFileSize.QuadPart; TCHAR szFileSize[32]; FormatSizeString(ulFileSize,szFileSize,SIZEOF_ARRAY(szFileSize)); SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_FILESIZE,szFileSize); CloseHandle(hFile); } TCHAR szOutputDirectory[MAX_PATH]; StringCchCopy(szOutputDirectory,SIZEOF_ARRAY(szOutputDirectory),m_strFullFilename.c_str()); PathRemoveFileSpec(szOutputDirectory); SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_OUTPUT,szOutputDirectory); HWND hComboBox = GetDlgItem(m_hDlg,IDC_SPLIT_COMBOBOX_SIZES); int iPos; TCHAR szTemp[64]; LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_BYTES,szTemp,SIZEOF_ARRAY(szTemp)); iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp))); m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_BYTES)); LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_KB,szTemp,SIZEOF_ARRAY(szTemp)); iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp))); m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_KB)); LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_MB,szTemp,SIZEOF_ARRAY(szTemp)); iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp))); m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_MB)); LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_GB,szTemp,SIZEOF_ARRAY(szTemp)); iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp))); m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_GB)); SendMessage(hComboBox,CB_SELECTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(m_psfdps->m_strSplitGroup.c_str())); HWND hEditSize = GetDlgItem(m_hDlg,IDC_SPLIT_EDIT_SIZE); SetWindowText(hEditSize,m_psfdps->m_strSplitSize.c_str()); SendMessage(hEditSize,EM_SETSEL,0,-1); SetFocus(hEditSize); TCHAR szOutputFilename[MAX_PATH]; StringCchCopy(szOutputFilename,SIZEOF_ARRAY(szOutputFilename),m_strFullFilename.c_str()); PathStripPath(szOutputFilename); StringCchPrintf(szOutputFilename,SIZEOF_ARRAY(szOutputFilename),_T("%s.part%s"), szOutputFilename,NSplitFileDialog::COUNTER_PATTERN); SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_OUTPUTFILENAME,szOutputFilename); HFONT hCurentFont = reinterpret_cast<HFONT>(SendDlgItemMessage(m_hDlg, IDC_SPLIT_STATIC_FILENAMEHELPER,WM_GETFONT,0,0)); LOGFONT lf; GetObject(hCurentFont,sizeof(lf),reinterpret_cast<LPVOID>(&lf)); lf.lfItalic = TRUE; m_hHelperTextFont = CreateFontIndirect(&lf); SendDlgItemMessage(m_hDlg,IDC_SPLIT_STATIC_FILENAMEHELPER, WM_SETFONT,reinterpret_cast<WPARAM>(m_hHelperTextFont),MAKEWORD(TRUE,0)); SetDlgItemText(m_hDlg,IDC_SPLIT_STATIC_ELAPSEDTIME,_T("00:00:00")); m_psfdps->RestoreDialogPosition(m_hDlg,false); return 0; }
INT_PTR CDestroyFilesDialog::OnInitDialog() { m_hDialogIcon = LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(IDI_MAIN_SMALL)); SetClassLongPtr(m_hDlg,GCLP_HICONSM,reinterpret_cast<LONG_PTR>(m_hDialogIcon)); HWND hListView = GetDlgItem(m_hDlg,IDC_DESTROYFILES_LISTVIEW); HIMAGELIST himlSmall; Shell_GetImageLists(NULL,&himlSmall); ListView_SetImageList(hListView,himlSmall,LVSIL_SMALL); SetWindowTheme(hListView,L"Explorer",NULL); ListView_SetExtendedListViewStyleEx(hListView, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); LVCOLUMN lvColumn; TCHAR szTemp[128]; LoadString(GetInstance(),IDS_DESTROY_FILES_COLUMN_FILE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,0,&lvColumn); LoadString(GetInstance(),IDS_DESTROY_FILES_COLUMN_TYPE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,1,&lvColumn); LoadString(GetInstance(),IDS_DESTROY_FILES_COLUMN_SIZE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,2,&lvColumn); LoadString(GetInstance(),IDS_DESTROY_FILES_COLUMN_DATE_MODIFIED, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,3,&lvColumn); int iItem = 0; for each(auto strFullFilename in m_FullFilenameList) { TCHAR szFullFilename[MAX_PATH]; StringCchCopy(szFullFilename,SIZEOF_ARRAY(szFullFilename), strFullFilename.c_str()); /* TODO: Perform in background thread. */ SHFILEINFO shfi; SHGetFileInfo(szFullFilename,0,&shfi,sizeof(shfi),SHGFI_SYSICONINDEX| SHGFI_TYPENAME); LVITEM lvItem; lvItem.mask = LVIF_TEXT|LVIF_IMAGE; lvItem.iItem = iItem; lvItem.iSubItem = 0; lvItem.pszText = szFullFilename; lvItem.iImage = shfi.iIcon; ListView_InsertItem(hListView,&lvItem); ListView_SetItemText(hListView,iItem,1,shfi.szTypeName); WIN32_FILE_ATTRIBUTE_DATA wfad; GetFileAttributesEx(szFullFilename,GetFileExInfoStandard,&wfad); TCHAR szFileSize[32]; ULARGE_INTEGER lFileSize = {wfad.nFileSizeLow,wfad.nFileSizeHigh}; FormatSizeString(lFileSize,szFileSize,SIZEOF_ARRAY(szFileSize)); ListView_SetItemText(hListView,iItem,2,szFileSize); TCHAR szDateModified[32]; CreateFileTimeString(&wfad.ftLastWriteTime,szDateModified, SIZEOF_ARRAY(szDateModified),m_bShowFriendlyDates); ListView_SetItemText(hListView,iItem,3,szDateModified); iItem++; }
void SetRelateInfo(CRichEditCtrlEx &ctlRichEdit, T_VulListItemData *pItemData, BOOL bOfferOperate) { // Set Info Page Data ctlRichEdit.ClearText(); if(pItemData->nType==VTYPE_IGNORED) { CString str; str.Format(BkString::Get(IDS_VULFIX_5116), pItemData->strName); ctlRichEdit.AddText( str ); } else { CString strText; // 软件的话, 提供操作 if(pItemData->nType==VTYPE_SOFTLEAK) { ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5117), true); ctlRichEdit.AddText( pItemData->strName ); ctlRichEdit.AddNewLine(); if(bOfferOperate) { ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5118), true); int state = GetSoftItemState( pItemData ); ctlRichEdit.AddText( SoftVulStatusOP[state] ); ctlRichEdit.AddNewLine(); } ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5119), true); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5120)); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5121), true); ctlRichEdit.AddText(pItemData->strDesc); } else { FormatKBString(pItemData->nID, strText); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5122), true); ctlRichEdit.AddText(strText); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5123), true); ctlRichEdit.AddText(pItemData->strMSID); ctlRichEdit.AddNewLine(); FormatSizeString(pItemData->nFileSize, strText); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5124), true); ctlRichEdit.AddText(strText); ctlRichEdit.AddNewLine(); // ctlRichEdit.AddText(_T("发布日期:"), true); // ctlRichEdit.AddText(pItemData->strPubDate); // ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5125), true); // ctlRichEdit.AddNewLine(); COLORREF clr=RGB(255,0,0); ctlRichEdit.AddText(pItemData->strAffects,FALSE,&clr); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5126), true); if ( !pItemData->isIgnored && pItemData->nWarnLevel > 0 ) ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5120)); else ctlRichEdit.AddText(pItemData->strSuggest); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5127), true); // ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(pItemData->strDesc); } ctlRichEdit.AddNewLine(); ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T(" ")); ctlRichEdit.AddLink(BkString::Get(IDS_VULFIX_5128)); if( !pItemData->strDownloadUrl.IsEmpty() ) { ctlRichEdit.AddText(_T(" ")); ctlRichEdit.AddLink(BkString::Get(IDS_VULFIX_5129)); } ctlRichEdit.AddNewLine(); ctlRichEdit.AddText(_T(" ")); ctlRichEdit.EndLink(); } }
NS_IMETHODIMP nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, nsISupports *aCtxt, nsIDirIndex *aIndex) { nsresult rv; if (!aIndex) return NS_ERROR_NULL_POINTER; nsString pushBuffer; pushBuffer.AppendLiteral("<tr"); nsXPIDLString description; aIndex->GetDescription(getter_Copies(description)); if (description.First() == PRUnichar('.')) pushBuffer.AppendLiteral(" class=\"hidden-object\""); pushBuffer.AppendLiteral(">\n <td sortable-data=\""); // The sort key is the name of the item, prepended by either 0, 1 or 2 // in order to group items. PRUint32 type; aIndex->GetType(&type); switch (type) { case nsIDirIndex::TYPE_SYMLINK: pushBuffer.AppendInt(0); break; case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.AppendInt(1); break; case nsIDirIndex::TYPE_FILE: case nsIDirIndex::TYPE_UNKNOWN: pushBuffer.AppendInt(2); break; } PRUnichar* escaped = nsEscapeHTML2(description.get(), description.Length()); pushBuffer.Append(escaped); pushBuffer.AppendLiteral("\"><a class=\""); switch (type) { case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.AppendLiteral("dir"); break; case nsIDirIndex::TYPE_SYMLINK: pushBuffer.AppendLiteral("symlink"); break; case nsIDirIndex::TYPE_FILE: case nsIDirIndex::TYPE_UNKNOWN: pushBuffer.AppendLiteral("file"); break; } pushBuffer.AppendLiteral("\""); // Truncate long names to not stretch the table //XXX this should be left to the stylesheet (bug 391471) nsString escapedShort; if (description.Length() > 71) { nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); nsCOMPtr<nsIURI> uri; rv = channel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; //XXX this potentially truncates after a combining char (bug 391472) nsXPIDLString descriptionAffix; descriptionAffix.Assign(description); descriptionAffix.Cut(0, descriptionAffix.Length() - 25); if (NS_IS_LOW_SURROGATE(descriptionAffix.First())) descriptionAffix.Cut(0, 1); description.Truncate(NS_MIN<PRUint32>(71, description.Length() - 28)); if (NS_IS_HIGH_SURROGATE(description.Last())) description.Truncate(description.Length() - 1); escapedShort.Adopt(nsEscapeHTML2(description.get(), description.Length())); escapedShort.Append(mEscapedEllipsis); // add ZERO WIDTH SPACE (U+200B) for wrapping escapedShort.AppendLiteral("​"); nsString tmp; tmp.Adopt(nsEscapeHTML2(descriptionAffix.get(), descriptionAffix.Length())); escapedShort.Append(tmp); pushBuffer.AppendLiteral(" title=\""); pushBuffer.Append(escaped); pushBuffer.AppendLiteral("\""); } if (escapedShort.IsEmpty()) escapedShort.Assign(escaped); nsMemory::Free(escaped); pushBuffer.AppendLiteral(" href=\""); nsXPIDLCString loc; aIndex->GetLocation(getter_Copies(loc)); if (!mTextToSubURI) { mTextToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; } nsXPIDLCString encoding; rv = mParser->GetEncoding(getter_Copies(encoding)); if (NS_FAILED(rv)) return rv; nsXPIDLString unEscapeSpec; rv = mTextToSubURI->UnEscapeAndConvert(encoding, loc, getter_Copies(unEscapeSpec)); if (NS_FAILED(rv)) return rv; // need to escape links nsCAutoString escapeBuf; NS_ConvertUTF16toUTF8 utf8UnEscapeSpec(unEscapeSpec); // Adding trailing slash helps to recognize whether the URL points to a file // or a directory (bug #214405). if ((type == nsIDirIndex::TYPE_DIRECTORY) && (utf8UnEscapeSpec.Last() != '/')) { utf8UnEscapeSpec.Append('/'); } // now minimally re-escape the location... PRUint32 escFlags; // for some protocols, we expect the location to be absolute. // if so, and if the location indeed appears to be a valid URI, then go // ahead and treat it like one. if (mExpectAbsLoc && NS_SUCCEEDED(net_ExtractURLScheme(utf8UnEscapeSpec, nsnull, nsnull, nsnull))) { // escape as absolute escFlags = esc_Forced | esc_OnlyASCII | esc_AlwaysCopy | esc_Minimal; } else { // escape as relative // esc_Directory is needed because directories have a trailing slash. // Without it, the trailing '/' will be escaped, and links from within // that directory will be incorrect escFlags = esc_Forced | esc_OnlyASCII | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory; } NS_EscapeURL(utf8UnEscapeSpec.get(), utf8UnEscapeSpec.Length(), escFlags, escapeBuf); // esc_Directory does not escape the semicolons, so if a filename // contains semicolons we need to manually escape them. // This replacement should be removed in bug #473280 escapeBuf.ReplaceSubstring(";", "%3b"); NS_ConvertUTF8toUTF16 utf16URI(escapeBuf); nsString htmlEscapedURL; htmlEscapedURL.Adopt(nsEscapeHTML2(utf16URI.get(), utf16URI.Length())); pushBuffer.Append(htmlEscapedURL); pushBuffer.AppendLiteral("\">"); if (type == nsIDirIndex::TYPE_FILE || type == nsIDirIndex::TYPE_UNKNOWN) { pushBuffer.AppendLiteral("<img src=\"moz-icon://"); PRInt32 lastDot = escapeBuf.RFindChar('.'); if (lastDot != kNotFound) { escapeBuf.Cut(0, lastDot); NS_ConvertUTF8toUTF16 utf16EscapeBuf(escapeBuf); nsString htmlFileExt; htmlFileExt.Adopt(nsEscapeHTML2(utf16EscapeBuf.get(), utf16EscapeBuf.Length())); pushBuffer.Append(htmlFileExt); } else { pushBuffer.AppendLiteral("unknown"); } pushBuffer.AppendLiteral("?size=16\" alt=\""); nsXPIDLString altText; rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirFileLabel").get(), getter_Copies(altText)); if (NS_FAILED(rv)) return rv; AppendNonAsciiToNCR(altText, pushBuffer); pushBuffer.AppendLiteral("\">"); } pushBuffer.Append(escapedShort); pushBuffer.AppendLiteral("</a></td>\n <td"); if (type == nsIDirIndex::TYPE_DIRECTORY || type == nsIDirIndex::TYPE_SYMLINK) { pushBuffer.AppendLiteral(">"); } else { PRInt64 size; aIndex->GetSize(&size); if (PRUint64(size) != LL_MAXUINT) { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(size); pushBuffer.AppendLiteral("\">"); nsAutoString sizeString; FormatSizeString(size, sizeString); pushBuffer.Append(sizeString); } else { pushBuffer.AppendLiteral(">"); } } pushBuffer.AppendLiteral("</td>\n <td"); PRTime t; aIndex->GetLastModified(&t); if (t == -1) { pushBuffer.AppendLiteral("></td>\n <td>"); } else { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(t); pushBuffer.AppendLiteral("\">"); nsAutoString formatted; mDateTime->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNone, t, formatted); AppendNonAsciiToNCR(formatted, pushBuffer); pushBuffer.AppendLiteral("</td>\n <td>"); mDateTime->FormatPRTime(nsnull, kDateFormatNone, kTimeFormatSeconds, t, formatted); // use NCR to show date in any doc charset AppendNonAsciiToNCR(formatted, pushBuffer); } pushBuffer.AppendLiteral("</td>\n</tr>"); return FormatInputStream(aRequest, aCtxt, pushBuffer); }
void FormatSizeString(ULARGE_INTEGER lFileSize, TCHAR *pszFileSize, size_t cchBuf) { FormatSizeString(lFileSize, pszFileSize, cchBuf, FALSE, SIZE_FORMAT_NONE); }
NS_IMETHODIMP nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, nsISupports *aCtxt, nsIDirIndex *aIndex) { nsresult rv; if (!aIndex) return NS_ERROR_NULL_POINTER; nsString pushBuffer; pushBuffer.AppendLiteral("<tr"); nsXPIDLString description; aIndex->GetDescription(getter_Copies(description)); if (description.First() == char16_t('.')) pushBuffer.AppendLiteral(" class=\"hidden-object\""); pushBuffer.AppendLiteral(">\n <td sortable-data=\""); // The sort key is the name of the item, prepended by either 0, 1 or 2 // in order to group items. uint32_t type; aIndex->GetType(&type); switch (type) { case nsIDirIndex::TYPE_SYMLINK: pushBuffer.AppendInt(0); break; case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.AppendInt(1); break; case nsIDirIndex::TYPE_FILE: case nsIDirIndex::TYPE_UNKNOWN: pushBuffer.AppendInt(2); break; } char16_t* escaped = nsEscapeHTML2(description.get(), description.Length()); pushBuffer.Append(escaped); pushBuffer.AppendLiteral("\"><a class=\""); switch (type) { case nsIDirIndex::TYPE_DIRECTORY: pushBuffer.AppendLiteral("dir"); break; case nsIDirIndex::TYPE_SYMLINK: pushBuffer.AppendLiteral("symlink"); break; case nsIDirIndex::TYPE_FILE: case nsIDirIndex::TYPE_UNKNOWN: pushBuffer.AppendLiteral("file"); break; } pushBuffer.AppendLiteral("\""); // Truncate long names to not stretch the table //XXX this should be left to the stylesheet (bug 391471) nsString escapedShort; if (description.Length() > 71) { nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); nsCOMPtr<nsIURI> uri; rv = channel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; //XXX this potentially truncates after a combining char (bug 391472) nsXPIDLString descriptionAffix; descriptionAffix.Assign(description); descriptionAffix.Cut(0, descriptionAffix.Length() - 25); if (NS_IS_LOW_SURROGATE(descriptionAffix.First())) descriptionAffix.Cut(0, 1); description.Truncate(std::min<uint32_t>(71, description.Length() - 28)); if (NS_IS_HIGH_SURROGATE(description.Last())) description.Truncate(description.Length() - 1); escapedShort.Adopt(nsEscapeHTML2(description.get(), description.Length())); escapedShort.Append(mEscapedEllipsis); // add ZERO WIDTH SPACE (U+200B) for wrapping escapedShort.AppendLiteral("​"); nsString tmp; tmp.Adopt(nsEscapeHTML2(descriptionAffix.get(), descriptionAffix.Length())); escapedShort.Append(tmp); pushBuffer.AppendLiteral(" title=\""); pushBuffer.Append(escaped); pushBuffer.AppendLiteral("\""); } if (escapedShort.IsEmpty()) escapedShort.Assign(escaped); nsMemory::Free(escaped); pushBuffer.AppendLiteral(" href=\""); nsXPIDLCString loc; aIndex->GetLocation(getter_Copies(loc)); nsXPIDLCString encoding; rv = mParser->GetEncoding(getter_Copies(encoding)); if (NS_FAILED(rv)) return rv; // Don't byte-to-Unicode conversion here, it is lossy. loc.SetLength(nsUnescapeCount(loc.BeginWriting())); // need to escape links nsAutoCString locEscaped; // Adding trailing slash helps to recognize whether the URL points to a file // or a directory (bug #214405). if ((type == nsIDirIndex::TYPE_DIRECTORY) && (loc.Last() != '/')) { loc.Append('/'); } // now minimally re-escape the location... uint32_t escFlags; // for some protocols, we expect the location to be absolute. // if so, and if the location indeed appears to be a valid URI, then go // ahead and treat it like one. if (mExpectAbsLoc && NS_SUCCEEDED(net_ExtractURLScheme(loc, nullptr, nullptr, nullptr))) { // escape as absolute escFlags = esc_Forced | esc_OnlyASCII | esc_AlwaysCopy | esc_Minimal; } else { // escape as relative // esc_Directory is needed because directories have a trailing slash. // Without it, the trailing '/' will be escaped, and links from within // that directory will be incorrect escFlags = esc_Forced | esc_OnlyASCII | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory; } NS_EscapeURL(loc.get(), loc.Length(), escFlags, locEscaped); // esc_Directory does not escape the semicolons, so if a filename // contains semicolons we need to manually escape them. // This replacement should be removed in bug #473280 locEscaped.ReplaceSubstring(";", "%3b"); nsAutoString utf16URI; if (encoding.EqualsLiteral("UTF-8")) { // Try to convert non-ASCII bytes to Unicode using UTF-8 decoder. nsCOMPtr<nsIUnicodeDecoder> decoder = mozilla::dom::EncodingUtils::DecoderForEncoding("UTF-8"); decoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal); int32_t len = locEscaped.Length(); int32_t outlen = 0; rv = decoder->GetMaxLength(locEscaped.get(), len, &outlen); if (NS_FAILED(rv)) { return rv; } nsAutoArrayPtr<char16_t> outbuf(new char16_t[outlen]); rv = decoder->Convert(locEscaped.get(), &len, outbuf, &outlen); // Use the result only if the sequence is valid as UTF-8. if (rv == NS_OK) { utf16URI.Append(outbuf, outlen); } } if (utf16URI.IsEmpty()) { // Escape all non-ASCII bytes to preserve the raw value. nsAutoCString outstr; NS_EscapeURL(locEscaped, esc_AlwaysCopy | esc_OnlyNonASCII, outstr); CopyASCIItoUTF16(outstr, utf16URI); } nsString htmlEscapedURL; htmlEscapedURL.Adopt(nsEscapeHTML2(utf16URI.get(), utf16URI.Length())); pushBuffer.Append(htmlEscapedURL); pushBuffer.AppendLiteral("\">"); if (type == nsIDirIndex::TYPE_FILE || type == nsIDirIndex::TYPE_UNKNOWN) { pushBuffer.AppendLiteral("<img src=\"moz-icon://"); int32_t lastDot = locEscaped.RFindChar('.'); if (lastDot != kNotFound) { locEscaped.Cut(0, lastDot); NS_ConvertUTF8toUTF16 utf16LocEscaped(locEscaped); nsString htmlFileExt; htmlFileExt.Adopt(nsEscapeHTML2(utf16LocEscaped.get(), utf16LocEscaped.Length())); pushBuffer.Append(htmlFileExt); } else { pushBuffer.AppendLiteral("unknown"); } pushBuffer.AppendLiteral("?size=16\" alt=\""); nsXPIDLString altText; rv = mBundle->GetStringFromName(MOZ_UTF16("DirFileLabel"), getter_Copies(altText)); if (NS_FAILED(rv)) return rv; AppendNonAsciiToNCR(altText, pushBuffer); pushBuffer.AppendLiteral("\">"); } pushBuffer.Append(escapedShort); pushBuffer.AppendLiteral("</a></td>\n <td"); if (type == nsIDirIndex::TYPE_DIRECTORY || type == nsIDirIndex::TYPE_SYMLINK) { pushBuffer.AppendLiteral(">"); } else { int64_t size; aIndex->GetSize(&size); if (uint64_t(size) != UINT64_MAX) { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(size); pushBuffer.AppendLiteral("\">"); nsAutoString sizeString; FormatSizeString(size, sizeString); pushBuffer.Append(sizeString); } else { pushBuffer.AppendLiteral(">"); } } pushBuffer.AppendLiteral("</td>\n <td"); PRTime t; aIndex->GetLastModified(&t); if (t == -1) { pushBuffer.AppendLiteral("></td>\n <td>"); } else { pushBuffer.AppendLiteral(" sortable-data=\""); pushBuffer.AppendInt(static_cast<int64_t>(t)); pushBuffer.AppendLiteral("\">"); nsAutoString formatted; mDateTime->FormatPRTime(nullptr, kDateFormatShort, kTimeFormatNone, t, formatted); AppendNonAsciiToNCR(formatted, pushBuffer); pushBuffer.AppendLiteral("</td>\n <td>"); mDateTime->FormatPRTime(nullptr, kDateFormatNone, kTimeFormatSeconds, t, formatted); // use NCR to show date in any doc charset AppendNonAsciiToNCR(formatted, pushBuffer); } pushBuffer.AppendLiteral("</td>\n</tr>"); return FormatInputStream(aRequest, aCtxt, pushBuffer); }
INT_PTR CMergeFilesDialog::OnInitDialog() { m_hDialogIcon = LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(IDI_MAIN_SMALL)); SetClassLongPtr(m_hDlg,GCLP_HICONSM,reinterpret_cast<LONG_PTR>(m_hDialogIcon)); std::wregex rxPattern; bool bAllMatchPattern = true; rxPattern.assign(_T(".*[\\.]?part[0-9]+"),std::regex_constants::icase); /* If the files all match the pattern .*[\\.]?part[0-9]+ (e.g. document.txt.part1), order them alphabetically. */ for each(auto strFullFilename in m_FullFilenameList) { if(!std::tr1::regex_match(strFullFilename,rxPattern)) { bAllMatchPattern = false; break; } } std::wstring strOutputFilename; if(bAllMatchPattern) { m_FullFilenameList.sort(CompareFilenames); /* Since the filenames all match the pattern, construct the output filename from the first files name. */ rxPattern.assign(_T("[\\.]?part[0-9]+"),std::regex_constants::icase); strOutputFilename = std::tr1::regex_replace(m_FullFilenameList.front(), rxPattern,std::wstring(_T(""))); } else { /* TODO: Improve output name. */ strOutputFilename = _T("output"); } TCHAR szOutputFile[MAX_PATH]; PathCombine(szOutputFile,m_strOutputDirectory.c_str(),strOutputFilename.c_str()); SetDlgItemText(m_hDlg,IDC_MERGE_EDIT_FILENAME,szOutputFile); HWND hListView = GetDlgItem(m_hDlg,IDC_MERGE_LISTVIEW); HIMAGELIST himlSmall; Shell_GetImageLists(NULL,&himlSmall); ListView_SetImageList(hListView,himlSmall,LVSIL_SMALL); SetWindowTheme(hListView,L"Explorer",NULL); ListView_SetExtendedListViewStyleEx(hListView, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); LVCOLUMN lvColumn; TCHAR szTemp[32]; LoadString(GetInstance(),IDS_MERGE_FILES_COLUMN_FILE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,0,&lvColumn); LoadString(GetInstance(),IDS_MERGE_FILES_COLUMN_TYPE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,1,&lvColumn); LoadString(GetInstance(),IDS_MERGE_FILES_COLUMN_SIZE, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,2,&lvColumn); LoadString(GetInstance(),IDS_MERGE_FILES_COLUMN_DATE_MODIFIED, szTemp,SIZEOF_ARRAY(szTemp)); lvColumn.mask = LVCF_TEXT; lvColumn.pszText = szTemp; ListView_InsertColumn(hListView,3,&lvColumn); int iItem = 0; for each(auto strFullFilename in m_FullFilenameList) { TCHAR szFullFilename[MAX_PATH]; StringCchCopy(szFullFilename,SIZEOF_ARRAY(szFullFilename), strFullFilename.c_str()); /* TODO: Perform in background thread. */ SHFILEINFO shfi; SHGetFileInfo(szFullFilename,0,&shfi,sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_TYPENAME); LVITEM lvItem; lvItem.mask = LVIF_TEXT|LVIF_IMAGE; lvItem.iItem = iItem; lvItem.iSubItem = 0; lvItem.pszText = szFullFilename; lvItem.iImage = shfi.iIcon; ListView_InsertItem(hListView,&lvItem); ListView_SetItemText(hListView,iItem,1,shfi.szTypeName); WIN32_FILE_ATTRIBUTE_DATA wfad; GetFileAttributesEx(szFullFilename,GetFileExInfoStandard,&wfad); TCHAR szFileSize[32]; ULARGE_INTEGER lFileSize = {wfad.nFileSizeLow,wfad.nFileSizeHigh}; FormatSizeString(lFileSize,szFileSize,SIZEOF_ARRAY(szFileSize)); ListView_SetItemText(hListView,iItem,2,szFileSize); TCHAR szDateModified[32]; CreateFileTimeString(&wfad.ftLastWriteTime,szDateModified, SIZEOF_ARRAY(szDateModified),m_bShowFriendlyDates); ListView_SetItemText(hListView,iItem,3,szDateModified); iItem++; }
void CDlgTipDetail::OnPaint(CDCHandle dc) { PAINTSTRUCT ps; HDC hDC = ::BeginPaint( m_hWnd, &ps ); Gdiplus::Graphics grap(hDC); Gdiplus::Image *pImg = NULL; CDC memDC(hDC); int nDownHeightPos = m_rcClient.Height() - 27; memDC.SetBkMode(TRANSPARENT); pImg = BkPngPool::Get(IDP_VUL_TIP_HEAD); grap.DrawImage(pImg, 0,0); pImg = BkPngPool::Get(IDP_VUL_TIP_DOWN); grap.DrawImage(pImg, 0, nDownHeightPos); pImg = BkPngPool::Get(IDP_VUL_TIP_CLOSE); if (m_nCloseState == -1) { grap.DrawImage(pImg, m_rcCloseBtn.left, m_rcCloseBtn.top); } CRect rcGrant(0,84, DEF_VUL_TIP_DETAIL_WIDTH, nDownHeightPos); _DrawGradualColorRect(memDC, rcGrant,RGB(0xE4, 0xF0, 0xFE), RGB(0xD7, 0xE6, 0xF9), TRUE); _DrawLine(memDC, CPoint(0,0), CPoint(0,m_rcClient.Height()), RGB(0x87, 0x98, 0xA8)); _DrawLine(memDC, CPoint(DEF_VUL_TIP_DETAIL_WIDTH - 1, 0), CPoint(DEF_VUL_TIP_DETAIL_WIDTH - 1, m_rcClient.Height()), RGB(0x87, 0x98, 0xA8)); HFONT hHeadFont = BkFontPool::GetFont(TRUE, FALSE, FALSE, 1); HFONT hNormalFont = BkFontPool::GetFont(FALSE, FALSE, FALSE); CString strTitle; CString strTmp = BkString::Get(IDS_VULFIX_5019); FormatKBString(m_pItemData->nID, strTitle); strTitle = strTmp + _T(":") + strTitle; CRect rcText(13, 10, 220, 25); CRect rcTemp; _DrawText(memDC, rcText, strTitle, RGB(0x0, 0x0, 0x0), hHeadFont); rcText.SetRect(15, 32, 200, 47); strTmp = BkString::Get(IDS_VULFIX_5021); strTitle = strTmp + _T(":") + m_pItemData->strPubDate; _DrawText(memDC, rcText, strTitle, RGB(0x44, 0x61, 0x83), hNormalFont); // 大小 rcText.SetRect(275,32,DEF_VUL_TIP_DETAIL_WIDTH,47); FormatSizeString(m_pItemData->nFileSize, strTitle); strTmp = BkString::Get(IDS_VULFIX_5124); strTitle = strTmp + strTitle; _DrawText(memDC, rcText, strTitle, RGB(0x44, 0x61, 0x83), hNormalFont); // 绘制小点 和 描述文字 pImg = BkPngPool::Get(IDP_VUL_TIP_POINT); CRect rcContent(15, 72, DEF_VUL_TIP_DETAIL_WIDTH, 72 + 15); if (!m_pItemData->strMSID.IsEmpty()) { grap.DrawImage(pImg, rcContent.left, rcContent.top + 5); strTmp = BkString::Get(IDS_VULFIX_5123); strTmp += m_pItemData->strMSID; rcContent.left += 10; _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont); rcContent.top += 17; rcContent.bottom += 17; rcContent.left = 15; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; } grap.DrawImage(pImg, rcContent.left, rcContent.top + 5); rcContent.left += 10; strTmp = BkString::Get(IDS_VULFIX_5125); _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont); rcContent.left = rcContent.right; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; CString strAff = m_pItemData->strAffects; if (strAff.GetLength() < 25) { _DrawText(memDC, rcContent, strAff, RGB(255, 0, 0), hNormalFont); } else { strTmp = strAff.Mid(0, 25); _DrawText(memDC, rcContent, strTmp, RGB(255, 0, 0), hNormalFont); strAff = strAff.Mid(25); while(1) { if (strAff.GetLength() > 0) { int len = strAff.GetLength(); rcContent.top += 17; rcContent.bottom += 17; rcContent.left = 25; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; if (strAff.GetLength() > 30) len = 30; strTmp = strAff.Mid(0, len); _DrawText(memDC, rcContent, strTmp, RGB(255, 0, 0), hNormalFont); strAff = strAff.Mid(len); } else { break; } } } // 描述 rcContent.top += 17; rcContent.bottom += 17; rcContent.left = 15; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; grap.DrawImage(pImg, rcContent.left, rcContent.top + 5); rcContent.left += 10; strTmp = BkString::Get(IDS_VULFIX_5172); _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont); rcContent.left = rcContent.right; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; CString strDes = m_pItemData->strDesc; if (strDes.GetLength() < 25) { _DrawText(memDC, rcContent, strDes, RGB(0, 0, 0), hNormalFont); } else { HFONT oldFont = memDC.SelectFont(hNormalFont);; int len = 25; strTmp = strDes.Mid(0, len); int nCount = 0; while(1) { CSize nSize; memDC.GetTextExtent(strTmp, -1, &nSize); if (rcContent.left + nSize.cx < DEF_VUL_TIP_DETAIL_WIDTH - 30) { if (len < strDes.GetLength()) { ++len; strTmp = strDes.Mid(0, len); } else { break; } } else break; } _DrawText(memDC, rcContent, strTmp, RGB(0, 0, 0), hNormalFont); strDes = strDes.Mid(len); while(1) { if (nCount >= 2) { break; } if (strDes.GetLength() > 0) { int len = strDes.GetLength(); rcContent.left = 25; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; if (strDes.GetLength() > 30) len = 30; else break; strTmp = strDes.Mid(0, len); // 文字可能是混合的,从个数到计算长度来确定本行的个数。 while(1) { CSize nSize; memDC.GetTextExtent(strTmp, -1, &nSize); if (rcContent.left + nSize.cx < DEF_VUL_TIP_DETAIL_WIDTH - 30) { if (len < strDes.GetLength()) { ++len; strTmp = strDes.Mid(0, len); } else { break; } } else break; } if (len == strDes.GetLength()) break; rcContent.top += 17; rcContent.bottom += 17; _DrawText(memDC, rcContent, strTmp, RGB(0, 0, 0), hNormalFont); strDes = strDes.Mid(len); } else { break; } nCount ++; } memDC.SelectFont(oldFont); } CSize nSize; rcContent.top += 17; rcContent.bottom += 17; rcContent.left = 25; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; memDC.GetTextExtent(strDes, -1, &nSize); if (rcContent.left + nSize.cx > DEF_VUL_TIP_DETAIL_WIDTH - 90) rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH - 90; _DrawText(memDC, rcContent, strDes, RGB(0, 0, 0), hNormalFont); rcContent.left = rcContent.right; rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH; _DrawText(memDC, rcContent, BkString::Get(IDS_VULFIX_5128), RGB(0x33, 0x62, 0x9A), BkFontPool::GetFont(FALSE, TRUE ,FALSE)); ::CopyRect(m_rcDetail, rcContent); // draw link HFONT hLinkFont = BkFontPool::GetFont(FALSE, TRUE, FALSE); CRect rcLink; COLORREF clrLink = RGB(0x33, 0x62, 0x9A); rcLink.SetRect(15, m_rcClient.Height() - 20, 300, m_rcClient.Height() - 5); _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5170), clrLink, hLinkFont); ::CopyRect(m_rcQuestion, rcLink); rcLink.left = 250; rcLink.right = DEF_VUL_TIP_DETAIL_WIDTH; _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5129), clrLink, hLinkFont); ::CopyRect(m_rcOfficial, rcLink); rcLink.left = 325; rcLink.right = DEF_VUL_TIP_DETAIL_WIDTH; _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5171), clrLink, hLinkFont); ::CopyRect(m_rcIgnoreVul, rcLink); ::EndPaint( m_hWnd, &ps ); }