/////////////////////////////////////////////////////////////////////////////// // ein neues Objekt zum Baum hinzufügen bool CSpatialTreeNode::AddTile(CPgrTile *pTile, int nMaxDepth) { // If there are subnodes, then consider wether this object // will fit in them. if (nMaxDepth > 1 && m_nSubNodes > 0) { for (int i = 0; i < m_nSubNodes; ++i) { _ASSERTE(NULL != m_apsSubNode[i]); if (m_apsSubNode[i] -> CheckObjectContained(pTile)) return m_apsSubNode[i] -> AddTile(pTile, nMaxDepth - 1); } } else if (nMaxDepth > 1 && 0 == m_nSubNodes) { // Otherwise, consider creating four subnodes if could fit into // them, and adding to the appropriate subnode. double adfBoundsMinH1[SPATIALTREE_DIMENSION], adfBoundsMaxH1[SPATIALTREE_DIMENSION]; double adfBoundsMinH2[SPATIALTREE_DIMENSION], adfBoundsMaxH2[SPATIALTREE_DIMENSION]; double adfBoundsMin1[SPATIALTREE_DIMENSION], adfBoundsMax1[SPATIALTREE_DIMENSION]; double adfBoundsMin2[SPATIALTREE_DIMENSION], adfBoundsMax2[SPATIALTREE_DIMENSION]; double adfBoundsMin3[SPATIALTREE_DIMENSION], adfBoundsMax3[SPATIALTREE_DIMENSION]; double adfBoundsMin4[SPATIALTREE_DIMENSION], adfBoundsMax4[SPATIALTREE_DIMENSION]; SplitBounds(m_dBoundsMin, m_dBoundsMax, adfBoundsMinH1, adfBoundsMaxH1, adfBoundsMinH2, adfBoundsMaxH2); SplitBounds(adfBoundsMinH1, adfBoundsMaxH1, adfBoundsMin1, adfBoundsMax1, adfBoundsMin2, adfBoundsMax2); SplitBounds(adfBoundsMinH2, adfBoundsMaxH2, adfBoundsMin3, adfBoundsMax3, adfBoundsMin4, adfBoundsMax4); if (CheckObjectContained(pTile, adfBoundsMin1, adfBoundsMax1) || CheckObjectContained(pTile, adfBoundsMin2, adfBoundsMax2) || CheckObjectContained(pTile, adfBoundsMin3, adfBoundsMax3) || CheckObjectContained(pTile, adfBoundsMin4, adfBoundsMax4)) { m_nSubNodes = 4; ATLTRY(( m_apsSubNode[0] = new CSpatialTreeNode(adfBoundsMin1, adfBoundsMax1), m_apsSubNode[1] = new CSpatialTreeNode(adfBoundsMin2, adfBoundsMax2), m_apsSubNode[2] = new CSpatialTreeNode(adfBoundsMin3, adfBoundsMax3), m_apsSubNode[3] = new CSpatialTreeNode(adfBoundsMin4, adfBoundsMax4) )); // recurse back on this node now that it has subnodes return AddTile(pTile, nMaxDepth); } } // If none of that worked, just add it to this nodes list. ++m_nFeatureCount; CPgrTile * *pFeatureIds = SfRealloc(m_pFeatureIds, sizeof(CPgrTile *) * m_nFeatureCount); if (NULL != pFeatureIds) { m_pFeatureIds = pFeatureIds; ATLTRY(m_pFeatureIds[m_nFeatureCount - 1] = new CPgrTile(*pTile)); return true; } return false; }
/////////////////////////////////////////////////////////////////////////////// // Objektgeometrie besorgen bool CObjGeometrie::FInit (bool fStatisticsOnly) { // Statistik anfordern if (!DEX_GetObjStatistik (*this)) return false; if (fStatisticsOnly) return true; // Felder anfordern ATLTRY(pdblX = new double [lCnt]); ATLTRY(pdblY = new double [lCnt]); if (pdblX == NULL || pdblY == NULL) return false; if (iKCnt > 0) { if (iObjTyp == OGFlaeche) { ATLTRY(plCnt = new long [iKCnt]); if (plCnt == NULL) return false; } else if (iObjTyp == OGText) { ((TEXTGEOMETRIE &)*this).pText = new char [iKCnt+1]; if (((TEXTGEOMETRIE &)*this).pText == NULL) return false; } } // Geometrie holen iFlags |= OGConverted; if (!DEX_GetObjGeometrie (*this)) return false; // bei Linien/Flächen vergleichbare Position herstellen bool fResult = true; if (OGFlaeche == iObjTyp) { fResult = AdjustAreaGeometry(); fResult &= AdjustIslands(); // Inseln sortieren } else if (OGLinie == iObjTyp) fResult = AdjustLineGeometry(); // Hashwerte berechnen if (1.0 == m_dKoeff) { m_lXHash = HashKoords(&X(0), lCnt*sizeof(double)); m_lYHash = HashKoords(&Y(0), lCnt*sizeof(double)); } else { m_lXHash = HashKoordsTolerance(&X(0), lCnt, m_dKoeff); m_lYHash = HashKoordsTolerance(&Y(0), lCnt, m_dKoeff); } return fResult; }
void CComSafeArray::Create(VARTYPE vtSrc, DWORD dwDims, SAFEARRAYBOUND *rgsabound) { ATLASSERT(dwDims > 0); ATLASSERT(rgsabound != NULL); // Validate the VARTYPE for SafeArrayCreate call ATLASSERT( !(vtSrc & VT_ARRAY) ); ATLASSERT( !(vtSrc & VT_BYREF) ); ATLASSERT( !(vtSrc & VT_VECTOR) ); ATLASSERT(vtSrc != VT_EMPTY); ATLASSERT(vtSrc != VT_NULL); // Free up old safe array if necessary Clear(); ATLTRY( parray = ::SafeArrayCreate(vtSrc, dwDims, rgsabound) ); if (parray == NULL) { ATLTRACE2(atlTraceDBProvider, 0, "CComSafeArray::Create Error : OOM\n"); return; } vt = unsigned short (vtSrc | VT_ARRAY); m_dwDims = dwDims; m_dwElementSize = GetElemSize(); }
/************************************************************************** * IDataObject_Constructor */ HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl, IDataObject **dataObject) { CComObject<IDataObjectImpl> *theDataObject; CComPtr<IDataObject> result; HRESULT hResult; if (dataObject == NULL) return E_POINTER; *dataObject = NULL; ATLTRY (theDataObject = new CComObject<IDataObjectImpl>); if (theDataObject == NULL) return E_OUTOFMEMORY; hResult = theDataObject->QueryInterface (IID_IDataObject, (void **)&result); if (FAILED (hResult)) { delete theDataObject; return hResult; } hResult = theDataObject->Initialize (hwndOwner, pMyPidl, apidl, cidl); if (FAILED (hResult)) return hResult; *dataObject = result.Detach (); TRACE("(%p)->(apidl=%p cidl=%u)\n", *dataObject, apidl, cidl); return S_OK; }
HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator) { CComObject<IEnumFORMATETCImpl> *theEnumerator; CComPtr<IEnumFORMATETC> result; HRESULT hResult; if (enumerator == NULL) return E_POINTER; *enumerator = NULL; ATLTRY (theEnumerator = new CComObject<IEnumFORMATETCImpl>); if (theEnumerator == NULL) return E_OUTOFMEMORY; hResult = theEnumerator->QueryInterface (IID_IEnumFORMATETC, (void **)&result); if (FAILED (hResult)) { delete theEnumerator; return hResult; } hResult = theEnumerator->Initialize (cfmt, afmt); if (FAILED (hResult)) return hResult; *enumerator = result.Detach (); TRACE("(%p)->(%u,%p)\n", *enumerator, cfmt, afmt); return S_OK; }
STDMETHODIMP CTRiASHPDBEngine::EnumDataBaseTypes (IUnknown **ppIEnum) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) CHECKOUTPOINTER(ppIEnum); CComObject<CEnumString> *pIEnum = NULL; ATLTRY(pIEnum = new CComObject<CEnumString>()); if (NULL == pIEnum) return E_OUTOFMEMORY; // die Funktion Init des EnumTemplates erwartet die Adressen des ersten und // letzten+1 Elementes eines Vektors LPOLESTR *ppStringsStart = (LPOLESTR *)&s_poleTypesNormal[0]; LPOLESTR *ppStringsEnd = (LPOLESTR *)&s_poleTypesNormal[_countof(s_poleTypesNormal)]; HRESULT hr = pIEnum -> Init (ppStringsStart, ppStringsEnd, static_cast<ITRiASDBEngine *>(this), AtlFlagCopy); if (SUCCEEDED(hr)) hr = pIEnum -> QueryInterface(IID_IEnumString, (LPVOID *)ppIEnum); if (FAILED(hr)) // bei Fehler alles freigeben delete pIEnum; return hr; }
HRESULT CBlobService::MakeTextVertices (BYTE *pBlob, double_v &rX, double_v &rY, void *pData) { USES_CONVERSION; TEXTBLOBDATA *pTBD = (TEXTBLOBDATA *)pData; pBlob += sizeof(GUID); // GUID übergehen rX.push_back (((POINTBASE *)pBlob) -> X); // Koordinaten lesen rY.push_back (((POINTBASE *)pBlob) -> Y); pBlob += sizeof(POINTBASE); RetrieveAndAdvance(pTBD -> dRotation, pBlob); pBlob += sizeof(POINTBASE); // Normale übergehen RetrieveAndAdvance(pTBD -> lFlags, pBlob); // Text einlesen ULONG uiTextSize = 0; LPOLESTR pText = NULL; RetrieveAndAdvance(uiTextSize, pBlob); ATLTRY(pText = new OLECHAR[uiTextSize]); if (NULL == pText) return E_OUTOFMEMORY; RetrieveAndAdvance(pText, pBlob, uiTextSize); pTBD -> strText = OLE2A(pText); DELETE_OBJ(pText); return S_OK; }
/************************************************************************** * CFontsFolder::EnumObjects */ HRESULT WINAPI CFontsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) { CComObject<CDesktopFolderEnumZ> *theEnumerator; CComPtr<IEnumIDList> result; HRESULT hResult; TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner, dwFlags, ppEnumIDList); if (ppEnumIDList == NULL) return E_POINTER; *ppEnumIDList = NULL; ATLTRY (theEnumerator = new CComObject<CDesktopFolderEnumZ>); if (theEnumerator == NULL) return E_OUTOFMEMORY; hResult = theEnumerator->QueryInterface(IID_PPV_ARG(IEnumIDList, &result)); if (FAILED (hResult)) { delete theEnumerator; return hResult; } hResult = theEnumerator->Initialize (dwFlags); if (FAILED (hResult)) return hResult; *ppEnumIDList = result.Detach (); TRACE ("-- (%p)->(new ID List: %p)\n", this, *ppEnumIDList); return S_OK; }
/////////////////////////////////////////////////////////////////////////////// // Geometriebaum (Quadtree) BOOL CSpatialTree::Init (long lTileCnt, double *padfBoundsMin, double *padfBoundsMax, int nMaxDepth) { DELETE_OBJ(m_psRoot); _ASSERTE(NULL != padfBoundsMin && NULL != padfBoundsMax); // If no max depth was defined, try to select a reasonable one // that implies approximately 8 shapes per node. if (0 == nMaxDepth) { int nMaxNodeCount = 1; while (4 * nMaxNodeCount < lTileCnt) { ++nMaxDepth; nMaxNodeCount = 2 * nMaxNodeCount; } } m_nMaxDepth = nMaxDepth; // Allocate the root node. // Assign the bounds to the root node. If none are passed in, // use the bounds of the provided file otherwise the create // function will have already set the bounds. ATLTRY(m_psRoot = new CSpatialTreeNode(padfBoundsMin, padfBoundsMax)); return (NULL != m_psRoot) ? TRUE : FALSE; }
EShellTreeItem _InsertItem(IShellFolder* pFolder, LPCITEMIDLIST pidlPath, LPCITEMIDLIST pidlNode, DWORD dwAttribs, EShellTreeItem tiParent) { ATLASSERT(pFolder); ATLASSERT(pidlPath); // Create PARAM data PSHELLITEMINFO pItem; ATLTRY(pItem = new SHELLITEMINFO); ATLASSERT(pItem); pItem->pidlFull.Copy( pidlPath ); pItem->pidlFull.Concatenate( pidlNode ); pItem->pidlNode.Copy( pidlNode ); pItem->spFolder = pFolder; pItem->dwAttribs = dwAttribs; SHFILEINFO sfi; if( ::SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)pItem->pidlFull, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY) ) { return AppendItem(tiParent, sfi.szDisplayName, sfi.iIcon, pItem); } return NULL; }
CKeyClass::CKeyClass( CHKey& hk) : m_ptszClass(NULL), m_lErr(ERROR_SUCCESS) { DWORD ctc = 0; if (! hk.QueryInfoKey(NULL, &ctc, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) { m_lErr = hk.Error(); } else { ATLTRY(m_ptszClass = new TCHAR [++ctc]); if (m_ptszClass == NULL) { m_lErr = ERROR_OUTOFMEMORY; return; } *m_ptszClass = _T('\0'); if (! hk.QueryInfoKey(m_ptszClass, &ctc, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) { delete [] m_ptszClass; m_ptszClass= NULL; m_lErr = hk.Error(); } } }
bool CPEDebug::Initialize() { if (m_fIsInitialized) return true; // nur einmal initialisieren else if (m_fTriedToInitialize) return false; // schon mal versucht, jedoch fehlgeschlagen m_fTriedToInitialize = true; // Since the largest symbol that the MS code generators can handle // is 256 that is all that is needed. ATLTRY(m_pSymbol = (IMAGEHLP_SYMBOL *)new BYTE [sizeof(IMAGEHLP_SYMBOL) + 256]); if (NULL == m_pSymbol) return false; // SymbolEngine initialisieren if (m_SymEngine.SymInitialize (GetCurrentProcess(), NULL, TRUE)) { // Set the symbol engine to load line information. This must be // because the symbol engine does not load source-lines by default. // I also turn on the OMAP lookups so that the super-special OMAP // moved blocks will get looked at as well. Trust me, don't ask. SymSetOptions (SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_OMAP_FIND_NEAREST); m_fIsInitialized = true; return true; } return false; }
COledbDatabase::COledbDatabase() : m_pSystem(NULL) { ATLTRY(m_pErrors = new COledbErrors); #ifdef _DEBUG m_nRecordsets = 0; #endif }
bool CIdentsDBExtension::ExportDataSourceAsXml (LPUNKNOWN pIUnk, HPROJECT hPr, LPCSTR pFName, ULONG &rulCnt) { if (pIUnk) LPPROGRESSINDICATOR(pIUnk) -> ChangeText (PIFLAG_FILENAME, pFName); // Datei bilden, wenn diese noch nicht existiert int fh = _lcreat (pFName, 0); if (fh < 0) return false; bool fRet = false; { // hier geht's los CXMLDocument Doc (fh); // <?xml ...?> char cbBuffer[80]; // TRiAS Version, aktuelle Zeit os_time_and_date now; string resVersion (g_cbTRiAS); ResString resTempl (IDS_SIGNONVERSION_MODAL, _MAX_PATH); resVersion += ": "; resVersion += resTempl; ATLTRY(now = os_time_and_date::now()); strcpy (cbBuffer, resVersion.c_str()); strcat (cbBuffer, now.to_string(" %e. %B %Y, %T").c_str()); CXMLComment (fh, cbBuffer); CXMLComment (fh, ResString (IDS_COPYRIGHT, 100)); // allgemeines Copyright // DTD einfügen CXMLRawData (fh, s_cbDTD); // die eigentlichen Infos ausgeben CXMLAttribute Attr ("Version", "1.0"); CXMLNode MainNode (fh, g_cbTRiASMetadata, Attr); ENUMLONGKEY ELK; EXPORTDATA ED; ED.fh = fh; ED.pIUnk = pIUnk; ED.ulCnt = rulCnt; ELK.eKey = 'i'; ELK.eFcn = (ENUMLONGKEYPROC)ExportIdentEntryAsXml; ELK.ePtr = &ED; fRet = DEX_EnumPBDDataEx (hPr, ELK); rulCnt = ED.ulCnt; } // Datei wieder schließen _lclose (fh); // Datei schließen return fRet; }
CFindReplaceDlg *CFindReplaceDlg :: CreateInstance () { CFindReplaceDlg *pCFindReplaceDlg = NULL; ATLTRY(pCFindReplaceDlg = new CFindReplaceDlg()); if(pCFindReplaceDlg == NULL || !pCFindReplaceDlg -> FInit () ) { if (pCFindReplaceDlg) delete pCFindReplaceDlg; return NULL; } return pCFindReplaceDlg; }
CTRiASDocTemplate::CTRiASDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass) : CSingleDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) { // Zeichenketten korrigieren if (m_strDocStrings.IsEmpty()) m_strDocStrings.LoadString(nIDResource); ATLTRY(m_strDocStrings = FakeTRiASName ( m_strDocStrings, g_cbTRiAS, g_cbTRiAS, g_cbTRiAS, g_cbRiw, g_cbRiw, g_cbTRiAS).c_str()); }
void CSketcherDoc::SetSearchContent(const CString& value) { if (value.IsEmpty()) { RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); } else { CMFCFilterChunkValueImpl *pChunk = NULL; ATLTRY(pChunk = new CMFCFilterChunkValueImpl); if (pChunk != NULL) { pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); SetChunkValue(pChunk); } } }
STDMETHODIMP CToolBarButton::GetImage (long *phBitmap, int *piCnt, int *piOffset) { if (NULL == phBitmap) return E_POINTER; if (BUTTONSTYLE_SEPARATOR == m_tb.fsStyle) return E_FAIL; // Separatoren haben keine Bitmap CPicture Pict (m_PictDisp, false); ATLTRY(*phBitmap = Pict.GetHandle()); if (NULL != piCnt) *piCnt = m_iCnt; if (NULL != piOffset) *piOffset = m_iOffset; return (NULL != *phBitmap) ? NOERROR : E_FAIL; }
inline HRESULT _PROPERTYSUPPORT_ENTRY::AddDefaultEntry (LPCOLESTR pcName, IUnknown *pIUnk) { _ASSERTE(dwFlags & PROPERTYSUPPORT_DEFAULT); // in unserer Liste eintragen if (NULL == pobjs) { ATLTRY(pobjs = new CDefEntries); if (NULL == pobjs) { ReleaseSupportObjects(); return E_OUTOFMEMORY; } } pobjs -> push_back (CDefEntry(CComBSTR(pcName), pIUnk)); return S_OK; }
HRESULT CTRiASConnections::FinalConstruct (void) { CTRiASConnection::ResetAskMode(); // init base instance data HRESULT hr = IPersistStorageOMImpl<CTRiASConnections>::FinalConstruct(); if (FAILED(hr)) return hr; // instance data ATLTRY(m_Enum = new NEnumWTRiASConnection()); if (!m_Enum) return E_OUTOFMEMORY; m_Enum -> Release(); // Konstruktor hinterläßt RefCnt==1 return S_OK; }
STDMETHODIMP CreateDelegator (IUnknown* pUnkOuter, IUnknown* pUnkInner, REFIID iid, void** ppv) { // must pass both an outer and inner if (!pUnkOuter || !pUnkInner) return E_UNEXPECTED; CoDelegator *p = NULL; ATLTRY(p = new CoDelegator (pUnkOuter, pUnkInner)); if (!p) return E_OUTOFMEMORY; p->AddRef(); HRESULT hr = p->QueryInterface (iid, ppv); p->Release(); return hr; }
HRESULT CreateAddressBand(REFIID riid, void **ppv) { CComObject<CAddressBand> *theMenuBar; HRESULT hResult; if (ppv == NULL) return E_POINTER; *ppv = NULL; ATLTRY (theMenuBar = new CComObject<CAddressBand>); if (theMenuBar == NULL) return E_OUTOFMEMORY; hResult = theMenuBar->QueryInterface (riid, (void **)ppv); if (FAILED (hResult)) { delete theMenuBar; return hResult; } return S_OK; }
//Add a page to the array (if it's not already present) and //increase its hitcount by ExtraHits. UINT CPageArray::AddPage(const BSTR bstrURL, UINT ExtraHits) { int i = FindURL(bstrURL); if (i >= 0) { // There are no duplicate URLs in this array; just adjust m_Hits ASSERT(i < m_iMax); m_aPages[i].m_Hits += ExtraHits; } else { // Not present, so append it ASSERT(0 <= m_iMax && m_iMax <= m_cAlloc); if (m_iMax == m_cAlloc) { // grow the array because it's full CPage* pOldPages = m_aPages; m_cAlloc += CHUNK_SIZE; m_aPages = NULL; ATLTRY(m_aPages = new CPage[m_cAlloc]); if (m_aPages == NULL) { m_aPages = pOldPages; return BAD_HITS; } for (i = 0; i < m_iMax; i++) m_aPages[i] = pOldPages[i]; delete [] pOldPages; } i = m_iMax++; m_aPages[i].m_URL = bstrURL; m_aPages[i].m_Hits = ExtraHits; } return m_aPages[i].GetHits(); }
/************************************************************************** * IEnumIDList_Folder_Constructor * */ HRESULT IEnumIDList_Constructor(IEnumIDList **enumerator) { CComObject<IEnumIDListImpl> *theEnumerator; CComPtr<IEnumIDList> result; HRESULT hResult; if (enumerator == NULL) return E_POINTER; *enumerator = NULL; ATLTRY (theEnumerator = new CComObject<IEnumIDListImpl>); if (theEnumerator == NULL) return E_OUTOFMEMORY; hResult = theEnumerator->QueryInterface(IID_PPV_ARG(IEnumIDList, &result)); if (FAILED (hResult)) { delete theEnumerator; return hResult; } *enumerator = result.Detach (); return S_OK; }
///////////////////////////////////////////////////////////////////////////// // Helper for iter to CComSafeArray void _MtlCreateOneDimArray(VARIANT &varSrc, DWORD dwSize) { UINT nDim; // Clear VARIANT and re-create SafeArray if necessary if (varSrc.vt != (VT_UI1 | VT_ARRAY) || ( nDim = ::SafeArrayGetDim(varSrc.parray) ) != 1) { MTLVERIFY(::VariantClear(&varSrc) == NOERROR); varSrc.vt = VT_UI1 | VT_ARRAY; SAFEARRAYBOUND bound; bound.cElements = dwSize; bound.lLbound = 0; ATLTRY( varSrc.parray = ::SafeArrayCreate(VT_UI1, 1, &bound) ); if (varSrc.parray == NULL) ATLTRACE2(atlTraceDBProvider, 0, "MtlCheckError Error : OOM\n"); } else { // Must redimension array if necessary long lLower, lUpper; MtlCheckError( ::SafeArrayGetLBound(varSrc.parray, 1, &lLower) ); MtlCheckError( ::SafeArrayGetUBound(varSrc.parray, 1, &lUpper) ); // Upper bound should always be greater than lower bound long lSize = lUpper - lLower; if (lSize < 0) { ATLASSERT(FALSE); lSize = 0; } if ( (DWORD) lSize != dwSize ) { SAFEARRAYBOUND bound; bound.cElements = dwSize; bound.lLbound = lLower; MtlCheckError( ::SafeArrayRedim(varSrc.parray, &bound) ); } } }
HRESULT CTRiASOptionDlg::FinalConstruct() { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // Caption initialisieren CComBSTR bstrCaption; VERIFY(bstrCaption.LoadString (_Module.GetResourceInstance(), IDS_STDDIALOGCAPTION)); // Dialog anlegen, initialisieren und anzeigen CStdCtrlDlg *pDlg = NULL; ATLTRY(pDlg = new CStdCtrlDlg); if (NULL == pDlg) return E_OUTOFMEMORY; pDlg -> SetCallback (this); pDlg->EnableAutomation(); pDlg->EnableAggregation(); pDlg->m_pOuterUnknown = static_cast<LPUNKNOWN>(GetControllingUnknown()); //LPDISPATCH _pDispatch = pDlg->GetIDispatch(FALSE); m_pUnkPpg = reinterpret_cast<LPUNKNOWN>(&(pDlg->m_xInnerUnknown)); if (NULL == m_pUnkPpg) { delete pDlg; return E_UNEXPECTED; } // Fenster erzeugen (ist !Visible) // if (!pDlg -> Create()) { // delete pDlg; // return E_UNEXPECTED; // } m_pDlg = pDlg; return S_OK; }
int __cdecl VMessageBox (LPCSTR pcCaption, UINT uiType, UINT uiText, ...) { CString strText; VERIFY(strText.LoadString (uiText)); CWnd Wnd; CString strOut; LPTSTR pcOut = NULL; ATLTRY(pcOut = strOut.GetBufferSetLength(_MAX_PATH*4)); if (NULL != pcOut) { va_list params; va_start (params, uiText); //lint --e(534) wvsprintf (pcOut, strText, params); va_end (params); return Wnd.MessageBox (pcOut, pcCaption, uiType); } return Wnd.MessageBox (strText, pcCaption, uiType); }
HRESULT IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, const IID *riidInst, IClassFactory **theFactory) { CComObject<IDefClFImpl> *theClassObject; CComPtr<IClassFactory> result; HRESULT hResult; if (theFactory == NULL) return E_POINTER; *theFactory = NULL; ATLTRY (theClassObject = new CComObject<IDefClFImpl>); if (theClassObject == NULL) return E_OUTOFMEMORY; hResult = theClassObject->QueryInterface (IID_IClassFactory, (void **)&result); if (FAILED (hResult)) { delete theClassObject; return hResult; } hResult = theClassObject->Initialize (lpfnCI, pcRefDll, riidInst); if (FAILED (hResult)) return hResult; *theFactory = result.Detach (); return S_OK; }
/************************************************************************** * IExtractIcon_Constructor */ static HRESULT WINAPI IEI_Printers_Constructor(LPCITEMIDLIST pidl, REFIID riid, IUnknown **ppv) { CComObject<CPrintersExtractIconW> *theExtractor; CComPtr<IUnknown> result; HRESULT hResult; if (ppv == NULL) return E_POINTER; *ppv = NULL; ATLTRY (theExtractor = new CComObject<CPrintersExtractIconW>); if (theExtractor == NULL) return E_OUTOFMEMORY; hResult = theExtractor->QueryInterface(riid, (void **)&result); if (FAILED (hResult)) { delete theExtractor; return hResult; } hResult = theExtractor->Initialize(pidl); if (FAILED (hResult)) return hResult; *ppv = result.Detach(); return S_OK; }
/////////////////////////////////////////////////////////////////////////////// // Hinzufügen eines Eintrages HRESULT TxAddMapEntry ( _PROPERTYSUPPORT_ENTRY* pEntry, LPCOLESTR pcKey, INT_PTR NewData, DWORD NewFlags, VARIANT vInitData, GETDEFAULTVALUEPROC pFcn) { while (NULL != pEntry->dw) { if (pEntry -> dwFlags & PROPERTYSUPPORT_DYNAMICSTRING && NULL == pEntry -> szKey) { ATLTRY(pEntry -> szKey = new wchar_t[wcslen(pcKey)+1]); if (NULL == pEntry -> szKey) return E_OUTOFMEMORY; wcscpy (const_cast<unsigned short *>(pEntry -> szKey), pcKey); pEntry -> dw = NewData; pEntry -> dwFlags |= NewFlags; if (VT_ERROR != V_VT(&vInitData)) { RETURN_FAILED_HRESULT(VariantCopy (&pEntry -> vInitData, &vInitData)); } if (NULL != pFcn) pEntry -> pDefValProc = pFcn; return S_OK; } pEntry++; } return E_UNEXPECTED; }