HRESULT CTypeInfoBrowse::CrackExtendProperty(ICxEnumExtendProperty* pEnum, CPropInfoArray& arrProp)
{
	LONG nIndex;
	HRESULT hr;
	CPropInfo prop;

	pEnum->Reset();
	while (S_FALSE != pEnum->Next(&nIndex))
	{
		hr = pEnum->GetType((LONG *)&prop.m_proptype);
		if (FAILED(hr))
			return hr;
			
		CComBSTR bstr;
		hr = pEnum->GetName(&bstr);
		if (FAILED(hr))
			return hr;
		prop.m_bstrName = bstr;

		bstr.Empty();
		hr = pEnum->GetDescription(&bstr);
		if (FAILED(hr))
			return hr;
		prop.m_bstrDesc = bstr;
	
		hr = pEnum->GetDispid(&prop.m_dispid);
		if (FAILED(hr))
			return hr;
			
		arrProp.Add(prop);
	}
	
	return S_OK;
}
BOOL vmsMetalinkFile::ReadHashNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Hash *hash)
{
	USES_CONVERSION;

	IXMLDOMNamedNodeMapPtr spAttrs;
	pNode->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;

	IXMLDOMNodePtr spType;
	spAttrs->getNamedItem (L"type", &spType);
	if (spType == NULL)
		return FALSE;

	COleVariant vt;
	spType->get_nodeValue (&vt);
	ASSERT (vt.vt == VT_BSTR);
	if (vt.vt == VT_BSTR)
		hash->strAlgorithm = W2A (vt.bstrVal);
	
	CComBSTR bstrText;
	pNode->get_text (&bstrText);
	if (bstrText.Length () == 0)
		return FALSE;

	hash->strChecksum = W2A (bstrText);

	return TRUE;
}
void CStrokeRecognition::EncodeStrokeToXML(std::vector<BasicStroke> &rgStrokes, BSTR* StrokeResult)
{
	CComBSTR	strokeXML;
	char		szTmp[1024];

	strokeXML = "<?xml version=\"1.0\"?><output><strokes candidatenum=\"1\">";
	sprintf(szTmp, "<candidate similarity=\"1\" strokenum=\"%d\">", rgStrokes.size());
	strokeXML += szTmp;

	for (unsigned int i = 0; i < rgStrokes.size(); i++)
	{
		switch (rgStrokes[i].iStrokeType)
		{
		case PRIMITIVE_SEGMENT:
			{
				sprintf(szTmp, "<line><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/></line>", 
						rgStrokes[i].segment.startPoint.x, rgStrokes[i].segment.startPoint.y, 
						rgStrokes[i].segment.endPoint.x, rgStrokes[i].segment.endPoint.y);
				strokeXML += szTmp;
			}
			break;
		case PRIMITIVE_ARC:
			{
				double	x1, y1, x2, y2;
				double	cx, cy, a, b;

				cx	= (rgStrokes[i].arc.rcBounding.left + rgStrokes[i].arc.rcBounding.right) / 2;
				cy	= (rgStrokes[i].arc.rcBounding.top + rgStrokes[i].arc.rcBounding.bottom) / 2;
				a	= (rgStrokes[i].arc.rcBounding.right - rgStrokes[i].arc.rcBounding.left) / 2;
				b	= (rgStrokes[i].arc.rcBounding.bottom - rgStrokes[i].arc.rcBounding.top) / 2;

				CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.startAngle, a, b), x1, y1);
				CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.endAngle, a, b), x2, y2);

				if (rgStrokes[i].arc.endAngle - rgStrokes[i].arc.startAngle >= 1.9 * PI)
				{
					sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>", 
						(float)(rgStrokes[i].arc.rotateAngle), 
						(int)x1, (int)y1, (int)x1, (int)y1,
						rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top, 
						rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
				}
				else
				{
					sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>", 
						(float)(rgStrokes[i].arc.rotateAngle), 
						(int)x1, (int)y1, (int)x2, (int)y2,
						rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top, 
						rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
				}
				strokeXML += szTmp;
			}
			break;
		}
	}

	strokeXML += "</candidate></strokes></output>";

	strokeXML.CopyTo(StrokeResult);
}
Example #4
0
//extern "C" {
HRESULT WINAPI DateTime_Evaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved )
{
	DATE Time;
	DWORDLONG address = GetAddress( pHelper, dwAddress);

	if( !ReadMem( pHelper, address, &Time) )
		return E_FAIL;

	if(Time == 0.)
	{
		strcpy(pResult, "zero");
		return S_OK;
	}
	if(Time == ( 65535. * 2147483647. ) || Time == (2147483647.))
	{
		strcpy(pResult, "invalid");
		return S_OK;
	}
	if(Time == ( 65535. * 2147483648. ) || Time == (2147483648.))
	{
		strcpy(pResult, "null");
		return S_OK;
	}

	CComBSTR strDate ;
	HRESULT hr = VarBstrFromDate(Time, LOCALE_USER_DEFAULT, 0, &strDate);
	if (FAILED(hr)) return hr;
	
	if(strDate != 0)
		WideCharToMultiByte(CP_ACP, 0, strDate, strDate.Length(), pResult, maxlen , NULL, NULL);

	return S_OK;
	
}
LRESULT CShellViewImpl::OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
WORD wMenuID = LOWORD(wParam);
WORD wFlags = HIWORD(wParam);

    // If the selected menu item is one of ours, show a flyby help string
    // in the Explorer status bar.

    if ( !(wFlags & MF_POPUP) )
        {
        switch ( wMenuID )
            {
            case IDC_EXPLORE_DRIVE:
            case IDC_SYS_PROPERTIES:
            case IDC_ABOUT_SIMPLENS:
                {
                CComBSTR bsHelpText;

                if ( bsHelpText.LoadString ( wMenuID ))
                    {
                    m_spShellBrowser->SetStatusTextSB ( bsHelpText.m_str );
                    }

                return 0;
                }
            break;
            }
        }

    // Otherwise, pass the message to the default handler.
    return DefWindowProc();
}
Example #6
0
/****************************************
** Author:      Joe Li
** Purpose:     Save whiteboard settings data
** Comments:  
****************************************/ 
bool DOSaveAppData::SaveWhiteboardSettingsData(const CComBSTR& sourcePath, const CComBSTR& targetPath)
{
    if (sourcePath.Length() != 0 && targetPath.Length() != 0)
    {
        const unsigned long bufferSize = 256;
        TCHAR buffer[bufferSize];

        DOPersistentFile sourceFile;

        // Search for first source file
        if (sourceFile.FindFirstFile(sourcePath, WHITEBOARD_SETTINGS_WILDCARD_SEARCH, buffer, bufferSize) == true)
        {
            CComBSTR sourceFileName = buffer;
            bool allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath);

            // Search of remaining source file(s)
            while (sourceFile.FindNextFile(buffer, bufferSize) == true)
            {
                sourceFileName = buffer;
                allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath) && allWhiteboardSettingsSaved;
            }

            return allWhiteboardSettingsSaved;
        }
    }

    return false;
}
Example #7
0
    HRESULT Property::SetValueAsString( 
        LPCOLESTR pszValue,
        DWORD dwRadix,
        DWORD dwTimeout )
    {
        // even though it could be read only, let's parse and eval, so we get good errors

        HRESULT         hr = S_OK;
        CComBSTR        assignExprText = mFullExprText;
        CComBSTR        errStr;
        UINT            errPos;
        CComPtr<IDebugExpression2>  expr;
        CComPtr<IDebugProperty2>    prop;

        if ( assignExprText == NULL )
            return E_OUTOFMEMORY;

        hr = assignExprText.Append( L" = " );
        if ( FAILED( hr ) )
            return hr;

        hr = assignExprText.Append( pszValue );
        if ( FAILED( hr ) )
            return hr;

        hr = mExprContext->ParseText( assignExprText, 0, dwRadix, &expr, &errStr, &errPos );
        if ( FAILED( hr ) )
            return hr;

        hr = expr->EvaluateSync( 0, dwTimeout, NULL, &prop );
        if ( FAILED( hr ) )
            return hr;

        return S_OK;
    }
Example #8
0
bool Skein::BoolFromXML(IXMLDOMNode* node, LPWSTR query, bool ifNon)
{
  CComBSTR text = StringFromXML(node,query);
  if (text.Length() > 0)
    return wcscmp(text.m_str,L"YES") == 0;
  return ifNon;
}
Example #9
0
int Skein::IntFromXML(IXMLDOMNode* node, LPWSTR query)
{
  CComBSTR text = StringFromXML(node,query);
  if (text.Length() > 0)
    return _wtoi(text.m_str);
  return 0;
}
Example #10
0
char * CCoordTransService::CoordTransToStringEx (
	double dX, double dY, bool isX, char *pBuffer, int iLen)
{
	if (m_fIsInitialized) {
		try {
		CComBSTR bstr;
		CCSPoint pt (dX, dY);

			if (isX) {
				THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, &bstr, NULL, NULL));
			} else {
				THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, NULL, &bstr, NULL));
			}

			USES_CONVERSION;
			iLen = min(bstr.Length(), iLen-1);
			strncpy (pBuffer, OLE2A(bstr), iLen);
			pBuffer[iLen] = '\0';
			return pBuffer;

		} catch (_com_error &e) {
			ShowError (_COM_ERROR(e), IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
			return NULL;
		}
	
	} 
	ShowError (TRIAS02_E_CSSNOTINITIALIZED, IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
	return NULL;
}
BOOL NodeExistsInParent(CComPtr<ItcProjectNode> owner_node, CComBSTR name) {
	_ASSERT( owner_node != NULL );

	if ((name.Length() > 0) && FAILED(name.ToLower()))
		return FALSE;
  
	CComPtr<ItcProjectNodeIterator> iterator;
    if (FAILED( owner_node->CreateChildIterator(&iterator) )) {
        return FALSE;
    }
	
    while (iterator->HasNext() == VARIANT_TRUE)  {
		CComPtr <ItcProjectNode> node;
		
        if (FAILED( iterator->Next(&node) )) {
            return FALSE;
        }
		
        CComBSTR caption;
		
        if (SUCCEEDED( node->get_Caption(&caption) )) {
            if ((caption.Length() == 0) || SUCCEEDED(caption.ToLower())) {
                if (caption == name) {
					return TRUE;
                }
            }
        }
	}

	return FALSE;
}
Example #12
0
STDMETHODIMP CJoystickCtl::getProductName(BSTR *pName) {
	USES_CONVERSION;
	char* name = stick.getProductName();
	CComBSTR wName = A2W(name);
	*pName = wName.Detach();
	return S_OK;
}
/////////////////////////////////////////////////////////////////////
// OPCBrowser::Item method
// Item index is 1-based for VB
STDMETHODIMP COPCBrowserImpl::Item( VARIANT ItemSpecifier, BSTR *pItem)
{
   if( ItemSpecifier.vt != VT_I4 && ItemSpecifier.vt != VT_I2 )
      return E_INVALIDARG;
   if( ItemSpecifier.vt == VT_I2 )
      ItemSpecifier.lVal = ItemSpecifier.iVal;
   if( ItemSpecifier.lVal < 1 || ItemSpecifier.lVal > m_names.size() )
      return E_INVALIDARG;
   if( pItem == NULL )
      return E_INVALIDARG;

   LONG index=1;
   m_listPosition = m_names.begin();
   while( m_listPosition!=m_names.end() && index < ItemSpecifier.lVal )
   {
      m_listPosition++;
      index++;
   }
   if( index == ItemSpecifier.lVal )
   {
      CComBSTR* pName = *m_listPosition;
      *pItem = pName->Copy();
      return S_OK;
   }

   return E_FAIL;
}
HRESULT GetFilter_new(dimension_t dimension, short index, BSTR* filter)
{
    std::string szFG;
    std::string szFV;
    int  newIndex  = offset_to_new_index_(atFilter,dimension, index);

    XXGetFilterEx_(dimension, newIndex, &szFG, &szFV);

    CComBSTR bFilter;

//  ff::ignore_missing_arguments_scope  scoper;
//  fastformat::fmt(bFilter, "{0}{1}{2}{3}", szFG, winstl::w2m(strFilterSeparator), szFV);

#if 0
    fastformat::write(bFilter, szFG, winstl::w2m(strFilterSeparator), szFV); // +1

    *filter = bFilter.Detach();
#else /* ? 0 */

# if 1

    *filter = fastformat::write(bFilter, szFG, winstl::w2m(strFilterSeparator), szFV).Detach(); // +1

# else /* ? 0 */

    // This should not work, but does with some compilers ...

    *filter = fastformat::write(CComBSTR(), szFG, winstl::w2m(strFilterSeparator), szFV).Detach(); // +1

# endif /* 0 */

#endif /* 0 */

    return S_OK;
}
Example #15
0
extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume)
{
	CComPtr<ITrueCryptMainCom> tc;
	int r;

	CoInitialize (NULL);

	if (ComGetInstance (hwndDlg, &tc))
	{
		CComBSTR volumeBstr;
		BSTR bstr = W2BSTR(lpszVolume);
		if (bstr)
		{
			volumeBstr.Attach (bstr);
			r = tc->RestoreVolumeHeader ((LONG_PTR) hwndDlg, volumeBstr);
		}
		else
			r = ERR_OUTOFMEMORY;
	}
	else
		r = -1;

	CoUninitialize ();

	return r;
}
STDMETHODIMP CSimplePointDatasetHelper::FetchAll(long ClassIndex, BSTR WhereClause, VARIANT FieldMap, IPlugInCursorHelper **cursorHelper)
{
	HRESULT hr;
	if (! cursorHelper) return E_POINTER;

	// Some parameters can be ignored since,
  //   ClassIndex is only relevant to feature datasets
  //   WhereClause is not appropriate since we are not supporting SQL
  ISimplePointCursorHelperPtr ipSimplePointCursorHelper;
  hr = ipSimplePointCursorHelper.CreateInstance(CLSID_SimplePointCursorHelper);
  if (FAILED(hr)) return hr;

	hr = ipSimplePointCursorHelper->put_FieldMap(FieldMap);
	if (FAILED(hr)) return hr;

  IFieldsPtr ipFields;
	hr = get_Fields(0, &ipFields);
	if (FAILED(hr)) return hr;

	hr = ipSimplePointCursorHelper->putref_Fields(ipFields);
	if (FAILED(hr)) return hr;

	CComBSTR sFilePath;
	sFilePath = m_sWorkspacePath;
	sFilePath.Append(m_sDatasetName);
  hr = ipSimplePointCursorHelper->put_FilePath(sFilePath);
	if (FAILED(hr)) return hr;

  IPlugInCursorHelperPtr ipPlugInCursorHelper;
	ipPlugInCursorHelper = ipSimplePointCursorHelper;
	if (ipPlugInCursorHelper == NULL) return E_FAIL;

  *cursorHelper = ipPlugInCursorHelper.Detach(); // Pass ownership of object back to client
	return S_OK;
}
Example #17
0
/****************************************
** Author:      Joe Li
** Purpose:     Save whiteboard settings data
** Comments:  
****************************************/ 
bool DOSaveAppData::SaveWhiteboardSettings(const CComBSTR& sourcePath, const CComBSTR& sourceFileName, const CComBSTR& targetPath)
{
    DOPersistentFile sourceFile;

    // Open source file for reading
    if (sourceFile.OpenFile(sourcePath, sourceFileName, DOFile::DO_FILE_OPEN_EXISTING, DOFile::DO_FILE_READ) == true)
    {
        SetDateTime();

        CComBSTR targetFileName = m_dateTime;
        targetFileName.Append(sourceFileName);

        DORemovableStorageFile targetFile;
        bool targetFileOpen = true;

        // Open existing target file
        if (targetFile.OpenFile(targetPath, targetFileName, DOFile::DO_FILE_TRUNCATE_EXISTING) == false)
            // Create target file if open existing file failed
            if (targetFile.OpenFile(targetPath, targetFileName) == false)
                targetFileOpen = false;

        if (targetFileOpen == true)
        {
            DOFileUtility fileUtility;
            return fileUtility.CopyFileContents(&sourceFile, &targetFile);
        }
    }

    return false;
}
Example #18
0
BOOL UIIMEdit::GetPicPosAndPathbyOrder(IN UInt32 nOrder, OUT UInt32& nPos, OUT CString& path)
{
	IRichEditOle* pRichEditOle = m_pRichEditOle;
	PTR_FALSE(pRichEditOle);

	REOBJECT reobj = { 0 };
	reobj.cbStruct = sizeof(REOBJECT);
	HRESULT hr = pRichEditOle->GetObject(nOrder, &reobj, REO_GETOBJ_POLEOBJ);
	if (SUCCEEDED(hr) && reobj.poleobj)
	{
		GifSmiley::IGifSmileyCtrl* lpAnimator = 0;
		hr = reobj.poleobj->QueryInterface(GifSmiley::IID_IGifSmileyCtrl, (void**)&lpAnimator);
		if (SUCCEEDED(hr) && lpAnimator)
		{
			CComBSTR  fileName;
			hr = lpAnimator->FileName(&fileName);
			if (SUCCEEDED(hr) && 0 != fileName.Length())
			{
				nPos = reobj.cp;
				path = CString(fileName.m_str);
			}
			lpAnimator->FreeImage();
			lpAnimator->Release();
		}
		reobj.poleobj->Release();
		return TRUE;
	}
	return FALSE;
}
std::string stringifyVarDesc(VARDESC* varDesc, ITypeInfo* pti) 
{
	CComPtr<ITypeInfo> pTypeInfo(pti);
	std::ostringstream oss;
	if(varDesc->varkind == VAR_CONST) 
		oss<< "const ";

	oss<< stringifyTypeDesc(&varDesc->elemdescVar.tdesc, pTypeInfo);
	CComBSTR bstrName;
	HRESULT hr(pTypeInfo->GetDocumentation(varDesc->memid, &bstrName, 0, 0, 0));
	if(hr) 
		return "UnknownName";

	char ansiName[MAX_PATH];
	WideCharToMultiByte(CP_ACP, 0, bstrName, bstrName.Length() + 1, ansiName, MAX_PATH, 0, 0);

	oss<< ' '<< ansiName;
	if(varDesc->varkind != VAR_CONST) 
		return oss.str();

	oss<< " = ";
	CComVariant variant;
	hr = VariantChangeType(&variant, varDesc->lpvarValue, 0, VT_BSTR);
	if(hr) 
		oss<< "???";
	else 
	{
		WideCharToMultiByte(CP_ACP, 0, variant.bstrVal, SysStringLen(variant.bstrVal) + 1, ansiName, MAX_PATH, 0, 0);
		oss<< ansiName;
	}

	return oss.str();
}
Example #20
0
STDMETHODIMP CTRiASOGCDBEngine::get_Description (BSTR * pVal)
{
#if defined(_MFC_VER)
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif // defined(_MFC_VER)

	CHECKOUTPOINTER(pVal);	

// Wert aus der Registry lesen
CRegKey regKey;
char cbBuffer[_MAX_PATH];
DWORD dwLen = sizeof(cbBuffer);

	if (ERROR_SUCCESS != regKey.Open(HKEY_CLASSES_ROOT, "TRiASDB.TRiASOGC.DBEngine.1", KEY_READ) || 
		ERROR_SUCCESS != regKey.QueryValue(cbBuffer, NULL, &dwLen))
	{
		return E_UNEXPECTED;
	}

CComBSTR bstr (cbBuffer);

	if (!bstr)
		return E_OUTOFMEMORY;

	*pVal = bstr.Detach();
	return S_OK;
}
Example #21
0
HRESULT GetPathNodeValue(ILDOMElement* element, BSTR path, BSTR* pVal)
{
	CComPtr<ILDOMNode> node;
	::GetPathNode(element, path, &node);

	if (node)
	{
		CComQIPtr<ILDOMAttr> attr = node;
		if (attr)
		{
			CComBSTR value;
			attr->get_value(&value);

			*pVal = value.Detach();
			return S_OK;
		}
		else
		{
			CComBSTR value;
			node->get_textContent(&value);

			*pVal = value.Detach();
			return S_OK;
		}
	}

	*pVal = NULL;
	return S_OK;
}
Example #22
0
void RichEditHost::SetMaxLength(uint nMaxLength)
{
    if (m_dwMaxLength != nMaxLength)
    {
        m_dwMaxLength = nMaxLength;
        if (m_pTextServices)
        {
            CComBSTR bsText;
            if (m_pTextServices)
            {
                m_pTextServices->TxGetText(&bsText);
                if (bsText.Length() > 0)
                {
                    wstring wstrText = bsText;
                    if (wstrText.length() > m_dwMaxLength)
                    {
                        wstrText.erase(wstrText.begin() + m_dwMaxLength, wstrText.end());
                        m_pTextServices->TxSetText(wstrText.c_str());
                    }
                }
            }

            LRESULT lRes = 0;
            HRESULT hr = m_pTextServices->TxSendMessage(EM_EXLIMITTEXT, 0, nMaxLength, &lRes);
            hr = m_pTextServices->OnTxPropertyBitsChange(TXTBIT_MAXLENGTHCHANGE, TXTBIT_MAXLENGTHCHANGE);
        }
    }
}
Example #23
0
    BSTR DocTracker::GetFilename()
    {
        _ASSERT( IsValid() );

        HRESULT                     hr = S_OK;
        RefPtr<MagoST::ISession>    session;
        MagoST::FileInfo            info = { 0 };
        CComBSTR                    filename;

        if ( !mCurData.mHasLineInfo )
            return NULL;

        if ( !mCurData.mMod->GetSymbolSession( session ) )
            return NULL;

        hr = session->GetFileInfo( mCurData.mCompilandIndex, mCurData.mFileIndex, info );
        if ( FAILED( hr ) )
            return NULL;

        hr = Utf8To16( info.Name.ptr, info.Name.length, filename.m_str );
        if ( FAILED( hr ) )
            return NULL;

        return filename.Detach();
    }
//------------------------------------------------------------------------
//! Update the description text of the group footer
//!
//! @param nGroupId ID of the group
//! @param strFooter The footer description text
//! @param dwAlign Indicates the alignment of the footer text for the group
//! @return Succeeded in updating the group footer
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::SetGroupFooter(int nGroupId, const CString& strFooter, DWORD dwAlign)
{
	if (!IsGroupStateEnabled())
		return FALSE;

#if _WIN32_WINNT >= 0x0600
	LVGROUP lg = {0};
	lg.cbSize = sizeof(lg);
	lg.mask = LVGF_FOOTER | LVGF_ALIGN;
	lg.uAlign = dwAlign;
#ifdef UNICODE
	lg.pszFooter = (LPWSTR)(LPCTSTR)strFooter;
	lg.cchFooter = strFooter.GetLength();
#else
	CComBSTR bstrFooter = strFooter;
	lg.pszFooter = bstrFooter;
	lg.cchFooter = bstrFooter.Length();
#endif

	if (SetGroupInfo(nGroupId, (PLVGROUP)&lg)==-1)
		return FALSE;

	return TRUE;
#else
	return FALSE;
#endif
}
Example #25
0
STDMETHODIMP ASDTDModel::saveAsText(BSTR *pVal)
{
    if (pVal == NULL) return E_POINTER;

    CComBSTR text = OLESTR("");

    for (int i = 0; i < m_elementDeclarations->m_items.GetSize(); i++)
    {
        CASDTDElement* pElement = (CASDTDElement*)m_elementDeclarations->m_items[i];

        text += pElement->GetAsText();

        if (pElement->m_attributeDecls->m_items.GetSize() > 0)
        {
            text += OLESTR("<!ATTLIST ");
            text += pElement->m_name;
            text += OLESTR(" ");

            for (int j = 0; j < pElement->m_attributeDecls->m_items.GetSize(); j++)
            {
                CASDTDAttribute* pAttribute = (CASDTDAttribute*)pElement->m_attributeDecls->m_items[j];

                text += pAttribute->m_name;
                text += OLESTR("\n");
            }

            text += OLESTR(">\n");
        }
    }

    *pVal = text.Detach();

    return S_OK;
}
//------------------------------------------------------------------------
//! Update the subtitle in the group header
//!
//! @param nGroupId ID of the group
//! @param strSubtitle The subtitle description text
//! @return Succeeded in updating the group subtitle
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::SetGroupSubtitle(int nGroupId, const CString& strSubtitle)
{
	if (!IsGroupStateEnabled())
		return FALSE;

#if _WIN32_WINNT >= 0x0600
	LVGROUP lg = {0};
	lg.cbSize = sizeof(lg);
	lg.mask = LVGF_SUBTITLE;
#ifdef UNICODE
	lg.pszSubtitle = (LPWSTR)(LPCTSTR)strSubtitle;
	lg.cchSubtitle = strSubtitle.GetLength();
#else
	CComBSTR bstrSubtitle = strSubtitle;
	lg.pszSubtitle = bstrSubtitle;
	lg.cchSubtitle = bstrSubtitle.Length();
#endif

	if (SetGroupInfo(nGroupId, (PLVGROUP)&lg)==-1)
		return FALSE;

	return TRUE;
#else
	return FALSE;
#endif
}
BOOL vmsMetalinkFile::ReadUrlNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Url *url)
{
	USES_CONVERSION;

	IXMLDOMNamedNodeMapPtr spAttrs;
	pNode->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;

	IXMLDOMNodePtr spType;
	spAttrs->getNamedItem (L"type", &spType);
	if (spType == NULL)
		return FALSE;

	COleVariant vt;
	spType->get_nodeValue (&vt);
	ASSERT (vt.vt == VT_BSTR);
	if (vt.vt == VT_BSTR)
		url->strProtocol = W2A (vt.bstrVal);
	
	CComBSTR bstrText;
	pNode->get_text (&bstrText);
	if (bstrText.Length () == 0)
		return FALSE;

	url->strUrl = W2A (bstrText);

	return TRUE;
}
Example #28
0
Handle<Value> EditorGetSelection(const Arguments& args)
{
    CComPtr<VirtualPoint> virtualPoint;
    CComBSTR buf;    

    g_pSelection->get_Text(&buf);

    int retValLen = buf.Length();
    if (0 == retValLen)
        return String::New("");

    PSTR asciiBuf = (PSTR)HeapAlloc(GetProcessHeap(), 0, retValLen + 1);

    WideCharToMultiByte(CP_ACP, 0, buf, retValLen + 1, asciiBuf, retValLen + 1, NULL, NULL);
    asciiBuf[retValLen] = '\0';

    int destIndex = 0;
    for (int index = 0; index <= retValLen; index++)
    {
        if (asciiBuf[index] != '\r')
        {
            asciiBuf[destIndex] = asciiBuf[index];
            destIndex++;
        }
    }
    asciiBuf[destIndex] = '\0';

    Handle<String> retVal = String::New(asciiBuf, destIndex);

    HeapFree(GetProcessHeap(), 0, asciiBuf);

    return retVal;
}
Example #29
0
// Besorgen des Tabellennamens (sofern einer exitiert)
HRESULT DatenBasisObjekt::GetTableName (TABLENAME *pTableName)
{
// Rückgabewerte initialisieren
int iLen = pTableName -> iLen;

	pTableName -> pBuffer[0] = '\0';
	pTableName -> iLen = 0;

// Objektmenge aus globaler Tabelle lesen
WTRiASObjects Objs;
HRESULT hr = S_OK;

	if (FAILED(hr = GetObjectsFromMap (pTableName -> lIdent, Objs)))
		return hr;

CComBSTR bstrName;

	RETURN_FAILED_HRESULT(hr = Objs -> get_TableName (CLEARED(&bstrName)));

int iToCopy = min ((int)bstrName.Length(), iLen -1);

	USES_CONVERSION;
	strncpy (pTableName -> pBuffer, OLE2A(bstrName), iToCopy);
	pTableName -> pBuffer[iToCopy] = '\0';
	pTableName -> iLen = iToCopy;

	return hr;
}
Example #30
0
HRESULT CPigEngine::get_AccountDispenser(IPigAccountDispenser** ppDispenser)
{
  // Get the computer name of the account server
  CComBSTR bstrServer;
  RETURN_FAILED(get_AccountServer(&bstrServer));
  if (!bstrServer.Length())
  {
    // Get the computer name of the mission server
    RETURN_FAILED(get_MissionServer(&bstrServer));
  }

  // Check for '.' to indicate this computer
  if (1 == bstrServer.Length() && OLESTR('.') == bstrServer[0])
    bstrServer.Empty();

  // Create the Pig Account Dispenser on the mission server
  COSERVERINFO si  = {0, bstrServer, NULL, 0};
  MULTI_QI     mqi = {&IID_IPigAccountDispenser, NULL, S_OK};
  RETURN_FAILED(CoCreateInstanceEx(CLSID_PigAccountDispenser, NULL,
    CLSCTX_SERVER, &si, 1, &mqi));

  // Copy the interface pointer to the [out] parameter
  ZSucceeded(mqi.hr);
  *ppDispenser = (IPigAccountDispenser*)mqi.pItf;

  // Indicate success
  return S_OK;
}