/** * \brief Start parsing. * \param LogProc A Pointer to the logging procedure. */ void CAuxParser::Parse(PFNLOGPROC LogProc) { m_LogProc = LogProc; m_Errors = 0; m_BibData.Empty(); m_BibStyle.Empty(); CString str; if (!m_AuxFile.IsEmpty()) { CFile f; CFileException ex; if (f.Open(m_AuxFile, CFile::modeRead | CFile::shareDenyWrite, &ex)) { str.Format(AfxLoadString(IDS_STRING_PARSING), m_AuxFile); AddLog(str); CBibReader reader(&f); ParseFile(&reader); f.Close(); } else { m_Errors++; TCHAR msg[MAX_PATH]; ex.GetErrorMessage(msg, MAX_PATH); str.Format(AfxLoadString(IDS_STRING_ERROR), msg); AddLog(str); } } }
/** * Sets the style file * * \param xsldoc Either a filename or source of XSL file */ void CXSLTransform::SetXSLDoc(CString xsldoc) { if (m_XSLDoc.Compare(xsldoc) != 0) { m_XSLDoc = xsldoc; Reset(); if (xsldoc.IsEmpty()) { return; } xmlErrorPtr err = NULL; xmlDocPtr xsl = NULL; CFileFind ff; if (xsldoc.GetLength() < MAX_PATH && ff.FindFile(xsldoc)) { // xsldoc is a filename ff.Close(); m_Style = xsltParseStylesheetFile((const xmlChar *)(LPCSTR)xsldoc); if (!m_Style || m_Style->errors > 0) { xmlFreeDoc(xsl); err = xmlGetLastError(); if (err != NULL) m_LastError.Format(AfxLoadString(IDS_STRING_XSLPARSEERR), err->file, err->line, err->int2, err->code, err->message); else m_LastError.LoadString(IDS_STRING_UNKNOWN_XSLERROR); xmlResetLastError(); #ifdef _DEBUG TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError); #endif } } else { // xsldoc is a XSL source xsl = xmlParseMemory(xsldoc, xsldoc.GetLength()); if (xsl) { m_Style = xsltParseStylesheetDoc(xsl); if (!m_Style || m_Style->errors > 0) { xmlFreeDoc(xsl); err = xmlGetLastError(); if (err != NULL) m_LastError.Format(AfxLoadString(IDS_STRING_XSLPARSEERR), err->file, err->line, err->int2, err->code, err->message); else m_LastError.LoadString(IDS_STRING_UNKNOWN_XSLERROR); xmlResetLastError(); #ifdef _DEBUG TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError); #endif } } else { // XML parsing error err = xmlGetLastError(); m_LastError.Format(AfxLoadString(IDS_STRING_XMLPARSEERR), err->file, err->line, err->int2, err->code, err->message); xmlResetLastError(); #ifdef _DEBUG TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError); #endif } } } }
void COnlineSearch::OnButtonNewprofile() { CInputBox dlg; dlg.SetCaption(AfxLoadString(IDS_STRING_NEWPROFCAP)); dlg.SetPrompt(AfxLoadString(IDS_STRING_NEWPROFPROMPT)); if (dlg.DoModal() == IDOK && !dlg.m_strText.IsEmpty()) { CString name = dlg.m_strText; CSearchProfile* profile = m_ProfilesList.New(name); int i = m_cboProfiles.AddString(name); m_cboProfiles.SetItemDataPtr(i, profile); m_cboProfiles.SetCurSel(i); OnSelchangeComboProfiles(); m_editHost.SetFocus(); } }
void CInsertHeaderDialog::OnChangeTitle() { UpdateData(); // disable label-window? m_wndLabelEdit.EnableWindow(!m_strTitle.IsEmpty()); // auto generate label BOOL bWhiteSpace = FALSE; TCHAR strC[2] = _T(" "); m_strLabel = AfxLoadString(SectionIDs[m_nDepth].second); for (int i = 0; i < m_strTitle.GetLength(); i++) { if (!_istalnum(m_strTitle[i])) bWhiteSpace = TRUE; else { strC[0] = m_strTitle[i]; m_strLabel += (bWhiteSpace ? _tcsupr(strC) : strC); //bWhiteSpace + _tcsupr ==> CamelCase bWhiteSpace = FALSE; } } UpdateData(FALSE); }
CTrayIcon::CTrayIcon(unsigned int uID) { memset(&icondata,0,sizeof(icondata)); icondata.cbSize=sizeof(icondata); icondata.uID=uID; AfxLoadString(uID,icondata.szTip,sizeof(icondata.szTip)); }
/** * \brief Add a warning. * \param msg The warning message. */ void CAuxParser::Warning(CString msg) { m_Warnings++; CString str; str.Format(AfxLoadString(IDS_STRING_WARNING), msg); AddLog(str); }
BOOL CModelessMain::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult) { ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); // allow top level routing frame to handle the message if (GetRoutingFrame() != NULL) return FALSE; // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; TCHAR szFullText[256]; CString strTipText; UINT_PTR nID = (UINT_PTR)pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { // idFrom is actually the HWND of the tool nID = ((UINT_PTR)(WORD)::GetDlgCtrlID((HWND)nID)); } if (nID != 0) // will be zero on a separator { AfxLoadString((UINT)nID, szFullText); // this is the command id, not the button index AfxExtractSubString(strTipText, szFullText, 1, '\n'); } #ifndef _UNICODE if (pNMHDR->code == TTN_NEEDTEXTA) _tcsncpy_s(pTTTA->szText, (sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0])), strTipText, _TRUNCATE); else { int n = MultiByteToWideChar(CP_ACP, 0, strTipText, -1, pTTTW->szText, sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0])); if (n > 0) pTTTW->szText[n-1] = 0; } #else if (pNMHDR->code == TTN_NEEDTEXTA) { int n = WideCharToMultiByte(CP_ACP, 0, strTipText, -1, pTTTA->szText, sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0]), NULL, NULL); if (n > 0) pTTTA->szText[n-1] = 0; } else _tcsncpy_s(pTTTW->szText, (sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0])), strTipText, _TRUNCATE); #endif *pResult = 0; // bring the tooltip window above other popup windows ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE); return TRUE; // message was handled }
BOOL CInsertHeaderDialog::SetProperties(const CString &strProperties) { const int count = sizeof(SectionIDs) / sizeof(*SectionIDs); for (int i = 0; i < count; i++) { CString strCommand = AfxLoadString(SectionIDs[i].first) + _T('{'); int nPos; if ((nPos = strProperties.Find(strCommand)) == -1) continue; // set depth m_nDepth = i; // set title m_strTitle.Empty(); for (nPos += strCommand.GetLength(); nPos < strProperties.GetLength(); nPos++) { if (strProperties[nPos] == _T('}')) break; else m_strTitle += strProperties[nPos]; } // set label m_strLabel = AfxLoadString(SectionIDs[m_nDepth].second); strCommand = _T("\\label{"); if ((nPos = strProperties.Find(strCommand)) == -1) return TRUE; m_strLabel.Empty(); for (nPos += strCommand.GetLength(); nPos < strProperties.GetLength(); nPos++) { if (strProperties[nPos] == _T('}')) break; else m_strLabel += strProperties[nPos]; } return TRUE; } return FALSE; }
////////////////// // This is the main variant for setting the icon. // Sets both the icon and tooltip from resource ID // To remove the icon, call SetIcon(0) // BOOL CTrayIcon::SetIcon(UINT uID) { HICON hicon=NULL; if (uID) { AfxLoadString(uID, m_nid.szTip, sizeof(m_nid.szTip)); hicon = AfxGetApp()->LoadIcon(uID); } return SetIcon(hicon, NULL); }
bool CTrayIcon::SetIcon(unsigned int uID) { HICON icon=NULL; if(uID) { AfxLoadString(uID,icondata.szTip,sizeof(icondata.szTip)); icon=AfxGetApp()->LoadIcon(uID); } return SetIcon(icon,NULL); }
CTrayIcon::CTrayIcon(UINT uID) { // Initialize NOTIFYICONDATA memset(&m_nid,0,sizeof(m_nid)); m_nid.cbSize = sizeof(m_nid); m_nid.uID = uID; // Use resource string as tip if there is one AfxLoadString(uID,m_nid.szTip,sizeof(m_nid.szTip)); }
// Handles TTN_NEEDTEXT message to display tooltips for the toolbar. // This code is based on CFrameWnd::OnToolTipText BOOL WindowSelector::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult) { ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); // allow top level routing frame to handle the message if (GetRoutingFrame() != NULL) return FALSE; // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; TCHAR szFullText[256]; CString strTipText; UINT nID = (UINT) pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { // idFrom is actually the HWND of the tool nID = ((UINT)(WORD)::GetDlgCtrlID((HWND)nID)); } if (nID != 0) // will be zero on a separator { AfxLoadString(nID, szFullText); // this is the command id, not the button index AfxExtractSubString(strTipText, szFullText, 1, '\n'); } #ifndef _UNICODE if (pNMHDR->code == TTN_NEEDTEXTA) // lstrcpyn(pTTTA->szText, strTipText, // (sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0]))); CopyString(pTTTA->szText, strTipText, 80); else _mbstowcsz(pTTTW->szText, strTipText, (sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0]))); #else if (pNMHDR->code == TTN_NEEDTEXTA) _wcstombsz(pTTTA->szText, strTipText, (sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0]))); else CopyString(pTTTA->szText, strTipText, 80); // lstrcpyn(pTTTW->szText, strTipText, // (sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0]))); #endif *pResult = 0; // bring the tooltip window above other popup windows ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE); return TRUE; // message was handled }
CString CInsertHeaderDialog::GetProperties() { CString strResult = _T('\r') + AfxLoadString(SectionIDs[m_nDepth].first) + _T('{'); if (!m_strTitle.IsEmpty()) { strResult += m_strTitle + _T("}\r"); if (!m_strLabel.IsEmpty()) strResult += _T("\\label{") + m_strLabel + _T("}\r"); } else strResult += _T("\001}\r"); return strResult; }
void CBibitemView::UpdateMissing() { m_lstMissingFields.ResetContent(); CStringList mf; if (m_TmpItem->GetMissingFields(&mf)) { POSITION p = mf.GetHeadPosition(); while (p) { m_lstMissingFields.AddString(mf.GetNext(p)); } m_lstMissingFields.EnableWindow(); } else { m_lstMissingFields.AddString(AfxLoadString(IDS_STRING_NOMISSING)); m_lstMissingFields.EnableWindow(FALSE); } }
BOOL CChildFrame::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult) //-------------------------------------------------------------------- { // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; TCHAR szFullText[256]; CString strTipText; ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); szFullText[0] = 0; UINT nID = pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { // idFrom is actually the HWND of the tool nID = (UINT)::GetDlgCtrlID((HWND)nID); } if ((nID >= 1000) && (nID < 10000) && (m_hWndCtrl) && (::SendMessage(m_hWndCtrl, WM_MOD_GETTOOLTIPTEXT, nID, (LPARAM)szFullText))) { strTipText = szFullText; } else { // allow top level routing frame to handle the message if (GetRoutingFrame() != NULL) return FALSE; if (nID != 0) // will be zero on a separator { AfxLoadString(nID, szFullText); // this is the command id, not the button index AfxExtractSubString(strTipText, szFullText, 1, '\n'); } } if (pNMHDR->code == TTN_NEEDTEXTA) lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText)); else _mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText)); *pResult = 0; // bring the tooltip window above other popup windows ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE; // message was handled }
void CBibitemView::OnPopupBrowse() { CString f; CString fn; CField* fi = (CField*)m_ListFields.GetItemData(m_SelField); fn = DecodeFilename(fi->GetValue()); CFileFind finder; if (!finder.FindFile(fn)) // Dialog will not show when file does not exist fn.Empty(); finder.Close(); f.Format(_T("%s||"), AfxLoadString(IDS_STRING_ALLFILTER)); CFileDialogEx dlg(TRUE, NULL, fn, OFN_HIDEREADONLY | OFN_ENABLESIZING, f, this); if (dlg.DoModal() == IDOK) { m_ListFields.SetItemText(m_SelField, 1, EncodeFilename(dlg.GetPathName())); fi->SetValue(EncodeFilename(dlg.GetPathName())); SetModified(fi->GetModified()); } }
BOOL COXHistoryCombo::OnToolTipText(UINT /* nControlID */, NMHDR* pNMHDR, LRESULT* pResult) { ASSERT_VALID(this); // This code is almost the same as in CFrameWnd::OnToolTipText // see WinFrm.cpp ASSERT(pNMHDR->code == TTN_NEEDTEXT); // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*) pNMHDR; TCHAR szFullText[256]; CString strTipText; UINT_PTR nID = pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXT && (pTTT->uFlags & TTF_IDISHWND)) { // ... idFrom is actually the HWND of the tool nID = ((UINT)(WORD)::GetDlgCtrlID((HWND)nID)); } // ... nID will be zero on a separator if (nID != 0) { // don't handle the message if no string resource found if(AfxLoadString(PtrToUint(nID),szFullText)==0) { return FALSE; } // ... this is the command id, not the button index AfxExtractSubString(strTipText, szFullText, 1, '\n'); } UTBStr::tcscpy(pTTT->szText, 80, strTipText); // Bring the tooltip window above other popup windows ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE); // Message was handled // ... Message does not use result *pResult = 0; return TRUE; }
void COptionPageLanguage::OnOptionsSpellBrowse() { CWnd *pPersonalDictionary = GetDlgItem(IDC_OPTIONS_SPELL_PDICT); CString defaultPath; pPersonalDictionary->GetWindowText(defaultPath); CFileDialog dlg(true,NULL,defaultPath,OFN_PATHMUSTEXIST, AfxLoadString(STE_FILE_DICFILTER)); if (!defaultPath.IsEmpty()) { LPTSTR pathStr = defaultPath.GetBuffer(0); ::PathRemoveFileSpec(pathStr); dlg.m_ofn.lpstrInitialDir = pathStr; defaultPath.ReleaseBuffer(); } if (dlg.DoModal() == IDOK) pPersonalDictionary->SetWindowText(dlg.GetPathName()); }
BOOL AFXAPI AfxCustomLogFont(UINT nIDS, LOGFONT* pLogFont) { ASSERT(pLogFont != NULL); ASSERT(nIDS != 0); TCHAR szFontInfo[256]; if (!AfxLoadString(nIDS, szFontInfo)) return FALSE; LPTSTR lpszSize = _tcschr(szFontInfo, '\n'); if (lpszSize != NULL) { // get point size and convert to pixels pLogFont->lfHeight = _ttoi(lpszSize+1); pLogFont->lfHeight = MulDiv(pLogFont->lfHeight, afxData.cyPixelsPerInch, 72); *lpszSize = '\0'; } lstrcpyn(pLogFont->lfFaceName, szFontInfo, LF_FACESIZE); return TRUE; }
void CBibitemView::InitDialog() { UpdateData(FALSE); InitAnchors(); m_ComboType.ResetContent(); m_SelField = -1; m_ImageList.Create(IDB_BITMAP_REQUIRED, 16, 6, RGB(255, 0, 255)); DWORD extst = m_ListFields.GetExtendedStyle(); m_ListFields.SetExtendedStyle(extst | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); m_ListFields.SetImageList(&m_ImageList, LVSIL_SMALL); CString col; col.LoadString(IDS_STRING_FIELD); m_ListFields.InsertColumn(0, col, LVCFMT_LEFT, AfxGetApp()->GetProfileInt(SETTINGS_KEY, _T("ItemView.Col1.Width"), 200)); col.LoadString(IDS_STRING_VALUE); m_ListFields.InsertColumn(1, col, LVCFMT_LEFT, AfxGetApp()->GetProfileInt(SETTINGS_KEY, _T("ItemView.Col2.Width"), 400)); m_ListFields.m_DefaultText = AfxLoadString(IDS_STRING_NEWFIELD); SetModified(FALSE); m_TmpItem = new CBibItem(GetDocument()->m_BibFile); }
void CInsertGraphicDialog::OnGraphicBrowse() { UpdateData(TRUE); CFileDialogEx dlg( TRUE,NULL,m_strFile, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, AfxLoadString(STE_GRAPHIC_FILES),this); //Get default path CString strInitialDir = AfxGetDefaultDirectory(); dlg.m_ofn.lpstrInitialDir = strInitialDir; //Show the dialog if (dlg.DoModal() != IDOK) { //It was cancelled - the PathName is not set. // Therefore, we use GetLastOpenedFolder. AfxSetLastDirectory(dlg.GetLastOpenedFolder()); return; } AfxSetLastDirectory(CPathTool::GetDirectory(dlg.GetPathName())); m_strFile = dlg.GetPathName(); //Get path relative to project dir CLaTeXProject* pLProject = theApp.GetProject(); if (pLProject) { m_strFile = CPathTool::GetRelativePath(pLProject->GetWorkingDirectory(),m_strFile); } m_strFile.Replace(_T('\\'),_T('/')); UpdateData(FALSE); OnChangePath(); }
void CBibitemView::OnPopupLocalurl() { CString f, fn; f.Format(_T("%s||"), AfxLoadString(IDS_STRING_ALLFILTER)); CFileDialogEx dlg(TRUE, NULL, fn, OFN_HIDEREADONLY | OFN_ENABLESIZING, f, this); if (dlg.DoModal() == IDOK) { CField *fi = m_TmpItem->Find(STR_LOCALURL); if (fi == NULL) { fi = m_TmpItem->New(); fi->SetName(STR_LOCALURL); fi->SetValue(EncodeFilename(dlg.GetPathName())); } else { CString val = fi->GetValue(); if (!val.IsEmpty()) val += _T("; ") + EncodeFilename(dlg.GetPathName()); else val = EncodeFilename(dlg.GetPathName()); fi->SetValue(val); } SetModified(); PopulateFields(); } }
void COlePasteSpecialDialog::AddFormat(UINT cf, DWORD tymed, UINT nFormatID, BOOL bEnableIcon, BOOL bLink) { TCHAR szFormat[256]; if (AfxLoadString(nFormatID, szFormat) == 0) AfxThrowResourceException(); // the format and result strings are delimited by a newline LPTSTR lpszResult = _tcschr(szFormat, '\n'); ASSERT(lpszResult != NULL); // must contain a newline *lpszResult = '\0'; ++lpszResult; // one char past newline // add it to the array of acceptable formats m_ps.arrPasteEntries = (OLEUIPASTEENTRY *)realloc(m_ps.arrPasteEntries, sizeof(OLEUIPASTEENTRY) * (m_ps.cPasteEntries +1)); OLEUIPASTEENTRY* pEntry = &m_ps.arrPasteEntries[m_ps.cPasteEntries]; pEntry->fmtetc.cfFormat = (CLIPFORMAT)cf; pEntry->fmtetc.dwAspect = DVASPECT_CONTENT; pEntry->fmtetc.ptd = NULL; pEntry->fmtetc.tymed = tymed; pEntry->fmtetc.lindex = -1; pEntry->lpstrFormatName = _tcsdup(szFormat); pEntry->lpstrResultText = _tcsdup(lpszResult); pEntry->dwFlags = OLEUIPASTE_PASTE; if (bEnableIcon) pEntry->dwFlags |= OLEUIPASTE_ENABLEICON; if (bLink) pEntry->dwFlags |= AddLinkEntry(cf); if (pEntry->dwFlags == OLEUIPASTE_PASTE) pEntry->dwFlags = OLEUIPASTE_PASTEONLY; pEntry->dwScratchSpace = NULL; m_ps.cPasteEntries++; }
COleConvertDialog::COleConvertDialog(COleClientItem* pItem, DWORD dwFlags, CLSID* pClassID, CWnd* pParentWnd) : COleDialog(pParentWnd) { if (pItem != NULL) ASSERT_VALID(pItem); ASSERT(pClassID == NULL || AfxIsValidAddress(pClassID, sizeof(CLSID), FALSE)); memset(&m_cv, 0, sizeof(m_cv)); // initialize structure to 0/NULL if (pClassID != NULL) m_cv.clsid = *pClassID; // fill in common part m_cv.cbStruct = sizeof(m_cv); m_cv.dwFlags = dwFlags; if (!afxData.bWin4 && AfxHelpEnabled()) m_cv.dwFlags |= CF_SHOWHELPBUTTON; m_cv.lpfnHook = AfxOleHookProc; m_nIDHelp = AFX_IDD_CONVERT; // specific to this dialog m_cv.fIsLinkedObject = pItem->GetType() == OT_LINK; m_cv.dvAspect = pItem->GetDrawAspect(); if (pClassID == NULL && !m_cv.fIsLinkedObject) { // for embeddings, attempt to get class ID from the storage if (ReadClassStg(pItem->m_lpStorage, &m_cv.clsid) == S_OK) pClassID = &m_cv.clsid; // attempt to get user type from storage CLIPFORMAT cf = 0; LPOLESTR lpOleStr = NULL; ReadFmtUserTypeStg(pItem->m_lpStorage, &cf, &lpOleStr); m_cv.lpszUserType = TASKSTRINGOLE2T(lpOleStr); m_cv.wFormat = (WORD)cf; } // get class id if neded if (pClassID == NULL) { // no class ID in the storage, use class ID of the object pItem->GetClassID(&m_cv.clsid); } // get user type if needed if (m_cv.lpszUserType == NULL) { // no user type in storge, get user type from class ID LPTSTR lpszUserType = NULL; LPOLESTR lpOleStr = NULL; if (OleRegGetUserType(m_cv.clsid, USERCLASSTYPE_FULL, &lpOleStr) == S_OK) { lpszUserType = TASKSTRINGOLE2T(lpOleStr); } else { lpszUserType = (LPTSTR)CoTaskMemAlloc(256 * sizeof(TCHAR)); if (lpszUserType != NULL) { lpszUserType[0] = '?'; lpszUserType[1] = 0; VERIFY(AfxLoadString(AFX_IDS_UNKNOWNTYPE, lpszUserType) != 0); } } m_cv.lpszUserType = lpszUserType; } m_cv.hMetaPict = pItem->GetIconicMetafile(); }
STDMETHODIMP COleUILinkInfo::GetLinkSource( DWORD dwLink, LPTSTR* lplpszDisplayName, ULONG* lplenFileName, LPTSTR* lplpszFullLinkType, LPTSTR* lplpszShortLinkType, BOOL* lpfSourceAvailable, BOOL* lpfIsSelected) { COleClientItem* pItem = (COleClientItem*)dwLink; ASSERT_VALID(pItem); ASSERT_KINDOF(COleClientItem, pItem); ASSERT(pItem->GetType() == OT_LINK); // set OUT params to NULL ASSERT(lplpszDisplayName != NULL); *lplpszDisplayName = NULL; if (lplpszFullLinkType != NULL) *lplpszFullLinkType = NULL; if (lplpszShortLinkType != NULL) *lplpszShortLinkType = NULL; if (lplenFileName != NULL) *lplenFileName = 0; if (lpfSourceAvailable != NULL) *lpfSourceAvailable = !pItem->m_bLinkUnavail; // get IOleLink interface LPOLELINK lpOleLink = QUERYINTERFACE(pItem->m_lpObject, IOleLink); ASSERT(lpOleLink != NULL); // get moniker & object information LPMONIKER lpmk; if (lpOleLink->GetSourceMoniker(&lpmk) == S_OK) { if (lplenFileName != NULL) *lplenFileName = _AfxOleGetLenFilePrefixOfMoniker(lpmk); lpmk->Release(); } // attempt to get the type names of the link if (lplpszFullLinkType != NULL) { LPOLESTR lpOleStr = NULL; pItem->m_lpObject->GetUserType(USERCLASSTYPE_FULL, &lpOleStr); *lplpszFullLinkType = TASKSTRINGOLE2T(lpOleStr); if (*lplpszFullLinkType == NULL) { TCHAR szUnknown[256]; VERIFY(AfxLoadString(AFX_IDS_UNKNOWNTYPE, szUnknown) != 0); *lplpszFullLinkType = AfxAllocTaskString(szUnknown); } } if (lplpszShortLinkType != NULL) { LPOLESTR lpOleStr = NULL; pItem->m_lpObject->GetUserType(USERCLASSTYPE_SHORT, &lpOleStr); *lplpszShortLinkType = TASKSTRINGOLE2T(lpOleStr); if (*lplpszShortLinkType == NULL) { TCHAR szUnknown[256]; VERIFY(AfxLoadString(AFX_IDS_UNKNOWNTYPE, szUnknown) != 0); *lplpszShortLinkType = AfxAllocTaskString(szUnknown); } } // get source display name for moniker LPOLESTR lpOleStr = NULL; SCODE sc = lpOleLink->GetSourceDisplayName(&lpOleStr); *lplpszDisplayName = TASKSTRINGOLE2T(lpOleStr); lpOleLink->Release(); if (sc != S_OK) return sc; // see if item is selected if specified if (lpfIsSelected) { *lpfIsSelected = (m_pSelectedItem == pItem); } return S_OK; }
HRESULT DualHandleException(REFIID riidSource, const CException* pAnyException) { USES_CONVERSION; ASSERT_VALID(pAnyException); TRACE0("DualHandleException called\n"); // Set ErrInfo object so that VTLB binding container // applications can get rich error information. ICreateErrorInfo* pcerrinfo; HRESULT hr = CreateErrorInfo(&pcerrinfo); if (SUCCEEDED(hr)) { TCHAR szDescription[256]; LPCTSTR pszDescription = szDescription; GUID guid = GUID_NULL; DWORD dwHelpContext = 0; BSTR bstrHelpFile = NULL; BSTR bstrSource = NULL; if (pAnyException->IsKindOf(RUNTIME_CLASS(COleDispatchException))) { // specific IDispatch style exception COleDispatchException* e = (COleDispatchException*)pAnyException; guid = riidSource; hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, (e->m_wCode + 0x200)); pszDescription = e->m_strDescription; dwHelpContext = e->m_dwHelpContext; // propagate source and help file if present // call ::SysAllocString directly so no further exceptions are thrown if (!e->m_strHelpFile.IsEmpty()) bstrHelpFile = ::SysAllocString(T2COLE(e->m_strHelpFile)); if (!e->m_strSource.IsEmpty()) bstrSource = ::SysAllocString(T2COLE(e->m_strSource)); } else if (pAnyException->IsKindOf(RUNTIME_CLASS(CMemoryException))) { // failed memory allocation AfxLoadString(AFX_IDP_FAILED_MEMORY_ALLOC, szDescription); hr = E_OUTOFMEMORY; } else { // other unknown/uncommon error AfxLoadString(AFX_IDP_INTERNAL_FAILURE, szDescription); hr = E_UNEXPECTED; } if (bstrHelpFile == NULL && dwHelpContext != 0) bstrHelpFile = ::SysAllocString(T2COLE(AfxGetApp()->m_pszHelpFilePath)); if (bstrSource == NULL) bstrSource = ::SysAllocString(T2COLE(AfxGetAppName())); // Set up ErrInfo object pcerrinfo->SetGUID(guid); pcerrinfo->SetDescription(::SysAllocString(T2COLE(pszDescription))); pcerrinfo->SetHelpContext(dwHelpContext); pcerrinfo->SetHelpFile(bstrHelpFile); pcerrinfo->SetSource(bstrSource); TRACE(_T("\tSource = %ws\n"), bstrSource); TRACE(_T("\tDescription = %s\n"), pszDescription); TRACE(_T("\tHelpContext = %lx\n"), dwHelpContext); TRACE(_T("\tHelpFile = %ws\n"), bstrHelpFile); // Set the ErrInfo object for the current thread IErrorInfo* perrinfo; if (SUCCEEDED(pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID*)&perrinfo))) { SetErrorInfo(0, perrinfo); perrinfo->Release(); } pcerrinfo->Release(); } TRACE(_T("DualHandleException returning HRESULT %lx\n"), hr); return hr; }
STDMETHODIMP COlePropertiesDialog::XOleUIObjInfo::GetObjectInfo( DWORD dwObject, DWORD* lpdwObjSize, LPTSTR* lplpszLabel, LPTSTR* lplpszType, LPTSTR* lplpszShortType, LPTSTR* lplpszLocation) { COleClientItem* pItem = (COleClientItem*)dwObject; ASSERT_VALID(pItem); BOOL bIsLink = (pItem->GetType() == OT_LINK); if (lpdwObjSize != NULL) { ASSERT(pItem->m_lpStorage != NULL); // try ILockBytes first, then IStorage STATSTG statStg; if ((pItem->m_lpLockBytes == NULL || pItem->m_lpLockBytes->Stat(&statStg, STATFLAG_NONAME) != S_OK) && pItem->m_lpStorage->Stat(&statStg, STATFLAG_NONAME) != S_OK) { *lpdwObjSize = 0xFFFFFFFF; } else { ASSERT(statStg.pwcsName == NULL); if (statStg.cbSize.HighPart > 0) *lpdwObjSize = 0xFFFFFFFE; else if (statStg.cbSize.LowPart == 0) *lpdwObjSize = 0xFFFFFFFF; else *lpdwObjSize = statStg.cbSize.LowPart; } } if (lplpszLabel != NULL) { TCHAR szFormatLink[128]; AfxLoadString(AFX_IDS_PASTELINKEDTYPE, szFormatLink, _countof(szFormatLink)); TCHAR szFormatObj[] = _T("%s"); LPTSTR lpszFormat = bIsLink ? szFormatLink : szFormatObj; CString strType; pItem->GetUserType(USERCLASSTYPE_FULL, strType); CString strResult; strResult.Format(lpszFormat, (LPCTSTR)strType); *lplpszLabel = AfxAllocTaskString(strResult); } if (lplpszType != NULL) { LPOLESTR lpOleStr; pItem->m_lpObject->GetUserType(USERCLASSTYPE_FULL, &lpOleStr); *lplpszType = TASKSTRINGOLE2T(lpOleStr); } if (lplpszShortType != NULL) { LPOLESTR lpOleStr; pItem->m_lpObject->GetUserType(USERCLASSTYPE_SHORT, &lpOleStr); *lplpszShortType = TASKSTRINGOLE2T(lpOleStr); } if (lplpszLocation != NULL) { if (bIsLink) { LPOLELINK lpOleLink = NULL; pItem->m_lpObject->QueryInterface(IID_IOleLink, (LPVOID*)&lpOleLink); ASSERT(lpOleLink != NULL); LPOLESTR lpOleStr; lpOleLink->GetSourceDisplayName(&lpOleStr); *lplpszLocation = TASKSTRINGOLE2T(lpOleStr); lpOleLink->Release(); } else { CDocument* pDoc = (CDocument*)pItem->GetDocument(); CString strLocation = pDoc->GetPathName(); if (strLocation.IsEmpty()) strLocation = pDoc->GetTitle(); *lplpszLocation = AfxAllocTaskString(strLocation); } } return S_OK; }
void CSimpleException::InitString() { m_bInitialized = TRUE; m_bLoaded = (AfxLoadString(m_nResourceID, m_szMessage, _countof(m_szMessage)) != 0); }
void CAboutDlg::OnDonate() { ::ShellExecute(NULL, _T("open"), AfxLoadString(IDS_DONATE_URL), NULL, NULL, SW_SHOWNORMAL); }
BOOL CBibedtApp::InitInstance() { // Standardinitialisierung // Wenn Sie diese Funktionen nicht nutzen und die Größe Ihrer fertigen // ausführbaren Datei reduzieren wollen, sollten Sie die nachfolgenden // spezifischen Initialisierungsroutinen, die Sie nicht benötigen, entfernen. InitCommonControls(); #ifdef _AFXDLL Enable3dControls(); // Diese Funktion bei Verwendung von MFC in gemeinsam genutzten DLLs aufrufen #else Enable3dControlsStatic(); // Diese Funktion bei statischen MFC-Anbindungen aufrufen #endif // Ändern des Registrierungsschlüssels, unter dem unsere Einstellungen gespeichert sind. SetRegistryKey(AfxLoadString(IDS_STRING_REGKEY)); LoadStdProfileSettings(); // Standard INI-Dateioptionen laden (einschließlich MRU) m_Language.LoadLanguages(); m_Options = new COptions(); m_Options->Load(); m_Coding = new CCodingTeX(); m_Coding->m_Enabled = m_Options->m_TranslateASCII; m_Coding->m_Filename = m_Options->m_EncodingTeX; m_Coding->m_Res = _T("TEX"); m_Coding->Load(); m_BibDef = new CBibDef(); CScintillaWnd::LoadScintillaDll(); m_pDocManager = new CDocManagerEx; // Dokumentvorlagen der Anwendung registrieren. Dokumentvorlagen // dienen als Verbindung zwischen Dokumenten, Rahmenfenstern und Ansichten. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CBibedtDoc), RUNTIME_CLASS(CMainFrame), // Haupt-SDI-Rahmenfenster RUNTIME_CLASS(CBibedtView)); AddDocTemplate(pDocTemplate); // Befehlszeile parsen, um zu prüfen auf Standard-Umgebungsbefehle DDE, Datei offen CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Verteilung der in der Befehlszeile angegebenen Befehle if (!ProcessShellCommand(cmdInfo)) return FALSE; // Register Bib Clipboard format m_BibClipbrdFormat = RegisterClipboardFormat(CF_BIB); // Register RTF Clipboard format m_RtfClipbrdFormat = RegisterClipboardFormat(CF_RTF); m_HtmlClipbrdFormat = RegisterClipboardFormat(CF_HTML); // Shell EnableShellOpen(); #ifndef _DEBUG RegisterShellFileTypes(TRUE); #endif m_pMainWnd->DragAcceptFiles(); // Das einzige Fenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden. m_pMainWnd->ShowWindow(m_Options->m_WindowPlacement.showCmd); m_pMainWnd->UpdateWindow(); if (m_Options->m_OpenLastFile && cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew && (UINT)m_pRecentFileList->GetSize() > 0) { // Open last file at start CString fn = m_pRecentFileList->m_arrNames[0]; CFileFind ff; if (ff.FindFile(fn)) { OnOpenRecentFile(ID_FILE_MRU_FILE1); } else { // Does not exist //m_pRecentFileList->Remove(0); } ff.Close(); } return TRUE; }