示例#1
0
/**
 * @brief Set default font values.
 */
void CMergeApp::SetFontDefaults()
{
	USES_CONVERSION;

	LOGFONT lfDefault;
	ZeroMemory(&lfDefault, sizeof(LOGFONT));

	MIMECPINFO cpi = {0};
	cpi.bGDICharset = ANSI_CHARSET;
	wcscpy(cpi.wszFixedWidthFont, L"Courier New");
	IMultiLanguage *pMLang = NULL;

	HRESULT hr = CoCreateInstance(CLSID_CMultiLanguage, NULL,
		CLSCTX_INPROC_SERVER, IID_IMultiLanguage, (void **)&pMLang);
	if (SUCCEEDED(hr))
	{
		hr = pMLang->GetCodePageInfo(GetACP(), &cpi);
		pMLang->Release();
	}
	m_pOptions->InitOption(OPT_FONT_FILECMP_CHARSET, (int) cpi.bGDICharset);
	m_pOptions->InitOption(OPT_FONT_FILECMP_FACENAME, W2T(cpi.wszFixedWidthFont));

	m_pOptions->InitOption(OPT_FONT_DIRCMP_CHARSET, (int) cpi.bGDICharset);
	m_pOptions->InitOption(OPT_FONT_DIRCMP_FACENAME, W2T(cpi.wszFixedWidthFont));
}
nsresult
PromptDlg::PromptPassword(HWND hwndParent,
    const PRUnichar *dialogTitle,
    const PRUnichar *text,
    PRUnichar **password,
    const PRUnichar *checkMsg, PRBool *checkValue,
    PRBool *_retval)
{
    NS_ENSURE_ARG_POINTER(text);
    NS_ENSURE_ARG_POINTER(_retval);

    HINSTANCE hInstResource = _Module.m_hInstResource;

    USES_CONVERSION;

    // Duplicate all strings, turning them into TCHARs

    if (dialogTitle)
        mTitle = _tcsdup(W2T(dialogTitle));
    mMessage = _tcsdup(W2T(text));
    if (checkMsg)
    {
        NS_ENSURE_ARG_POINTER(checkValue);
        mCheckMessage = _tcsdup(W2T(checkMsg));
        mCheckValue = *checkValue ? TRUE : FALSE;
    }
    if (password)
    {
        mPassword = _tcsdup(W2T(*password));
    }

    mPromptMode = PROMPT_PASS;
    INT result = DialogBoxParam(hInstResource,
        MAKEINTRESOURCE(IDD_PROMPTUSERPASS), hwndParent, PromptProc, (LPARAM) this);

    if (result == IDOK)
    {
        if (password)
        {
            if (*password)
                nsMemory::Free(*password);
            nsAutoString pass(T2W(mPassword));
            *password = ToNewUnicode(pass);
        }

        if (checkValue)
            *checkValue = mCheckValue;

        *_retval = TRUE;
    }
    else
    {
        *_retval = FALSE;
    }

    return NS_OK;
}
NS_IMETHODIMP CPromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
    const PRUnichar *text)
{
    CMozillaBrowser *pOwner = GetOwningBrowser(parent);
    if (pOwner)
    {
        USES_CONVERSION;
        pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
    }
    return NS_OK;
}
NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
    const PRUnichar *text,
    const PRUnichar *checkMsg, PRBool *checkValue)
{
    CMozillaBrowser *pOwner = GetOwningBrowser(parent);
    if (pOwner)
    {
        // TODO show dialog with check box
        USES_CONVERSION;
        pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
    }
    return NS_OK;
}
NS_IMETHODIMP CPromptService::Confirm(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
    const PRUnichar *text,
    PRBool *_retval)
{
    CMozillaBrowser *pOwner = GetOwningBrowser(parent);
    if (pOwner)
    {
        USES_CONVERSION;
        int nAnswer = pOwner->MessageBox(W2T(text), W2T(dialogTitle),
            MB_YESNO | MB_ICONQUESTION);
        *_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE;
    }
    return NS_OK;
}
	// TODO: <table> special case.
	BOOL SearchElementVisitor::GetElementAttributeValue(CComQIPtr<IHTMLElement> spElement,
	                                                    const String& sAttributeName,
                                                        String* pAttributeValue,
														BOOL    bFullAttribute)
	{
		ATLASSERT(spElement != NULL);
		ATLASSERT(pAttributeValue != NULL);

		if (!_tcsicmp(sAttributeName.c_str(), Common::TEXT_SEARCH_ATTRIBUTE))
		{
			USES_CONVERSION;
			*pAttributeValue = Common::TrimString(W2T(HtmlHelpers::GetTextAttributeValue(spElement)));
			return TRUE;
		}

		String sRealAttributeName; 

		if (!_tcsicmp(sAttributeName.c_str(), _T("class")))
		{
			// According to MSDN when using IHTMLElement::getAttribute to get the CLASS attribute,
			// className should be used as the attribute name.
			sRealAttributeName = _T("className");
		}
		else
		{
			sRealAttributeName = sAttributeName;
		}

		CComVariant vAttrValue;
		HRESULT hRes = spElement->getAttribute(CComBSTR(sRealAttributeName.c_str()), (bFullAttribute ? 0 : 2), &vAttrValue);
		if (hRes != S_OK)
		{
			traceLog << "Can not get the attribute" << sRealAttributeName << " in SearchElementVisitor::GetElementAttributeValue\n";
			return FALSE;
		}

		if ((vAttrValue.vt != VT_BSTR) || (NULL == vAttrValue.bstrVal))
		{
			// The attribute doesn't exist. Return empty string.
			*pAttributeValue = _T("");
		}
		else
		{
			USES_CONVERSION;
			*pAttributeValue = Common::TrimString(W2T(vAttrValue.bstrVal));
		}

		return TRUE;
	}
STDMETHODIMP CComPolygon::put_TextStyleName(BSTR newVal)
{
	try
    {
        AXEntityDocLockNoDbOk(m_objRef.objectId());

        Acad::ErrorStatus es;
        AcAxObjectRefPtr<AsdkPoly> pPoly(&m_objRef,AcDb::kForWrite,Adesk::kTrue);
	    if((es=pPoly.openStatus()) != Acad::eOk)
            throw es;

        USES_CONVERSION;
        AcDbDatabase* pDb = m_objRef.objectId().database();
        if (NULL == pDb)
            pDb = acdbHostApplicationServices()->workingDatabase();
        
        AcDbTextStyleTableRecordPointer pTextStyleRecord(W2T(newVal),pDb,AcDb::kForRead);
        if((es=pTextStyleRecord.openStatus()) != Acad::eOk)
            throw es;

        if ((es=pPoly->setTextStyle(pTextStyleRecord->objectId()))!=Acad::eOk)
            throw es;
        else
            Fire_Notification(DISPID_TEXTSTYLENAME);
    }
    catch(const Acad::ErrorStatus)
    {
        return Error(L"Failed to set TextStyleName.",IID_IComPolygon,E_FAIL);
    }
    catch(const HRESULT hr)
    {
        return Error(L"Invalid argument.",IID_IComPolygon,hr);
    }
	return S_OK;
}
示例#8
0
BOOL CTemplateFile::LoadCurItemHeader()
{
	// read item size
	DWORD readed = 0;
	ReadFile(m_hFile, &m_CurItem.ItemSize, sizeof(m_CurItem.ItemSize),
		&readed, NULL);
	
	// read item name from UTF8 coding in pascal string format
	m_CurItem.ItemName[0] = _T('\0');
	BYTE ItemNameSize = 0;
	ReadFile(m_hFile, &ItemNameSize, sizeof(ItemNameSize),
		&readed, NULL);
	
	char ItemNameBuf[256];
	ReadFile(m_hFile, &ItemNameBuf, ItemNameSize,
		&readed, NULL);
	
	int wSize = MultiByteToWideChar(CP_UTF8, 0, ItemNameBuf, ItemNameSize, NULL, 0);
	LPWSTR wszBuffer = new WCHAR[wSize+1];
	int Count = MultiByteToWideChar(CP_UTF8, 0, ItemNameBuf, ItemNameSize, wszBuffer, wSize+1);
	wszBuffer[Count] = 0;
	USES_CONVERSION;
	lstrcpy(m_CurItem.ItemName, W2T(wszBuffer));
	delete[] wszBuffer;

	return TRUE;
}
示例#9
0
static void ErrorDump()
{
#if 0
    USES_CONVERSION;
    CDBErrorInfo einfo;
    BSTR bstrDescription;
    ULONG nRecords = 0;
    HRESULT hr = einfo.GetErrorRecords(&nRecords);
    if(SUCCEEDED(hr) && nRecords > 0)
    {
        LCID lcid = GetSystemDefaultLCID();
        for(ULONG nIndex = 0; nIndex < nRecords; nIndex++)
        {
            hr = einfo.GetAllErrorInfo(nIndex, lcid, &bstrDescription);
            if(SUCCEEDED(hr))
            {
                AfxMessageBox(OLE2T(bstrDescription));
                SysFreeString(bstrDescription);
            }
        }
    }
#endif
    USES_CONVERSION;
    CComPtr<IErrorInfo> pErrInfo;
    HRESULT hr = ::GetErrorInfo(0, &pErrInfo);
    if(SUCCEEDED(hr))
    {
        _bstr_t bstrErrDescription;
        pErrInfo->GetDescription((BSTR *) &bstrErrDescription);

        CString strDescription = W2T(bstrErrDescription);
        OutputDebugString(strDescription);

    }
}
示例#10
0
HRESULT CDBStepNC::SelectTable(CString tszSQL, StringTable &szColumnTable,	 StringTable &szDataTable)
{
    USES_CONVERSION;
    HRESULT hr;
    //CTable<CDynamicAccessor> rs;
    CTable<CDynamicStringAccessor> rs;

    hr = rs.Open( m_session, "milling_cutter" );

    hr = rs.MoveFirst( );
    int j=0;
    while( SUCCEEDED( hr ) && hr != DB_S_ENDOFROWSET )
    {
        for( size_t i = 1; i < rs.GetColumnCount( ); i++ )
        {
            OutputDebugString(StrFormat( "Column %d [%S]= %s\n",  i, rs.GetColumnName( i ), rs.GetString( i ) ));
            if(j==0)
                szColumnTable(0,i)=W2T(_bstr_t(rs.GetColumnName( i )));
            szDataTable(j,i-1)=rs.GetString( i );


            OutputDebugString(szDataTable(j,i));
        }
        hr = rs.MoveNext( );
        j++;
    }

    return hr;
}
示例#11
0
文件: DropTarget.cpp 项目: acat/emule
HRESULT CMainFrameDropTarget::AddUrlFileContents(LPCTSTR pszFileName)
{
	HRESULT hrResult = S_FALSE;

	TCHAR szExt[_MAX_EXT];
	_tsplitpath(pszFileName, NULL, NULL, NULL, szExt);
	if (_tcsicmp(szExt, FILEEXTDOT_INETSHRTCUT) == 0)
	{
		CComPtr<IUniformResourceLocatorW> pIUrl;
		if (SUCCEEDED(hrResult = CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, IID_IUniformResourceLocatorW, (void**)&pIUrl)))
		{
			CComPtr<IPersistFile> pIFile;
			if (SUCCEEDED(hrResult = pIUrl.QueryInterface(&pIFile)))
			{
				USES_CONVERSION;
				if (SUCCEEDED(hrResult = pIFile->Load(CComBSTR(T2CW(pszFileName)), STGM_READ | STGM_SHARE_DENY_WRITE)))
				{
					LPWSTR pwszUrl;
					if ((hrResult = pIUrl->GetURL(&pwszUrl)) == S_OK)
					{
						if (pwszUrl != NULL && pwszUrl[0] != L'\0' && IsUrlSchemeSupportedW(pwszUrl))
						{
							theApp.emuledlg->ProcessED2KLink(W2T(pwszUrl));
							hrResult = S_OK;
						}
						::CoTaskMemFree(pwszUrl);
					}
				}
			}
		}
	}

	return hrResult;
}
示例#12
0
//se der erro, o retorno comeca com ERROR
NS_IMETHODIMP CLidaAudio::Descriptografar(const nsAString & texto, const nsAString & senha_binhex, nsAString & _retval)
{
	//para fazer: tentar pegar o texto sem copiar
	//usar NS_StringGetData
	std::wstring w_texto;
	w_texto.assign(texto.BeginReading(), texto.EndReading());
	String_Wide2A a_texto;
	a_texto.Load(w_texto.c_str(), /* CP_ACP */ CP_UTF8 );
	


	std::wstring w_senha_binhex;
	w_senha_binhex.assign(senha_binhex.BeginReading(), senha_binhex.EndReading());

	//a senha usamos as conversoes padrao
	USES_CONVERSION;

	std::string a_saida;
	std::string a_erros;

	int status = cripto::descriptografar(a_texto.GetBuffer(), a_saida, W2T(w_senha_binhex.c_str()), a_erros);
	if(status != 0)
	{
		a_saida = "ERROR";
		a_saida += a_erros;
	}

	String_A2Wide w_saida;
	w_saida.Load(a_saida.c_str(), /* CP_ACP */ CP_UTF8 );

	_retval.Assign(w_saida.GetBuffer());
	return NS_OK;
}
示例#13
0
CxSimpleADO::IRecordSetPtr CxSimpleADO::Execute(LPCWSTR lpszSql)
{
    if (!IsConnect())
        return IRecordSetPtr(m_pCommand, NULL);

    USES_CONVERSION;

    m_pCommand->SetActiveConnection( m_pConnection );
    m_pCommand->SetCommandText( W2T((LPWSTR)lpszSql) );

    int nParamCount = m_pParameterSet->GetCount();
    for ( int i=0 ; i<nParamCount ; i++ )
    {
        CxADOParameterSet::ParameterSet* pParamSet = m_pParameterSet->GetAt(i);
        XASSERT( !pParamSet->pParameter );
        pParamSet->pParameter = m_pCommand->CreateParameter( pParamSet->strName, pParamSet->size, adLongVarBinary );
        m_pCommand->Append(pParamSet->pParameter);
        pParamSet->pParameter->AppendChunk(pParamSet->var);
    }

    CxADORecordSet* pRs = m_pCommand->Execute();

    m_pParameterSet->Clear();

    if (!pRs)
        return IRecordSetPtr(m_pCommand, NULL);

    return IRecordSetPtr(m_pCommand, pRs);
}
示例#14
0
HRESULT CDBStepNC::ExecuteSelectSql(CString tszSQL, StringTable &szColumnTable, StringTable &szDataTable)
{
    USES_CONVERSION;
    CCommand< CDynamicStringAccessor > m_QueryCommand;

    HRESULT hr;
    hr = m_QueryCommand.Open( m_session, tszSQL );
    if( FAILED( hr ) )
        return hr;

    hr = m_QueryCommand.MoveFirst();
    if( FAILED( hr ) )
        return hr;
    int j=0;
    while( SUCCEEDED( hr ) && hr != DB_S_ENDOFROWSET )
    {
        for( size_t i = 1; i < m_QueryCommand.GetColumnCount( ); i++ )
        {
            OutputDebugString(StrFormat( "Column %d [%S]= %s\n",  i, m_QueryCommand.GetColumnName( i ), m_QueryCommand.GetString( i ) ));
            szDataTable(j,i-1)=m_QueryCommand.GetString( i );
            if(j==0)
                szColumnTable(0,i)=W2T(_bstr_t(m_QueryCommand.GetColumnName( i )));
        }
        hr = m_QueryCommand.MoveNext( );
        j++;
    }
errors:
    return hr;
}
示例#15
0
STDMETHODIMP CWGUrlReceiver::AddDownload()
{
	
	if (m_bCheckExt && is_ExtToSkip ())
		return E_NOTIMPL;	

	if (m_bIgnoreSize == FALSE)
	{
		UINT iSize = _App.Monitor_SkipSmaller ();
		if (iSize)
		{
			USES_CONVERSION;
			fsDownloadMgr mgr (NULL);
			mgr.CreateByUrl (W2T (m_dlInfo.bstrUrl), TRUE);
			mgr.QuerySize ();
			UINT64 uSize = mgr.GetDownloader ()->GetSSFileSize ();
			if (iSize >= uSize)
				return E_NOTIMPL;	
		}
	}

	CheckYouTubePicture();
	StartJobThread (_threadAddDownload);
	return S_OK;
}
// {secret}
// 
// Name: 
// 	CTestSuiteItemCollection::getTestInformation
// 
// Description:
// 	Retrieves the test name and description for the provided CLSID.
// 
// Arguments:
// 	clsid - The class is for which the name and description are being requested.
// 
// 	rbstrName - Holder for the test name.
// 
// 	rbstrDescription - Holder for the description.
// 
// Results:
// 
//    S_OK - All is well
//    REGDB_E_KEYMISSING - Could not open the registry key.
//    E_UNEXPECTED - An unknown exception has been caught.
// 
HRESULT CTestSuiteItemCollection::getTestInformation(
      CLSID& clsid, CComBSTR& rbstrName, CComBSTR& rbstrDescription)
{
   HRESULT hr = S_OK;

   TCHAR* sztSubKey = NULL;

   try
   {
      CRegKey keyTestInfo;
      
      LPOLESTR szClsId;
      ::StringFromCLSID(clsid, &szClsId);
      
      USES_CONVERSION;
      CComBSTR bstrSubKey(L"CLSID\\");
      
      bstrSubKey.Append(szClsId);
      ::CoTaskMemFree(szClsId);

      bstrSubKey.Append(L"\\Test Information");

      long lResult = keyTestInfo.Open(HKEY_CLASSES_ROOT, W2T(bstrSubKey));
      if(lResult == ERROR_SUCCESS)
      {

         TCHAR sztName[MAX_REG_VALUE_LENGTH];
         TCHAR sztDescription[MAX_REG_VALUE_LENGTH];

         DWORD count = MAX_REG_VALUE_LENGTH;
         lResult = keyTestInfo.QueryValue(sztName, _T("TestName"), &count);
         
         count = MAX_REG_VALUE_LENGTH;
         lResult = keyTestInfo.QueryValue(sztDescription, _T("Description"), &count);

         rbstrName = sztName;
         rbstrDescription = sztDescription;
      }
      else
      {
         hr = REGDB_E_KEYMISSING;
      }                     
   }
   catch(HRESULT hr)
   {
      ATLTRACE("Error 0x%8x\n", hr);
   }
   catch(_com_error& rerr)
   {
      ATLTRACE("Error 0x%8x\n", rerr.Error());
   }
   catch(...)
   {
      hr = E_UNEXPECTED;
   }

   return(hr);
}
示例#17
0
// 29-Sep-2005 SFK	Added create pIFacCfgMgr, check if pIFacCfgMgr is NULL
CString CFacCfgWrap::GetFacilityDirectory(short sFacID)
{
	USES_CONVERSION;
	CString strTemp;
	pIFacCfgMgr.CreateInstance(CLSID_FacilityMgrData);
	if (pIFacCfgMgr) strTemp = W2T(pIFacCfgMgr->GetFacilityDirectory(sFacID));
	pIFacCfgMgr = NULL;
	return(strTemp);
}
HRESULT MultiFileWriter::OpenFile(LPCWSTR pszFileName)
{
	USES_CONVERSION;

	// Is the file already opened
	if (m_hTSBufferFile != INVALID_HANDLE_VALUE)
	{
		return E_FAIL;
	}

	// Is this a valid filename supplied
	CheckPointer(pszFileName,E_POINTER);

	if(wcslen(pszFileName) > MAX_PATH)
  {
    LogDebug("MultiFileWriter: filename too long");
		return ERROR_FILENAME_EXCED_RANGE;
  }
	// Take a copy of the filename
	if (m_pTSBufferFileName)
	{
		delete[] m_pTSBufferFileName;
		m_pTSBufferFileName = NULL;
	}
	m_pTSBufferFileName = new WCHAR[1+lstrlenW(pszFileName)];
	if (m_pTSBufferFileName == NULL)
		return E_OUTOFMEMORY;
	wcscpy(m_pTSBufferFileName, pszFileName);
	
	//check disk space first
	__int64 llDiskSpaceAvailable = 0;
	if (SUCCEEDED(GetAvailableDiskSpace(&llDiskSpaceAvailable)) && (__int64)llDiskSpaceAvailable < (__int64)(m_maxTSFileSize*2))
  {
    LogDebug("MultiFileWriter: not enough free diskspace");
		return E_FAIL;
  }
	TCHAR *pFileName = NULL;

	// Try to open the file
	m_hTSBufferFile = CreateFile(W2T(m_pTSBufferFileName),  // The filename
								 (DWORD) GENERIC_WRITE,             // File access
								 (DWORD) FILE_SHARE_READ,           // Share access
								 NULL,                      // Security
								 (DWORD) CREATE_ALWAYS,             // Open flags
								 (DWORD) 0,                 // More flags
								 NULL);                     // Template

	if (m_hTSBufferFile == INVALID_HANDLE_VALUE)
	{
        LogDebug("MultiFileWriter: fail to create buffer file");
        DWORD dwErr = GetLastError();
        return HRESULT_FROM_WIN32(dwErr);
	}

	return S_OK;

}
示例#19
0
void CxSimpleADO::AppendBlobParameter(LPCWSTR lpParamName, _variant_t& vtBlob, int nBlobSize)
{
    USES_CONVERSION;
    CxADOParameterSet::ParameterSet* pParamSet = new CxADOParameterSet::ParameterSet;
    pParamSet->strName = W2T((LPWSTR)lpParamName);
    VariantCopy( &pParamSet->var, &vtBlob );
    pParamSet->size = nBlobSize;
    pParamSet->pParameter = NULL;
    m_pParameterSet->AddParameter(pParamSet);
}
static CString StripCommParam(BSTR sInit)
{
    USES_CONVERSION;
    LPTSTR lpszPart = W2T(sInit);
    LPTSTR lpszFull = W2T(sInit);
    LPTSTR lpsz = _tcschr(lpszPart, _T(','));
    if (lpsz != NULL)
        *lpsz = _T('\0');

    if (!CheckInitString(lpszPart))
        return lpszPart;

    //HACK!
    CRegKey keySW;
    LONG lRes = keySW.Open(HKEY_LOCAL_MACHINE, _T("Software"));
    if (lRes == ERROR_SUCCESS)
    {
        CRegKey key4C;
        lRes = key4C.Create(keySW, g_cs4Control);
        if (lRes == ERROR_SUCCESS)
        {
            CRegKey keyApp;
            lRes = keyApp.Create(key4C, g_csApp);
            if (lRes == ERROR_SUCCESS)
            {
                CRegKey keySysVar;
                lRes = keySysVar.Create(keyApp, g_csSysVar);
                if (lRes == ERROR_SUCCESS)
                {
                    CRegKey keyResult;
                    lRes = keyResult.Create(keySysVar, lpszPart);
                    if (lRes == ERROR_SUCCESS)
                    {
                         keyResult.SetValue(lpszFull, _T("CommParam"));
                    }
                }
            }
        }
    }

    return lpszPart;
}
示例#21
0
HRESULT CFilterProp::EnumFilters()
{
	if ( !pGB ) return E_FAIL;

    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;

    // Clear filters list box
    m_ListFilters.ResetContent();
    
    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
    {
        m_ListFilters.AddString(TEXT("<ERROR>"));
        return hr;
    }

    // Enumerate all filters in the graph
    while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            m_ListFilters.AddString(TEXT("<ERROR>"));
        }
        else
        {
				ISpecifyPropertyPages *pSpecify;
				hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpecify);
				if (SUCCEEDED(hr)) 
				{
	            pSpecify->Release();

					// Add the filter name to the filters listbox
					USES_CONVERSION;

					lstrcpy(szName, W2T(FilterInfo.achName));
					m_ListFilters.AddString(szName);

				}
				FilterInfo.pGraph->Release();
        }       
        pFilter->Release();
    }
    pEnum->Release();

    return hr;
}
示例#22
0
//
// The GraphBuilder interface provides a FindFilterByName() method,
// which provides similar functionality to the method below.
// This local method is provided for educational purposes.
//
IBaseFilter *FindFilterFromName(IGraphBuilder *pGB, LPTSTR szNameToFind)
{
    USES_CONVERSION;

    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;
    BOOL bFound = FALSE;

    // Verify graph builder interface
    if (!pGB)
        return NULL;

    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
        return NULL;

    // Enumerate all filters in the graph
    while((pEnum->Next(1, &pFilter, &cFetched) == S_OK) && (!bFound))
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            pFilter->Release();
            pEnum->Release();
            return NULL;
        }

        // Compare this filter's name with the one we want
        lstrcpy(szName, W2T(FilterInfo.achName));
        if (! lstrcmp(szName, szNameToFind))
        {
            bFound = TRUE;
        }

        FilterInfo.pGraph->Release();

        // If we found the right filter, don't release its interface.
        // The caller will use it and release it later.
        if (!bFound)
            pFilter->Release();
        else
            break;
    }
    pEnum->Release();

    return (bFound ? pFilter : NULL);
}
示例#23
0
HRESULT CDrawTxt::DoDraw(HDC hdcDest)
{
	USES_CONVERSION;

	// 如果字体宽度小于1,无法绘制
	if (m_dFontWidth > 0 && ROUND(m_dFontWidth) == 0)
		return S_OK;

	//设置背景模式
	int iBkMode = m_bsBackStyle == BackStyleTransparent ? TRANSPARENT : OPAQUE;
	int iOldBkMode = SetBkMode(hdcDest, iBkMode);
//	UINT uOldTextAlignMode = SetTextAlign(hdcDest, m_nTextAlign);
	COLORREF colFore;
	OleTranslateColor(m_clrForeColor, NULL, &colFore);
	COLORREF colOldTextColor = SetTextColor(hdcDest, colFore);

	COLORREF colBack;
	OleTranslateColor(m_clrBackColor, NULL, &colBack);
	COLORREF clrOldBackColor = SetBkColor(hdcDest, colBack);

	HFONT hFont = CreateTextFont(ROUND(m_dFontHeight), ROUND(m_dFontWidth));
	HFONT hOldFont = (HFONT)SelectObject(hdcDest, hFont);

	LPTSTR szCaption = W2T(m_bstrCaption);
	int cbCaption = lstrlen(szCaption);
	RECT rcCaption;
	RECTFToRECT(&m_rcPosition, &rcCaption);
	UINT uFormat = DT_NOPREFIX/* | DT_EXTERNALLEADING*/;
	// 考虑到斜体时可能文本超过外围矩形
	if (m_bAutoSize)
		uFormat |= DT_NOCLIP;
	else if (m_bWordWrap)
		uFormat |= DT_WORDBREAK;
	if (m_nTextAlign == TextAlignCenter)
		uFormat |= DT_CENTER;
	else if (m_nTextAlign == TextAlignRight)
		uFormat |= DT_RIGHT;
	else
		uFormat |= DT_LEFT;
	DrawText(hdcDest, szCaption, cbCaption, &rcCaption, uFormat);

	SelectObject(hdcDest, hOldFont);
	DeleteObject(hFont);

	SetBkMode(hdcDest, iOldBkMode);
//	SetTextAlign(hdcDest, uOldTextAlignMode);
	SetTextColor(hdcDest, colOldTextColor);
	SetBkColor(hdcDest, clrOldBackColor);

	return S_OK;

}
示例#24
0
tstring vmsXmlHelper::FromUtf8(LPCSTR psz)
{
	wchar_t *pwsz = new wchar_t [strlen (psz) + 1];
	
	MultiByteToWideChar (CP_UTF8, 0, psz, -1, pwsz, strlen (psz) + 1);
	
	USES_CONVERSION;
	tstring tstr = W2T (pwsz);
	
	delete [] pwsz;
	
	return tstr;
}
示例#25
0
LRESULT CDataEntryDlg::OnClickedVar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	USES_CONVERSION;
	
	CComBSTR bstr;
	GetDlgItemText(IDC_EXPRESSION, bstr.m_str); 

	CComQIPtr<ICxExpertPageSite> spExperSite(m_pExpert->m_pPageSite);
	spExperSite->OnGetDataSource(&bstr);

	SetDlgItemText(IDC_EXPRESSION, W2T(bstr));
	
	return 0;
}
示例#26
0
HRESULT AddGraphFiltersToList (IGraphBuilder *pGB, CListBox& m_ListFilters) 
{
    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;

    // Clear filters list box
    m_ListFilters.ResetContent();
    
    // Verify graph builder interface
    if (!pGB)
        return E_NOINTERFACE;

    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
    {
        m_ListFilters.AddString(TEXT("<ERROR>"));
        return hr;
    }

    // Enumerate all filters in the graph
    while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            m_ListFilters.AddString(TEXT("<ERROR>"));
        }
        else
        {
            USES_CONVERSION;

            // Add the filter name to the filters listbox
            lstrcpy(szName, W2T(FilterInfo.achName));
            m_ListFilters.AddString(szName);

            // Must release filter graph reference
            FilterInfo.pGraph->Release();
        }       
        pFilter->Release();
    }
    pEnum->Release();

    return hr;
}
示例#27
0
CxSimpleADO::IRecordSetPtr CxSimpleADO::ExecuteDirectSql(LPCWSTR lpszSql)
{
    if (!IsConnect())
        return IRecordSetPtr(m_pCommand, NULL);
    USES_CONVERSION;

    m_pCommand->SetActiveConnection( m_pConnection );
    m_pCommand->SetCommandText( W2T((LPWSTR)lpszSql) );

    CxADORecordSet* pRs = m_pCommand->Execute();
    if (!pRs)
        return IRecordSetPtr(m_pCommand, NULL);

    return IRecordSetPtr(m_pCommand, pRs);
}
示例#28
0
CString CFacCfgWrap::GetFacilityDirectory(short sFacID)
{
	USES_CONVERSION;
	// Change done for E10R3 9/28/05 per SFK note
	// instantiate the facmgr each time a method is called.  HN 10/24/07
	//return(W2T(pIFacCfgMgr->GetFacilityDirectory(sFacID)));
	CString strTemp("");
	pIFacCfgMgr.CreateInstance (CLSID_FacilityMgrData);
	if (pIFacCfgMgr)
	{
		strTemp = W2T (pIFacCfgMgr->GetFacilityDirectory (sFacID));
		pIFacCfgMgr = NULL;
	}
	return (strTemp);
}
示例#29
0
/*****************************************************************************
* CTTSEngObj::MapFile *
*---------------------*
*   Description:
*       Helper function used by SetObjectToken to map file.  This function
*   assumes that m_cpToken has been initialized.
*****************************************************************************/
HRESULT CTTSEngObj::MapFile( const WCHAR * pszTokenVal,  // Value that contains file path
                            HANDLE * phMapping,          // Pointer to file mapping handle
                            void ** ppvData )            // Pointer to the data
{
    USES_CONVERSION;
    HRESULT hr = S_OK;
    CSpDynamicString dstrFilePath;
    hr = m_cpToken->GetStringValue( pszTokenVal, &dstrFilePath );
    if ( SUCCEEDED( hr ) )
    {
        bool fWorked = false;
        *phMapping = NULL;
        *ppvData = NULL;
        HANDLE hFile;
#ifdef _WIN32_WCE
        hFile = CreateFileForMapping( dstrFilePath, GENERIC_READ,
                                      FILE_SHARE_READ, NULL, OPEN_EXISTING,
                                      FILE_ATTRIBUTE_NORMAL, NULL );
#else
        hFile = CreateFile( W2T(dstrFilePath), GENERIC_READ,
                            FILE_SHARE_READ, NULL, OPEN_EXISTING,
                            FILE_ATTRIBUTE_NORMAL, NULL );
#endif
        if (hFile != INVALID_HANDLE_VALUE)
        {
            *phMapping = ::CreateFileMapping( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
            if (*phMapping)
            {
                *ppvData = ::MapViewOfFile( *phMapping, FILE_MAP_READ, 0, 0, 0 );
                if (*ppvData)
                {
                    fWorked = true;
                }
            }
            ::CloseHandle( hFile );
        }
        if (!fWorked)
        {
            hr = HRESULT_FROM_WIN32(::GetLastError());
            if (*phMapping)
            {
                ::CloseHandle(*phMapping);
                *phMapping = NULL;
            }
        }
    }
    return hr;
} /* CTTSEngObj::MapFile */
CString NPStringToCString(NPString npstr)
{
	USES_CONVERSION;
	CString str;
	int nWide =  MultiByteToWideChar(CP_UTF8, 0, npstr.UTF8Characters, npstr.UTF8Length + 1, NULL, 0);
	if (nWide == 0)
		return str;
	WCHAR* wstr = new WCHAR[nWide];
	if (wstr)
	{
		MultiByteToWideChar(CP_UTF8, 0, npstr.UTF8Characters, npstr.UTF8Length + 1, wstr, nWide);
		str = W2T(wstr);
		delete[] wstr;
	}
	return str;
}