コード例 #1
0
//Define OnToolTipText(). This is the handler for the TTN_NEEDTEXT notification from 
//support ansi and unicode 
BOOL CClipboardListBox::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	CString strTipText;
	UINT nID = pNMHDR->idFrom;

	
	GetText( nID ,strTipText);

#ifndef _UNICODE
	if (pNMHDR->code == TTN_NEEDTEXTA)
		lstrcpyn(pTTTA->szText, strTipText, 80);
	else
		_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
	if (pNMHDR->code == TTN_NEEDTEXTA)
		_wcstombsz(pTTTA->szText, strTipText, 80);
	else
		lstrcpyn(pTTTW->szText, strTipText, 80);
#endif
	*pResult = 0;

	return TRUE;    
}
コード例 #2
0
ファイル: TTListCtrl.cpp プロジェクト: Robertysc/ecos
BOOL CTTListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	id=pNMHDR->idFrom;

  if(0==id--){	  	// Notification in NT from automatically
		return FALSE;   	// created tooltip
  } else {
	  const CString strTipText(GetItemText(LOWORD(id),HIWORD(id)));
#ifndef _UNICODE
	  if (pNMHDR->code == TTN_NEEDTEXTA)
		  lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
	  else
		  _mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
#else
	  if (pNMHDR->code == TTN_NEEDTEXTA)
		  _wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
	  else
		  lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
#endif
    CRect rect;
    GetSubItemRect(LOWORD(id),HIWORD(id),LVIR_LABEL,rect);
    ClientToScreen(rect);
    //::SetWindowPos(pNMHDR->hwndFrom,NULL,rect.left,rect.top,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSENDCHANGING);
    *pResult = 0;

	  return TRUE;    // message was handled
  }
}
コード例 #3
0
ファイル: ListCtrlEx.cpp プロジェクト: enramot/browser
BOOL CListCtrlEx::OnToolTipText(UINT /*uID*/, NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
    BOOL bRet = TRUE;
#ifdef _TOOL_TIP_ENABLE
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
    TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
    UINT nID = pNMHDR->idFrom;
    if(!nID)
    	bRet = FALSE;

	if(bRet)
	{
		int nRow = ((nID-1) >> 10) & 0x3fffff ;
		int nCol = (nID-1) & 0x3ff;
		CString strTipText = GetItemText(nRow, nCol);
		strTipText.TrimRight();
		strTipText.TrimLeft();
#ifndef _UNICODE
		if (pNMHDR->code == TTN_NEEDTEXTA)
			lstrcpyn(pTTTA->szText, strTipText, 80);
		else
			_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
		if(pNMHDR->code == TTN_NEEDTEXTA)
			_wcstombsz(pTTTA->szText, strTipText, 80);
		else
			lstrcpyn(pTTTW->szText, strTipText, 80);
#endif
	}
    
	*pResult = 0;
#endif

    return bRet;
}
コード例 #4
0
ファイル: MyListCtrl.cpp プロジェクト: WisemanLim/femos
BOOL CMyListCtrl::OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
    // 메시지의 ANSI 와 UNICODE 버전의 핸들이 필요함
    TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
    TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
    CString strTipText;
    UINT nID = pNMHDR->idFrom;

    if(nID == 0) return FALSE; // 툴팁이 생성되었음

    int nRow   = ((nID-1) >> 10) & 0x3fffff;
    int nCol   = (nID-1) & 0x3ff;
    strTipText = GetItemText(nRow, nCol);

#ifndef _UNICODE
    if(pNMHDR->code == TTN_NEEDTEXTA)
        lstrcpyn(pTTTA->szText, strTipText, MAX_PATH);
    else
        _mbstowcsz(pTTTW->szText, strTipText, MAX_PATH);
#else
    if(pNMHDR->code == TTN_NEEDTEXTA)
        _wcstombsz(pTTTA->szText, strTipText, MAX_PATH);
    else
        lstrcpyn(pTTTW->szText, strTipText, MAX_PATH);
#endif

    *pResult = 0;

    return TRUE;
}
コード例 #5
0
/*
================
CSyntaxRichEditCtrl::OnToolTipNotify
================
*/
BOOL CSyntaxRichEditCtrl::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

	*pResult = 0;

	idStr name;

	if ( GetNameForMousePosition( name ) ) {
		CString toolTip;

		if ( GetToolTip == NULL || !GetToolTip( name, toolTip ) ) {

			int keyWordIndex = FindKeyWord( name, name.Length() );

			if ( keyWordIndex != -1 && keyWords[keyWordIndex].description[0] != '\0' ) {
				toolTip = keyWords[keyWordIndex].description;
			} else {
				toolTip = name.c_str();
			}
		}

		AFX_MODULE_THREAD_STATE *state = AfxGetModuleThreadState();

		// set max tool tip width to enable multi-line tool tips using "\r\n" for line breaks
		state->m_pToolTip->SetMaxTipWidth( 500 );

		// set the number of milliseconds after which the tool tip automatically disappears
		state->m_pToolTip->SetDelayTime( TTDT_AUTOPOP, 5000 + toolTip.GetLength() * 50 );

#ifndef _UNICODE
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			_mbstowcsz( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pwchTip;
		}
#else
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			_wcstombsz( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR) m_pwchTip;
		}
#endif

		return TRUE;
	}
	return FALSE;
}
コード例 #6
0
ファイル: strcore.cpp プロジェクト: rickerliang/OpenNT
const CString& CString::operator=(LPCWSTR lpsz)
{
	int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
	AllocBeforeWrite(nSrcLen*2);
	_wcstombsz(m_pchData, lpsz, (nSrcLen*2)+1);
	ReleaseBuffer();
	return *this;
}
コード例 #7
0
ファイル: telnet.cpp プロジェクト: BackupTheBerlios/arnold
int CTelnetServerSession::Send(LPCWSTR sz, int nFlags /*= 0*/)
{
   const int len = wcslen(sz) + 1;
   char* buffer = new char[len];
   _wcstombsz(buffer, sz, len);
   const int n = Send(buffer, nFlags);
   delete [] buffer;
   return n;
}
コード例 #8
0
BOOL CSubTooltipListCtrl::OnToolTipText(UINT /*id*/, NMHDR * pNMHDR, LRESULT * pResult)
{
    if (pProvider == NULL)
        return FALSE;

    TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
    TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

    // Ignore messages from the built in tooltip, we are processing them internally
    if( (pNMHDR->idFrom == (UINT_PTR)m_hWnd) &&
        ( ((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
        ((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND)) ) )
    {
        return FALSE;
    }

    *pResult = 0;

    //Get the mouse position
    const MSG* pMessage = GetCurrentMessage();

    CPoint pt;
    pt = pMessage->pt;
    ScreenToClient(&pt);

    // Check if the point falls onto a list item
    LVHITTESTINFO lvhitTestInfo;
    lvhitTestInfo.pt = pt;

    int nItem = SubItemHitTest(&lvhitTestInfo);

    if (lvhitTestInfo.flags & LVHT_ONITEM)
    {
        // we want multiline tooltips
        ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, INT_MAX);
        CString strTipText = pProvider->GetToolTipText(nItem, lvhitTestInfo.iSubItem);

        //Deal with UNICODE
#ifndef _UNICODE
        if (pNMHDR->code == TTN_NEEDTEXTA)
            StringCchCopy(pTTTA->szText, _countof(pTTTA->szText), strTipText);
        else
            _mbstowcsz(pTTTW->szText, strTipText, 80);
#else
        if (pNMHDR->code == TTN_NEEDTEXTA)
            _wcstombsz(pTTTA->szText, strTipText, 80);
        else
            StringCchCopy(pTTTW->szText, _countof(pTTTW->szText), strTipText);
#endif
        return TRUE;    //We found a tool tip,
        //tell the framework this message has been handled
    }

    return FALSE; //We didn't handle the message,
    //let the framework continue propagating the message
}
コード例 #9
0
ファイル: DLlist.cpp プロジェクト: DLive/qqpattren
BOOL DLlist::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ){
	//Handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	
	if( (pNMHDR->idFrom == (UINT)m_hWnd) &&
		 ( ((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
         ((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND)) ) ){
      return FALSE;
	}
	
	*pResult = 0;
	
	const MSG* pMessage = GetCurrentMessage();
	ASSERT ( pMessage );
	CPoint pt;
	//::GetCursorPos(&pt);
	pt = pMessage->pt; //Get the point from the message
	ScreenToClient( &pt );
    
	LVHITTESTINFO lvinfo;
	lvinfo.pt	= pt;
	int iItem=HitTest(&lvinfo);
	UINT nFlags =   lvinfo.flags;
	int iSubItem=getSubItemHitTest(pt,iItem);

	//CString tt;
	//GetToolTips()->GetWindowTextW(tt);
	//TRACE1("__%s__",tt);
	if((nFlags & LVHT_ONITEMLABEL) && m_oldRTip==iItem &&m_oldCTip==iSubItem )
	{
		CString text,tt;
		
		/*GetToolTips()->GetText(tt,this);
		TRACE1("_TT_%s_",tt);*/
		text=this->GetItemText(iItem,iSubItem);

		//_tcscpy(pTTTW->lpszText,text);
		  #ifndef _UNICODE
			  if (pNMHDR->code == TTN_NEEDTEXTA)
				  lstrcpyn(pTTTA->szText, text, 80);
			  else
				  _mbstowcsz(pTTTW->szText, text, 80);
		  #else
			  if (pNMHDR->code == TTN_NEEDTEXTA)
				  _wcstombsz(pTTTA->szText, text, 80);
			  else
				  lstrcpyn(pTTTW->szText, text, 80);
		  #endif
			 // TRACE1("__%d__",pNMHDR->idFrom);
		return TRUE;
	}

	return TRUE;  //表示已处理(自己理解的,未验证)
}
コード例 #10
0
ファイル: strcore.cpp プロジェクト: rickerliang/OpenNT
CString::CString(LPCWSTR lpsz)
{
	Init();
	int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
	if (nSrcLen != 0)
	{
		AllocBuffer(nSrcLen*2);
		_wcstombsz(m_pchData, lpsz, (nSrcLen*2)+1);
		ReleaseBuffer();
	}
}
コード例 #11
0
ファイル: WindowSelector.cpp プロジェクト: jjayne/nSIGHTS
// 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
}
コード例 #12
0
BOOL CMyComboBoxEdit::OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
    TOOLTIPTEXTA *pTTTA = (TOOLTIPTEXTA *) pNMHDR;
    TOOLTIPTEXTW *pTTTW = (TOOLTIPTEXTW *) pNMHDR;
    static CString szTipText;
    UINT nID = pNMHDR->idFrom;

    if(nID == 0)
        return FALSE;

    if(this->HaveTooltipText())
        szTipText = this->GetTooltipText();
    else
        GetWindowText(szTipText);

    // length of tooltips buffer
    static const int nMyTooltipsWidth = 4096;

    // check the tooltip text length
    if(szTipText.GetLength() > nMyTooltipsWidth)
        return FALSE;
    
    ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM) nMyTooltipsWidth);

    TCHAR szBuff[nMyTooltipsWidth] = _T("");
    _stprintf(szBuff, _T("%s"), szTipText);

#ifndef _UNICODE
    if(pNMHDR->code == TTN_NEEDTEXTA)
    {
        pTTTA->lpszText = szBuff;
    }
    else
    {
        wchar_t szTmpBuff[nMyTooltipsWidth];
        _mbstowcsz(szTmpBuff, szBuff, szTipText.GetLength() + 1);
        pTTTW->lpszText = szTmpBuff;
    }
#else
    if(pNMHDR->code == TTN_NEEDTEXTA)
    {
        char szTmpBuff[nMyTooltipsWidth];
        _wcstombsz(szTmpBuff, szBuff, szTipText.GetLength() + 1);
        pTTTA->lpszText = szTmpBuff;
    }
    else
    {
        pTTTW->lpszText = szBuff;
    }
#endif

    *pResult = 0;
    return TRUE;
}
コード例 #13
0
ファイル: MainFrm.cpp プロジェクト: IMSoP/CDex
BOOL CMainFrame::OnMyToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
	ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);

	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	CString strTipText;

	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)(WORD)::GetDlgCtrlID( (HWND)nID ) );
	}

	if (nID != 0) // will be zero on a separator
	{
		// don't handle the message if no string resource found
        CUStringConvert strCnv;
        CUString strLangTipText = g_language.GetString( nID );

		if ( strLangTipText.IsEmpty() )
		{
			return FALSE;
		}	

		// this is the command id, not the button index
        AfxExtractSubString( strTipText, strCnv.ToT( strLangTipText ), 1, _T( '\n' ));
	}
#ifndef _UNICODE
	if (pNMHDR->code == TTN_NEEDTEXTA)
		lstrcpyn(pTTTA->szText, strTipText, _countof(pTTTA->szText) );
	else
		_mbstowcsz(pTTTW->szText, strTipText, _countof(pTTTW->szText) );
#else
	if (pNMHDR->code == TTN_NEEDTEXTA)
		_wcstombsz(pTTTA->szText, strTipText, _countof(pTTTA->szText));
	else
		lstrcpyn(pTTTW->szText, strTipText, _countof(pTTTW->szText));
#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|SWP_NOOWNERZORDER);

	return TRUE;    // message was handled
}
コード例 #14
0
BOOL CInfoShowDialog::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
	ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
	
	// UNICODE 消息
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	CString strTipText;
	UINT nID = pNMHDR->idFrom;
	
	if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
		pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
	{
		// idFrom 为工具条的HWND
		nID = ::GetDlgCtrlID((HWND)nID);
	}
	
	if(nID != 0) // 不为分隔符
	{
		strTipText.LoadString(nID);
		strTipText = strTipText.Mid(strTipText.Find('\n', 0) + 1);
		
#ifndef _UNICODE
		if(pNMHDR->code == TTN_NEEDTEXTA)
		{
			lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
		}
		else
		{
			_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
		}
#else
		if(pNMHDR->code == TTN_NEEDTEXTA)
		{
			_wcstombsz(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
		}
		else
		{
			lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
		}
#endif
		
		*pResult = 0;
		
		// 使工具条提示窗口在最上面
		::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|
			SWP_NOSIZE | SWP_NOMOVE | SWP_NOOWNERZORDER);
		return TRUE;
	}
	return TRUE;
}
コード例 #15
0
ファイル: dumpcont.cpp プロジェクト: jbeaurain/omaha_vs2010
// special version for WIDE characters
CDumpContext& CDumpContext::operator<<(LPCWSTR lpsz)
{
	if (lpsz == NULL)
	{
		OutputString("(NULL)");
		return *this;
	}

	// limited length
	char szBuffer[512];
	_wcstombsz(szBuffer, lpsz, _countof(szBuffer));
	szBuffer[511] = 0;
	return *this << szBuffer;
}
コード例 #16
0
ファイル: sockcore.cpp プロジェクト: rickerliang/OpenNT
static LPSTR AFXAPI ConvertUnicodeToAnsi(LPCTSTR lpszAddress)
{
	if (lpszAddress != NULL)
	{
		int nLen = wcslen(lpszAddress);
		if (nLen != 0)
		{
			LPSTR lpszReturn = new char[nLen*sizeof(TCHAR)+1];
			if (_wcstombsz(lpszReturn, lpszAddress, nLen+1) != 0)
				return lpszReturn;
			delete[] lpszReturn;
		}
	}
	return NULL;
}
コード例 #17
0
ファイル: PropCodepage.cpp プロジェクト: YueLinHo/WinMerge
void PropCodepage::GetEncodingCodePageFromNameString()
{
	int nCustomCodepageValue = _ttol(m_cCustomCodepageValue);
	if (nCustomCodepageValue == 0)
	{
		char *result= new char[80]; 
		long len = wcslen(m_cCustomCodepageValue); 
		_wcstombsz(result, m_cCustomCodepageValue, len); //conversion to char * 
		result[len] = '\0'; //don't forget to put the caracter of terminated string 
		nCustomCodepageValue = GetEncodingCodePageFromName(result);
		delete [] result;
	}
	//if found a new codepage valid
	if (nCustomCodepageValue)
		m_nCustomCodepageValue = nCustomCodepageValue;
}
コード例 #18
0
ファイル: DialogDeclBrowser.cpp プロジェクト: albertz/iodoom3
/*
================
DialogDeclBrowser::OnToolTipNotify
================
*/
BOOL DialogDeclBrowser::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

	if ( pNMHDR->hwndFrom == declTree.GetSafeHwnd() ) {
		CString toolTip;
		const idDecl *decl = GetDeclFromTreeItem( (HTREEITEM) pNMHDR->idFrom );

		if ( !decl ) {
			return FALSE;
		}

		toolTip = va( "%s, line: %d", decl->GetFileName(), decl->GetLineNum() );

#ifndef _UNICODE
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			_mbstowcsz( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pwchTip;
		}
#else
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			_wcstombsz( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR) m_pwchTip;
		}
#endif
		return TRUE;
	}

	return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
コード例 #19
0
ファイル: dumpcont.cpp プロジェクト: Rupan/winscp
// special version for WIDE characters
CDumpContext& CDumpContext::operator<<(LPCWSTR lpsz)
{
	if (lpsz == NULL)
	{
		OutputString("(NULL)");
		return *this;
	}

#ifdef _DEBUG // all CDumpContext output is controlled by afxTraceEnabled
	if (!afxTraceEnabled)
		return *this;
#endif //_DEBUG

	// limited length
	char szBuffer[512];
	_wcstombsz(szBuffer, lpsz, _countof(szBuffer));
	return *this << szBuffer;
}
コード例 #20
0
ファイル: MyGraph.cpp プロジェクト: ghostenter/TortoiseGit
// Handle the tooltip messages.  Returns true to mean message was handled.
BOOL MyGraph::OnNeedText(UINT /*uiId*/, NMHDR* pNMHDR, LRESULT* pResult)
{
	_ASSERTE(pNMHDR  &&  "Bad parameter passed");
	_ASSERTE(pResult  &&  "Bad parameter passed");

	bool bReturn(false);
	UINT_PTR uiID(pNMHDR->idFrom);

	// Notification in NT from automatically created tooltip.
	if (0U != uiID) {
		bReturn = true;

		// Need to handle both ANSI and UNICODE versions of the message.
		TOOLTIPTEXTA* pTTTA = reinterpret_cast<TOOLTIPTEXTA*> (pNMHDR);
		ASSERT_POINTER(pTTTA, TOOLTIPTEXTA);

		TOOLTIPTEXTW* pTTTW = reinterpret_cast<TOOLTIPTEXTW*> (pNMHDR);
		ASSERT_POINTER(pTTTW, TOOLTIPTEXTW);

		CString sTipText(GetTipText());

#ifndef _UNICODE
		if (TTN_NEEDTEXTA == pNMHDR->code) {
			lstrcpyn(pTTTA->szText, sTipText, _countof(pTTTA->szText));
		}
		else {
			_mbstowcsz(pTTTW->szText, sTipText, _countof(pTTTA->szText));
		}
#else
		if (pNMHDR->code == TTN_NEEDTEXTA) {
			_wcstombsz(pTTTA->szText, sTipText, _countof(pTTTA->szText));
		}
		else {
			lstrcpyn(pTTTW->szText, sTipText, _countof(pTTTA->szText));
		}
#endif

		*pResult = 0;
	}

	return bReturn;
}
コード例 #21
0
ファイル: ctlreg.cpp プロジェクト: Rupan/winscp
void _AfxUnregisterInterfaces(ITypeLib* pTypeLib)
{
	TCHAR szKey[128];
	lstrcpy(szKey, _T("Interface\\"));
	LPTSTR pszGuid = szKey + lstrlen(szKey);

	int cTypeInfo = pTypeLib->GetTypeInfoCount();

	for (int i = 0; i < cTypeInfo; i++)
	{
		TYPEKIND tk;
		if (SUCCEEDED(pTypeLib->GetTypeInfoType(i, &tk)) &&
			(tk == TKIND_DISPATCH || tk == TKIND_INTERFACE))
		{
			ITypeInfo* pTypeInfo = NULL;
			if (SUCCEEDED(pTypeLib->GetTypeInfo(i, &pTypeInfo)))
			{
				TYPEATTR* pTypeAttr;
				if (SUCCEEDED(pTypeInfo->GetTypeAttr(&pTypeAttr)))
				{
#if defined(_UNICODE) || defined(OLE2ANSI)
					StringFromGUID2(pTypeAttr->guid, pszGuid, GUID_CCH);
#else
					WCHAR wszGuid[39];
					StringFromGUID2(pTypeAttr->guid, wszGuid, GUID_CCH);
					_wcstombsz(pszGuid, wszGuid, GUID_CCH);
#endif
					_AfxRecursiveRegDeleteKey(HKEY_CLASSES_ROOT, szKey);
					pTypeInfo->ReleaseTypeAttr(pTypeAttr);
				}

				pTypeInfo->Release();
			}
		}
	}
}
コード例 #22
0
BOOL COXMonthCalCtrl::OnToolTip(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{   
	UNREFERENCED_PARAMETER(id);

	ASSERT(pNMHDR->code==TTN_NEEDTEXTA || pNMHDR->code==TTN_NEEDTEXTW);

	DWORD dwMessagePos=::GetMessagePos();
	CPoint point(GET_X_LPARAM(dwMessagePos),GET_Y_LPARAM(dwMessagePos));
	ScreenToClient(&point);
	// now hit test against COXMonthCalCtrl elements
	MCHITTESTINFO mcHitTest;
	::ZeroMemory((void*)&mcHitTest,sizeof(mcHitTest));
	mcHitTest.cbSize=sizeof(mcHitTest);
	mcHitTest.pt=point;
	HitTest(&mcHitTest);

	ASSERT(pNMHDR->idFrom==mcHitTest.uHit);

	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA=(TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW=(TOOLTIPTEXTW*)pNMHDR;
    
	// idFrom must be the handle to the group
	if (pNMHDR->code==TTN_NEEDTEXTA)
		ASSERT((pTTTA->uFlags&TTF_IDISHWND)==0);
	else
		ASSERT((pTTTW->uFlags&TTF_IDISHWND)==0);

	OXNMMCINFOTIP infoTip;
	// fill structure for notification
	infoTip.nmhdr.code=OXMCN_GETINFOTIP;
	infoTip.pMCHitTest=&mcHitTest;

	// notify parent
	CWnd* pParentWnd=GetParent();
	if(pParentWnd)
	{
		// fill notification structure
		infoTip.nmhdr.hwndFrom=GetSafeHwnd();
		infoTip.nmhdr.idFrom=GetDlgCtrlID();

		pParentWnd->SendMessage(WM_NOTIFY,(WPARAM)GetDlgCtrlID(),(LPARAM)&infoTip);
	}

#ifndef _UNICODE
	if(pNMHDR->code==TTN_NEEDTEXTA)
		lstrcpyn(pTTTA->szText,infoTip.szText,countof(pTTTA->szText));
	else
		_mbstowcsz(pTTTW->szText,infoTip.szText,countof(pTTTW->szText));
#else
	if (pNMHDR->code==TTN_NEEDTEXTA)
		_wcstombsz(pTTTA->szText,infoTip.szText,countof(pTTTA->szText));
	else
		lstrcpyn(pTTTW->szText,infoTip.szText,countof(pTTTW->szText));
#endif

	if(pNMHDR->code==TTN_NEEDTEXTA)
	{
		if(infoTip.lpszText==NULL)
			pTTTA->lpszText=pTTTA->szText;
		else
			pTTTA->lpszText=(LPSTR)infoTip.lpszText;
		pTTTA->hinst=infoTip.hinst;
	}
	else
	{
		if(infoTip.lpszText==NULL)
			pTTTW->lpszText=pTTTW->szText;
		else
			pTTTW->lpszText=(LPWSTR)infoTip.lpszText;
		pTTTW->hinst=infoTip.hinst;
	}

	*pResult=0;

	return TRUE;    // message was handled
}
コード例 #23
0
ファイル: GDisplay.cpp プロジェクト: alexshag/FSQAR
void GDisplay::SaveAsJpeg(LPCTSTR pszFileName)
{
	const int req_comps = 3; // request RGB image

	HDC hdcClient = GetDC(m_hWnd); 
	HDC hdcCompatible = CreateCompatibleDC(hdcClient); 
	HBITMAP hBmp = CreateCompatibleBitmap(hdcClient, m_nClientWidth, m_nClientHeight);
	HGDIOBJ hOldBmp = SelectObject(hdcCompatible, hBmp); 

	BitBlt(hdcCompatible, 
		0,0, 
		m_nClientWidth, m_nClientHeight, 
		hdcClient, 
		0,0, 
		SRCCOPY);


	BITMAPINFOHEADER   bi;

	bi.biSize = sizeof(BITMAPINFOHEADER);    
	bi.biWidth = m_nClientWidth;    
	bi.biHeight = m_nClientHeight;  
	bi.biPlanes = 1;    
	bi.biBitCount = 24;				// RGB mode is 24 bits
	bi.biCompression = BI_RGB;    
	bi.biSizeImage = 0;				// can be 0 for 24 bit images
	bi.biXPelsPerMeter = 0x0ec4;	// paint and PSP use this values 
	bi.biYPelsPerMeter = 0x0ec4;    
	bi.biClrUsed = 0;				// we are in RGB mode and have no palette
	bi.biClrImportant = 0;			// all colors are important

	SIZE_T dwBmpSize = ((m_nClientWidth*bi.biBitCount + 31)/24)*4*m_nClientHeight;

	HANDLE hDIB = GlobalAlloc(GHND, dwBmpSize); 
	if (hDIB)
	{
		PUCHAR lpBits = (PUCHAR)GlobalLock(hDIB);

		if (!GetDIBits(hdcClient, hBmp, 0, (WORD)bi.biHeight,
			lpBits, (LPBITMAPINFO)&bi,
			DIB_RGB_COLORS))
		{
			// error handler here...
		}

		// MUST be free later !!!
		PUCHAR pRGBBits = ConvertBMPToRGBBuffer(lpBits,
			m_nClientWidth,
			m_nClientHeight);

		// Fill in the compression parameter structure.
		jpge::params params;
		params.m_quality = 80;
		params.m_subsampling = jpge::H2V2;
		params.m_two_pass_flag = false;

		CHAR szAnsiFileName[MAX_PATH];

#ifndef _UNICODE
		StringCbCopy(szAnsiFileName, MAX_PATH, pszFileName);
#else
		_wcstombsz(szAnsiFileName, pszFileName, MAX_PATH);
#endif

		if (!jpge::compress_image_to_jpeg_file(szAnsiFileName,
			m_nClientWidth, m_nClientHeight,
			req_comps, pRGBBits, params))
		{
			// error handler here...
		}


		//Unlock and Free the DIB from the heap
		GlobalUnlock(hDIB);

		// DON'T forget free this !!!
		delete pRGBBits;
	}
   
	GlobalFree(hDIB);



	SelectObject(hdcCompatible, hOldBmp);
	DeleteDC(hdcCompatible);
	DeleteObject(hBmp);

}
コード例 #24
0
ファイル: itempropertiesdlg.cpp プロジェクト: wfmdyh/wecan
// **************************************************************************
// UpdateStatus ()
//
// Description:
//	Update the status of controls attached to this dialog based on current
//	properties of selected item.
//	
// Parameters:
//  none
//
// Returns:
//  void
// **************************************************************************
void CKItemPropertiesDlg::UpdateStatus ()
	{
	// Create a wait cursor object.  This will cause the wait cursor, 
	// usually an hourglass, to be displayed.  When this object goes
	// out of scope, its destructor will restore the previous cursor
	// type.
	CWaitCursor wc;

	// Save handle of item with focus.  We will have to change the focus
	// if this item is disabled:
	HWND hWnd = ::GetFocus ();

	// Enable next button if we are not at the end of the list:
	m_cNext.EnableWindow (m_nSelIndex < m_cnItems - 1);

	// Enable the previous button if we are not at the beginning of the list:
	m_cPrev.EnableWindow (m_nSelIndex > 0);

	// Allow the user to modify item ID and access path only if item is invalid:
	CKItem *pItem = GetSelectedItem ();
	ASSERT (pItem != NULL);

	GetDlgItem (IDC_ITEMID)->EnableWindow (!pItem->IsValid ());
	GetDlgItem (IDC_ACCESSPATH)->EnableWindow (!pItem->IsValid ());

	// Load appropriate datatypes (based on current data type and
	// item valid state):

	// First get pointer to data type combo box:
	CComboBox *pCombo = (CComboBox *)GetDlgItem (IDC_DATATYPE);

	// then reset it:
	pCombo->ResetContent ();

	// then load new entries:
	if (pItem->IsValid ())
		{
		// If current data type is an array type:
		if (pItem->GetDataType () & VT_ARRAY)
			{
			pCombo->AddString (_T("Byte Array"));
			pCombo->AddString (_T("Char Array"));
			pCombo->AddString (_T("Word Array"));
			pCombo->AddString (_T("Short Array"));
			pCombo->AddString (_T("DWord Array"));
			pCombo->AddString (_T("Long Array"));
			pCombo->AddString (_T("Float Array"));
			pCombo->AddString (_T("Double Array"));
			}

		// else if it is not an array type"
		else
			{
			pCombo->AddString (_T("Boolean"));
			pCombo->AddString (_T("Byte"));
			pCombo->AddString (_T("Char"));
			pCombo->AddString (_T("Word"));
			pCombo->AddString (_T("Short"));
			pCombo->AddString (_T("DWord"));
			pCombo->AddString (_T("Long"));
			pCombo->AddString (_T("Float"));
			pCombo->AddString (_T("Double"));
			pCombo->AddString (_T("String"));
			}
		}

	// If item is not valid (item has not be re-added), allow all data types:
	else
		{
		pCombo->AddString (_T("Native"));
		pCombo->AddString (_T("Boolean"));
		pCombo->AddString (_T("Byte"));
		pCombo->AddString (_T("Byte Array"));
		pCombo->AddString (_T("Char"));
		pCombo->AddString (_T("Char Array"));
		pCombo->AddString (_T("Word"));
		pCombo->AddString (_T("Word Array"));
		pCombo->AddString (_T("Short"));
		pCombo->AddString (_T("Short Array"));
		pCombo->AddString (_T("DWord"));
		pCombo->AddString (_T("DWord Array"));
		pCombo->AddString (_T("Long"));
		pCombo->AddString (_T("Long Array"));
		pCombo->AddString (_T("Float"));
		pCombo->AddString (_T("Float Array"));
		pCombo->AddString (_T("Double"));
		pCombo->AddString (_T("Double Array"));
		pCombo->AddString (_T("String"));
		}

	// Fill available 2.0 item properties (We won't be able to do this
	// unless we have a pointer to the item properties interface.)
	if (m_pIItemProps != NULL)
		{
		TCHAR szBuffer [DEFBUFFSIZE];
		WCHAR *pszItemID		= NULL;
		DWORD dwCount			= 0;
		DWORD dwIndex			= 0;		
		DWORD *pdwIDs			= NULL;
		LPWSTR *pszDescriptions	= NULL;
		LPWSTR *pszLookupIDs	= NULL;
		VARTYPE *pvtDataTypes	= NULL;
		VARIANT *pvtValues		= NULL;
		HRESULT *pValErrs		= NULL;
		HRESULT *pLookupErrs	= NULL;
		HRESULT hr				= E_FAIL;

		// Get pointer to list control:
		CListCtrl *pList = (CListCtrl *) GetDlgItem (IDC_LIST);
		ASSERT (pList != NULL);

		// Delete any list items that are present:
		pList->DeleteAllItems ();

		// Obtain the qualified ID:
		ASSERT (!m_strItemID.IsEmpty ());

		CString strQualifiedID;

		if (!m_strAccessPath.IsEmpty () && m_pServer->IsKepServerEx ())
			{
			strQualifiedID = m_strAccessPath;
			strQualifiedID += _T(".");
			strQualifiedID += m_strItemID;
			}
		else
			strQualifiedID = m_strItemID;

		// Allocate storage for item ID string:
		pszItemID = (WCHAR *) CoTaskMemAlloc ((strQualifiedID.GetLength () + 1) * sizeof (WCHAR));

		// Convert item ID to UNICODE if needed and copy to allocated memory:
#ifdef _UNICODE
		lstrcpyn (pszItemID, strQualifiedID, strQualifiedID.GetLength () + 1);
#else
		_mbstowcsz (pszItemID, strQualifiedID, strQualifiedID.GetLength () + 1);
#endif
		
		// Query available properties:
		hr = m_pIItemProps->QueryAvailableProperties (
			  pszItemID, &dwCount, &pdwIDs, &pszDescriptions, &pvtDataTypes);

		if (SUCCEEDED (hr))
			{
			// Get the current property values for the property ID's we 
			// just queried:
			hr = m_pIItemProps->GetItemProperties (pszItemID, dwCount, 
				pdwIDs, &pvtValues, &pValErrs);

			if (SUCCEEDED (hr))
				{
				// Get lookup item IDs for the property ID's we just queried:
				hr = m_pIItemProps->LookupItemIDs (pszItemID, dwCount, 
					pdwIDs, &pszLookupIDs, &pLookupErrs);

				if (SUCCEEDED (hr))
					{
					// Insert item IDs, descriptions, values and lookup IDs 
					// into the list control:
					for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
						{
						// ID:
						_itot (pdwIDs [dwIndex], szBuffer, 10);
						pList->InsertItem (dwIndex, szBuffer);

						// Description (may have to convert from UNICODE):
#ifdef _UNICODE
						pList->SetItemText (dwIndex, 1, pszDescriptions [dwIndex]);
#else
						_wcstombsz (szBuffer, pszDescriptions [dwIndex], sizeof (szBuffer) / sizeof (TCHAR));
						pList->SetItemText (dwIndex, 1, szBuffer);
#endif						

						// {roperty value:
						if (pValErrs && SUCCEEDED (pValErrs [dwIndex]))
							GetValue (pvtValues [dwIndex], szBuffer, sizeof (szBuffer) / sizeof (TCHAR)); 
						else
							lstrcpyn (szBuffer, _T("???"), sizeof (szBuffer) / sizeof (TCHAR));
						
						pList->SetItemText (dwIndex, 2, szBuffer);

						// Lookup item ID (may have to convert from UNICODE):
						if (pLookupErrs && SUCCEEDED (pLookupErrs [dwIndex]))
							{
#ifdef _UNICODE
							lstrcpyn (szBuffer, pszLookupIDs [dwIndex], sizeof (szBuffer) / sizeof (TCHAR));
#else
							_wcstombsz (szBuffer, pszLookupIDs [dwIndex], sizeof (szBuffer) / sizeof (TCHAR));
#endif
							}
						else
							{
							// No lookup item ID, so place "N/A" in list control:
							lstrcpyn (szBuffer, _T("N/A"), sizeof (szBuffer) / sizeof (TCHAR));
							pszLookupIDs [dwIndex] = NULL;
							}
						
						pList->SetItemText (dwIndex, 3, szBuffer);
						}
					}
				}
			}

		// COM requires us to free memory for data passed back to us:
		for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
			{
			if (pszDescriptions && pszDescriptions [dwIndex]) 
				CoTaskMemFree (pszDescriptions [dwIndex]);

			if (pszLookupIDs && pszLookupIDs [dwIndex])
				CoTaskMemFree (pszLookupIDs [dwIndex]);

			// Clear variants:
			if (pvtValues)
				VariantClear (&pvtValues [dwIndex]);
			}

		if (pdwIDs)
			CoTaskMemFree (pdwIDs);

		if (pszDescriptions)
			CoTaskMemFree (pszDescriptions);

		if (pszLookupIDs)
			CoTaskMemFree (pszLookupIDs);

		if (pvtDataTypes)
			CoTaskMemFree (pvtDataTypes);

		if (pvtValues)
			CoTaskMemFree (pvtValues);
			
		if (pValErrs)
			CoTaskMemFree (pValErrs);

		if (pLookupErrs)
			CoTaskMemFree (pLookupErrs);
		}

	// Set the focus to the first control (data type) if the control that
	// previously had it became disabled:
	if (hWnd && !::IsWindowEnabled (hWnd))
		GetDlgItem (IDC_DATATYPE)->SetFocus ();

	// Transfer data to controls:
	UpdateData (false);
	}
コード例 #25
0
ファイル: DOCMAPI.CPP プロジェクト: willpoon/wcwp
void CDocument::OnFileSendMail()
{
    ASSERT_VALID(this);
    ASSERT(_afxIsMailAvail);   // update handler always gets called first

    CWaitCursor wait;

    _AFX_MAIL_STATE* pMailState = _afxMailState;
    if (pMailState->m_hInstMail == NULL)
        pMailState->m_hInstMail = ::LoadLibraryA("MAPI32.DLL");

    if (pMailState->m_hInstMail == NULL)
    {
        AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
        return;
    }
    ASSERT(pMailState->m_hInstMail != NULL);

    ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);
    (FARPROC&)lpfnSendMail = GetProcAddress(pMailState->m_hInstMail, "MAPISendMail");
    if (lpfnSendMail == NULL)
    {
        AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
        return;
    }
    ASSERT(lpfnSendMail != NULL);

    TCHAR szTempName[_MAX_PATH];
    TCHAR szPath[_MAX_PATH];
    BOOL bRemoveTemp = FALSE;
    if (m_strPathName.IsEmpty() || IsModified())
    {
        // save to temporary path
        VERIFY(GetTempPath(_countof(szPath), szPath) != 0);
        VERIFY(GetTempFileName(szPath, _T("afx"), 0, szTempName) != 0);

        // save it, but remember original modified flag
        BOOL bModified = IsModified();
        BOOL bResult = DoSave(szTempName, FALSE);
        SetModifiedFlag(bModified);
        if (!bResult)
        {
            TRACE0("Warning: file save failed during File.Send Mail.\n");
            return;
        }
        bRemoveTemp = TRUE;
    }
    else
    {
        // use actual file since it isn't modified
        lstrcpyn(szTempName, m_strPathName, _countof(szTempName));
    }
#ifdef _UNICODE
    char szTempNameA[_MAX_PATH];
    _wcstombsz(szTempNameA, szTempName, _countof(szTempNameA));
#endif

    // build an appropriate title for the attachment
    TCHAR szTitle[_MAX_PATH];
    if (!m_strPathName.IsEmpty())
        AfxGetFileName(m_strPathName, szTitle, _countof(szTitle));
    else
    {
        lstrcpyn(szTitle, m_strTitle, _countof(szTitle));
        if (m_strTitle.Find('.') == -1) // no extension
        {
            // append the default suffix if there is one
            CString strExt;
            CDocTemplate* pTemplate = GetDocTemplate();
            if (pTemplate != NULL &&
                    pTemplate->GetDocString(strExt, CDocTemplate::filterExt))
            {
                lstrcat(szTitle, strExt);
            }
        }
    }

#ifdef _UNICODE
    char szTitleA[_MAX_PATH];
    _wcstombsz(szTitleA, szTitle, _countof(szTitleA));
#endif

    // prepare the file description (for the attachment)
    MapiFileDesc fileDesc;
    memset(&fileDesc, 0, sizeof(fileDesc));
    fileDesc.nPosition = (ULONG)-1;
#ifdef _UNICODE
    fileDesc.lpszPathName = szTempNameA;
    fileDesc.lpszFileName = szTitleA;
#else
    fileDesc.lpszPathName = szTempName;
    fileDesc.lpszFileName = szTitle;
#endif

    // prepare the message (empty with 1 attachment)
    MapiMessage message;
    memset(&message, 0, sizeof(message));
    message.nFileCount = 1;
    message.lpFiles = &fileDesc;

    // prepare for modal dialog box
    AfxGetApp()->EnableModeless(FALSE);
    HWND hWndTop;
    CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop);

    // some extra precautions are required to use MAPISendMail as it
    // tends to enable the parent window in between dialogs (after
    // the login dialog, but before the send note dialog).
    pParentWnd->SetCapture();
    ::SetFocus(NULL);
    pParentWnd->m_nFlags |= WF_STAYDISABLED;

    int nError = lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(),
                              &message, MAPI_LOGON_UI|MAPI_DIALOG, 0);

    // after returning from the MAPISendMail call, the window must
    // be re-enabled and focus returned to the frame to undo the workaround
    // done before the MAPI call.
    ::ReleaseCapture();
    pParentWnd->m_nFlags &= ~WF_STAYDISABLED;

    pParentWnd->EnableWindow(TRUE);
    ::SetActiveWindow(NULL);
    pParentWnd->SetActiveWindow();
    pParentWnd->SetFocus();
    if (hWndTop != NULL)
        ::EnableWindow(hWndTop, TRUE);
    AfxGetApp()->EnableModeless(TRUE);

    if (nError != SUCCESS_SUCCESS &&
            nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
    {
        AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
    }

    // remove temporary file, if temporary file was used
    if (bRemoveTemp)
        CFile::Remove(szTempName);
}
コード例 #26
0
ファイル: serverpropertysheet.cpp プロジェクト: wfmdyh/wecan
// **************************************************************************
// DisplayComponentCatList ()
//
// Description:
//	Construct a list of installed 1.0 and 2.0 OPC servers and insert into 
//	tree control.
//
// Parameters:
//  HTREEITEM	hParent		Handle of parent tree control item.
//	CATID		catid		Catagory ID (CATID_OPCDAServer10 or
//							  CATID_OPCDAServer20).
//
// Returns:
//  void
// **************************************************************************
void CKServerGeneralPage::DisplayComponentCatList (HTREEITEM hParent, CATID catid)
{
	HRESULT hr;

	// Make sure COM is initialized:
	hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);

	if (SUCCEEDED (hr))
	{
		ICatInformation *pCat = NULL;

		// Get component category manager:
		hr = CoCreateInstance (CLSID_StdComponentCategoriesMgr, 
			NULL,
			CLSCTX_SERVER, 
			IID_ICatInformation,
			(void **)&pCat);

		// If succeeded, enumerate registered components:
		if (SUCCEEDED (hr))
		{
			IEnumCLSID *pEnum = NULL;

			CATID arrcatid [1];
			arrcatid [0] = catid;

			// Enumerate registered components based on clsid:
			hr = pCat->EnumClassesOfCategories (
				sizeof (arrcatid) / sizeof (CATID),	// number of catids in the array that follows
				arrcatid,							// catid array
				0, 
				NULL,
				&pEnum);							// clsid enumerator for registered components under this category

			// If succeeded, process results:
			if (SUCCEEDED (hr))
			{
				GUID guid;
				ULONG fetched;

				// Loop over enumerated components.  Call enemerator's next
				// member function to reference next component and get its
				// guid:
				while ((hr = pEnum->Next (1, &guid, &fetched)) == S_OK)
				{
					// Get the ProgID from the guid:
					WCHAR *wszProgID;
					hr = ProgIDFromCLSID (guid, &wszProgID);

					// If succeeded, add component to list:
					if (SUCCEEDED (hr))
					{
						// ProgID string will be in UNICODE format.  Convert to 
						// ANSI format if this is and ANSI build.  Insert component
						// into list:
					#ifdef _UNICODE
						m_pServerList->InsertItem (wszProgID, ILI_COMPONENT, ILI_COMPONENT, hParent);
					#else
						TCHAR szProgID [DEFBUFFSIZE];

						_wcstombsz (szProgID, wszProgID, sizeof (szProgID) / sizeof (TCHAR));
						m_pServerList->InsertItem (szProgID, ILI_COMPONENT, ILI_COMPONENT, hParent);
					#endif
						// It is up to us to free the Prog ID string memory:
						CoTaskMemFree (wszProgID);
					}
				}

				// Release our enumerator:
				pEnum->Release ();
			}
			// release our category mamager
			pCat->Release ();
		}
		// Uninitialize COM:
		CoUninitialize ();
	}
}
コード例 #27
0
ファイル: serverpropertysheet.cpp プロジェクト: wfmdyh/wecan
// **************************************************************************
// OnInitDialog ()
//
// Description:
//	Called immediately before the dialog box is displayed.  Use opportunity
//	to initialize controls.
//
// Parameters:
//  none
//
// Returns:
//	BOOL - TRUE.
// **************************************************************************
BOOL CKServerStatusPage::OnInitDialog () 
{
	IOPCServer *pIServer = NULL;
	OPCSERVERSTATUS *pServerStatus;
	CString strLoader;
	CString strStatus;
	CString strTemp;

	// Perform default processing:
	CPropertyPage::OnInitDialog ();

	// Get IServer interface:
	ASSERT (m_pServer != NULL);
	pIServer = m_pServer->GetIServer ();

	// Add server name to status string:
	strLoader.FormatMessage (IDS_PROGID, m_pServer->GetProgID ());
	strStatus += strLoader;

	// Add remote machine (if applicable) to status string:
	if (m_pServer->GetRemoteMachine ())
	{
		strLoader.FormatMessage (IDS_REMOTEMACHINE, m_pServer->GetRemoteMachine ());
		strStatus += strLoader;
	}

	// Get the server status:
	if (pIServer && SUCCEEDED (pIServer->GetStatus (&pServerStatus)) && pServerStatus)
	{
		FILETIME ftLocal;
		TCHAR szBuffer [DEFBUFFSIZE];

		// Add vendor name to status string:
		if (pServerStatus->szVendorInfo)
		{
			// Convert venter name from UNICODE if needed:
		#ifdef _UNICODE
			lstrcpyn (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#else
			_wcstombsz (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#endif
			// Add vender name:
			strLoader.FormatMessage (IDS_VENDORNAME, szBuffer);
			strStatus += strLoader;

			// Free memory allocated for vender info:
			CoTaskMemFree (pServerStatus->szVendorInfo);
		}

		// Add start time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftStartTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_STARTTIME, strTemp);
				strStatus += strLoader;
			}
		}	

		// Add current time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftCurrentTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_CURRENTTIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Add last update time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftLastUpdateTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_LASTUPDATETIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Create a string describing server state:
		switch (pServerStatus->dwServerState)
		{
		case OPC_STATUS_RUNNING:
			strTemp.LoadString (IDS_RUNNING);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_FAILED: 
			strTemp.LoadString (IDS_FAILED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_NOCONFIG: 
			strTemp.LoadString (IDS_NOCONFIG);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_SUSPENDED:
			strTemp.LoadString (IDS_SUSPENDED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_TEST: 
			strTemp.LoadString (IDS_TEST);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		default: 
			strLoader.FormatMessage (IDS_SERVERSTATE, _T("???")); 
			break;			
		}

		// Add server state to status string:
		strStatus += strLoader;

		// Add group count to status string:
		strTemp.Format (_T("%d"), pServerStatus->dwGroupCount);
		strLoader.FormatMessage (IDS_GROUPCOUNT, strTemp);
		strStatus += strLoader;

		// Add major version number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMajorVersion);
		strLoader.FormatMessage (IDS_MAJORVERSION, strTemp);
		strStatus += strLoader;

		// Add minor version to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMinorVersion);
		strLoader.FormatMessage (IDS_MINORVERSION, strTemp);
		strStatus += strLoader;

		// Add build number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wBuildNumber);
		strLoader.FormatMessage (IDS_BUILDNUMBER, strTemp);
		strStatus += strLoader;

		// Free memeory allocated for server status:
		CoTaskMemFree (pServerStatus);
	}

	// Else if failed, add string stating unable to determin server status
	// to status string:
	else
	{
		strLoader.LoadString (IDS_UNABLE_TO_DETERMINE_STATUS);
		strStatus += strLoader;
	}

	// Display the status string:
	((CStatic *) GetDlgItem (IDC_STATUS))->SetWindowText (strStatus);

	// return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
	return (TRUE);  
}
コード例 #28
0
ファイル: MyFile.cpp プロジェクト: 9060/wavtoac3encoder
bool CMyFile::FWrite(TCHAR &Buffer)
{
    if(this->_bOpen == false)
        return false;

    if(this->_bWrite == false)
        return false;

    if(this->_nMode == -1)
        return false;

    switch(this->_nMode)
    {
        // 0 -> src = Unicode, dst = Unicode
    case 0:
        {
            try
            {
                this->BufferU = Buffer;
                Write(&this->BufferU, this->nSizeOf_wchar_t);
                return true;
            }
            catch(...)
            {
                return false;
            }
        }
        break;
        // 1 -> src = Ansi, dst = Unicode
    case 1:
        {
            try
            {
                this->BufferA = Buffer;
                _mbstowcsz(&this->BufferU, &this->BufferA, 1);
                Write(&this->BufferU, this->nSizeOf_wchar_t);
                return true;
            }
            catch(...)
            {
                return false;
            }
        }
        break;
        // 2 -> src = Unicode, dst = Ansi
    case 2:
        {
            try
            {
                this->BufferU = Buffer;
                _wcstombsz(&this->BufferA, &this->BufferU, 1);
                Write(&this->BufferA, this->nSizeOf_char);
                return true;
            }
            catch(...)
            {
                return false;
            }
        }
        break;
        // 3 -> src = Ansi, dst = Ansi
    case 3:
        {
            try
            {
                this->BufferA = Buffer;
                Write(&this->BufferA, this->nSizeOf_char);
                return true;
            }
            catch(...)
            {
                return false;
            }
        }
        break;
    default:
        {
            return false;
        }
        break;
    }

    return true;
}
コード例 #29
0
ファイル: MyFile.cpp プロジェクト: 9060/wavtoac3encoder
bool CMyFile::FRead(TCHAR &Buffer)
{
    if(this->_bOpen == false)
        return false;

    if(this->_nMode == -1)
        return false;

    switch(this->_nMode)
    {
        // 0 -> src = Unicode, dst = Unicode
    case 0:
        {
            try
            {
                if(Read(&this->BufferU, this->nSizeOf_wchar_t) == 0)
                    return false;
            }
            catch(...)
            {
                return false;
            }

            Buffer = this->BufferU;
            return true;
        }
        break;
        // 1 -> src = Ansi, dst = Unicode
    case 1:
        {
            try
            {
                if(Read(&this->BufferA, this->nSizeOf_char) == 0)
                    return false;
            }
            catch(...)
            {
                return false;
            }

            _mbstowcsz(&this->BufferU, &this->BufferA, 1);
            Buffer = this->BufferU;
            return true;
        }
        break;
        // 2 -> src = Unicode, dst = Ansi
    case 2:
        {
            try
            {
                if(Read(&this->BufferU, this->nSizeOf_wchar_t) == 0)
                    return false;
            }
            catch(...)
            {
                return false;
            }

            _wcstombsz(&this->BufferA, &this->BufferU, 1);
            Buffer = this->BufferU;
            return true;
        }
        break;
        // 3 -> src = Ansi, dst = Ansi
    case 3:
        {
            try
            {
                if(Read(&this->BufferA, this->nSizeOf_char) == 0)
                    return false;
            }
            catch(...)
            {
                return false;
            }

            Buffer = this->BufferA;
            return true;
        }
        break;
    default:
        {
            return false;
        }
        break;
    }
}