コード例 #1
0
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
char* GetNextToken( char** line )
{
    char *pos = *line;
    char *token = nullptr;

    // get up the first real character
    while (IsWhitespace( *pos )) {
        ++pos;
    }

    if (*pos != NULL) {
        token = pos;
        char *out = pos;

        if (*pos == QUOTE) {
            GetNextString( &out, &pos );
        }
        else {
            while (!IsWhitespace( *pos ) && (*pos != NULL)) {
                char nextChar = GetNextCharacter( &pos );
                *out = nextChar;
                ++out;
                ++pos;
            }
        }

        // move past the possible "last position" we left on
        // since we're NULLing it out for our token
        if (*pos != NULL) {
            ++pos;
        }
        *out = NULL;
    }

    *line = pos;
    return token;
}
コード例 #2
0
ファイル: Command.cpp プロジェクト: YoungBot/Engine
static char* GetNextToken(char **stream)
{
	char *s = *stream;
	char *token = nullptr;
	// get up the first real character
	while (IsWhitespace(*s)) {
		++s;
	}

	if (*s != NULL) {
		token = s;
		char *out = s;

		if (*s == QUOTE) {
			GetNextString(&out, &s);
		}
		else {
			while (!IsWhitespace(*s) && (*s != NULL)) {
				char c = GetNextCharacter(&s);
				*out = c;
				++out;
				++s;
			}
		}

		// move past the possible "last position" we left on
		// since we're NULLing it out for our token
		if (*s != NULL) {
			++s;
		}
		*out = NULL;
	}

	*stream = s;
	return token;
}
コード例 #3
0
ファイル: parameters.cpp プロジェクト: gabaker/TARUC_Bench
// Function for parsing user provided input file. 
// Users must adhere to input file structure provided 
// in the sample input file to insure correct parsing
void BenchParams::ParseParamFile(std::string fileStr) {
   inputFile = fileStr;

   std::string lineStr;
   std::ifstream inFile(inputFile.c_str());

   if (inFile.fail()) {
      SetDefault();      
      return;
   }

   useDefaultParams = false;

   // Benchmark Parameters 
   runTag  = GetNextString(inFile);                // runTag
   devPropFile = runTag + "_device_info.out";
   topoFile = runTag + "_topology.out";
   
   // All Tests
   runAllDevices = GetNextBool(inFile);            // runAllDevices 
   testAllMemTypes = GetNextBool(inFile);          // testAllMemTypes 
   runBurstTests = GetNextBool(inFile);            // runBurstTests 
   runRangeTests = GetNextBool(inFile);            // runRangeTests
   runSustainedTests = GetNextBool(inFile);        // runSustainedTests
   runSocketTests = GetNextBool(inFile);           // runSocketTests
   runPatternTests = GetNextBool(inFile);          // runPatternTests
   numPatterns = (runPatternTests ? NUM_ACCESS_PATTERNS: 1);

   numStepRepeats = (long) GetNextInteger(inFile); // numStepRepeats
   numRangeSteps = (long) GetNextInteger(inFile);  // numRangeSteps
   burstBlockSize = GetNextInteger(inFile);        // burstBlockSize
 
   // Memory Overhead Test
   runMemoryOverheadTest = GetNextBool(inFile);    // runMemoryOverheadTest
   for (int i = 0; i < 2; i++)                     // rangeMemOverhead
      rangeMemOH[i] = GetNextInteger(inFile); 

   // Host-Host Bandwidth Test
   runBandwidthTestHH = GetNextBool(inFile);    // runHHBandwidthTest
   for (int i = 0; i < 2; i++)                  // rangeHostHostBW
      rangeHHBW[i] = GetNextInteger(inFile); 

   // Host-Device Bandwidth Test
   runBandwidthTestHD = GetNextBool(inFile);    // runHDBandwidthTest
   for (int i = 0; i < 2; i++)                  // rangeHostDeviceBW
      rangeHDBW[i] = GetNextInteger(inFile); 

   // P2P Bandwidth Test
   runBandwidthTestP2P = GetNextBool(inFile);   // runP2PBandwidthTest
   for (int i = 0; i < 2; i++)                  // rangeDeviceP2P
      rangeP2PBW[i] = GetNextInteger(inFile);

   // NURMA Test
   runNURMATest = GetNextBool(inFile);          // runNURMATest
   gapNURMA = GetNextInteger(inFile);           // gapNURMA
   blockSizeNURMA = GetNextInteger(inFile);     // blockSizeNURMA 
   for (int i = 0; i < 2; i++)                  // rangeNURMA
      rangeNURMA[i] = GetNextInteger(inFile);
 
   // Memory System Contention Test 
   runContentionTest = GetNextBool(inFile);     // runContentionTest
   numContRepeats = GetNextInteger(inFile);     // numContRepeats
   for (int i = 0; i < 3; i++)                  // rangeCont
      contBlockSize[i] = GetNextInteger(inFile);
}
コード例 #4
0
ファイル: ED2KLink.cpp プロジェクト: machado2/emule
CED2KLink* CED2KLink::CreateLinkFromUrl(const TCHAR* uri)
{
	CString strURI(uri);
	int iPos = 0;
	CString strTok = GetNextString(strURI, _T("|"), iPos);
	if (strTok == _T("ed2k://"))
	{
		strTok = GetNextString(strURI, _T("|"), iPos);
		if (strTok == _T("file"))
		{
			CString strName = GetNextString(strURI, _T("|"), iPos);
			if (!strName.IsEmpty())
			{
				CString strSize = GetNextString(strURI, _T("|"), iPos);
				if (!strSize.IsEmpty())
				{
					CString strHash = GetNextString(strURI, _T("|"), iPos);
					if (!strHash.IsEmpty())
					{
						CStringArray astrEd2kParams;
						bool bEmuleExt = false;
						CString strEmuleExt;

						CString strLastTok;
						strTok = GetNextString(strURI, _T("|"), iPos);
						while (!strTok.IsEmpty())
						{
							strLastTok = strTok;
							if (strTok == _T("/"))
							{
								if (bEmuleExt)
									break;
								bEmuleExt = true;
							}
							else
							{
								if (bEmuleExt)
								{
									if (!strEmuleExt.IsEmpty())
										strEmuleExt += _T('|');
									strEmuleExt += strTok;
								}
								else
									astrEd2kParams.Add(strTok);
							}
							strTok = GetNextString(strURI, _T("|"), iPos);
						}

						if (strLastTok == _T("/"))
							return new CED2KFileLink(strName, strSize, strHash, astrEd2kParams, strEmuleExt.IsEmpty() ? (LPCTSTR)NULL : (LPCTSTR)strEmuleExt);
					}
				}
			}
		}
		else if (strTok == _T("serverlist"))
		{
			CString strURL = GetNextString(strURI, _T("|"), iPos);
			if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
				return new CED2KServerListLink(strURL);
		}
		else if (strTok == _T("server"))
		{
			CString strServer = GetNextString(strURI, _T("|"), iPos);
			if (!strServer.IsEmpty())
			{
				CString strPort = GetNextString(strURI, _T("|"), iPos);
				if (!strPort.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
					return new CED2KServerLink(strServer, strPort);
			}
		}
	}

	throw GetResString(IDS_ERR_NOSLLINK);
}
コード例 #5
0
ファイル: notevil.c プロジェクト: hoangduit/reactos
VOID
MainLoop(VOID)
{
    WCHAR NameString[RES_BUFFER_SIZE];
    DWORD NameIndex  = 0;
    INT   NameLength = 0;
    COORD xy;
    INT   n = RES_DELAY_CHANGE;
    INT   dir_y  = 1;
    INT   dir_x  = 1;
    WORD  wColor = 1;

    xy.X = ScreenBufferInfo.dwSize.X / 2;
    xy.Y = ScreenBufferInfo.dwSize.Y / 2;

    for ( ; 1; ++n )
    {
        if (n == RES_DELAY_CHANGE)
        {
            n = 0;

            GetNextString(NameString,
                          RES_BUFFER_SIZE,
                          &NameIndex);
            NameLength = wcslen(NameString);

            wColor++;
            if ((wColor & 0x000F) == 0)
                wColor = 1;
        }
        if (xy.X == 0)
        {
            if (dir_x == -1)
                dir_x = 1;
        }
        else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
        {
            if (dir_x == 1)
                dir_x = -1;
        }
        xy.X += dir_x;

        if (xy.Y == 0)
        {
            if (dir_y == -1)
                dir_y = 1;
        }
        else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
        {
            if (dir_y == 1)
                dir_y = -1;
        }
        xy.Y += dir_y;

#ifdef DISPLAY_COORD
        WriteCoord(xy);
#endif /* def DISPLAY_COORD */

        DisplayTitle();
        WriteStringAt(NameString, xy, wColor);
        WaitForSingleObject(WaitableTimer, INFINITE);
        WriteStringAt(NameString, xy, 0);
    }
}
コード例 #6
0
ファイル: ToolTipCtrlX.cpp プロジェクト: techpub/archive-code
void CToolTipCtrlX::OnNMCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTTCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTTCUSTOMDRAW>(pNMHDR);
	if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT)
	{
		CWnd* pwnd = CWnd::FromHandle(pNMCD->nmcd.hdr.hwndFrom);
		CDC* pdc = CDC::FromHandle(pNMCD->nmcd.hdc);

		CString strText;
		pwnd->GetWindowText(strText);

		CRect rcWnd;
		pwnd->GetWindowRect(&rcWnd);
		CRect rcBorder;
		rcBorder.left = pNMCD->nmcd.rc.left - rcWnd.left;
		rcBorder.top = pNMCD->nmcd.rc.top - rcWnd.top;
		rcBorder.right = rcWnd.right - pNMCD->nmcd.rc.right;
		rcBorder.bottom = rcWnd.bottom - pNMCD->nmcd.rc.bottom;

		if (m_bCol1Bold && m_fontBold.m_hObject == NULL) 
		{
			CFont* pFont = pwnd->GetFont();
			if (pFont) {
				LOGFONT lf;
				pFont->GetLogFont(&lf);
				lf.lfWeight = FW_BOLD;
				VERIFY( m_fontBold.CreateFontIndirect(&lf) );
			}
		}

		int iTextHeight = 0;
		int iMaxCol1Width = 0;
		int iMaxCol2Width = 0;
		int iMaxSingleLineWidth = 0;
		CSize sizText(0);
		int iPos = 0;
		while (iPos != -1)
		{
			CString strLine = GetNextString(strText, _T('\n'), iPos);
			int iColon = strLine.Find(_T(':'));
			if (iColon != -1) {
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				CSize siz = pdc->GetTextExtent(strLine, iColon + 1);
				if (pOldFont)
					pdc->SelectObject(pOldFont);
				iMaxCol1Width = max(iMaxCol1Width, siz.cx);
				iTextHeight = siz.cy; // update height with 'col1' string, because 'col2' string might be empty and therefore has no height
				sizText.cy += siz.cy;

				LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
				while (_istspace(*pszCol2))
					pszCol2++;
				if (*pszCol2 != _T('\0')) {
					siz = pdc->GetTextExtent(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2);
					iMaxCol2Width = max(iMaxCol2Width, siz.cx);
				}
			}
			else if (!strLine.IsEmpty()) {
				CSize siz = pdc->GetTextExtent(strLine);
				iMaxSingleLineWidth = max(iMaxSingleLineWidth, siz.cx);
				sizText.cy += siz.cy;
			}
			else {
				CSize siz = pdc->GetTextExtent(_T(" "), 1);
				sizText.cy += siz.cy;
			}
		}
		iMaxCol1Width = min(m_iScreenWidth4, iMaxCol1Width);
		iMaxCol2Width = min(m_iScreenWidth4*2, iMaxCol2Width);

		const int iMiddleMargin = 6;
		iMaxSingleLineWidth = max(iMaxSingleLineWidth, iMaxCol1Width + iMiddleMargin + iMaxCol2Width);
		sizText.cx = iMaxSingleLineWidth;

		rcWnd.right = rcWnd.left + rcBorder.left + sizText.cx + rcBorder.right;
		rcWnd.bottom = rcWnd.top + rcBorder.top + sizText.cy + rcBorder.bottom;

		if (rcWnd.left >= m_rcScreen.left) {
			if (rcWnd.right > m_rcScreen.right && rcWnd.Width() <= m_rcScreen.Width())
				rcWnd.OffsetRect(-(rcWnd.right - m_rcScreen.right), 0);
		}
		if (rcWnd.top >= m_rcScreen.top) {
			if (rcWnd.bottom > m_rcScreen.bottom && rcWnd.Height() <= m_rcScreen.Height())
				rcWnd.OffsetRect(0, -(rcWnd.bottom - m_rcScreen.bottom));
		}

		pwnd->MoveWindow(&rcWnd);

		pwnd->ScreenToClient(&rcWnd);
		pdc->FillSolidRect(&rcWnd, m_crTooltipBkColor);

		CPoint ptText(pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top);
		iPos = 0;
		while (iPos != -1)
		{
			CString strLine = GetNextString(strText, _T('\n'), iPos);
			int iColon = strLine.Find(_T(':'));
			if (iColon != -1) {
				CRect rcDT(ptText.x, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight);
				// don't draw empty <col1> strings (they are still handy to use for skipping the <col1> space)
				if (iColon > 0) {
					CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
					pdc->DrawText(strLine, iColon + 1, &rcDT, m_dwCol1DrawTextFlags);
					if (pOldFont)
						pdc->SelectObject(pOldFont);
				}

				LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
				while (_istspace(*pszCol2))
					pszCol2++;
				if (*pszCol2 != _T('\0')) {
					rcDT.left = ptText.x + iMaxCol1Width + iMiddleMargin;
					rcDT.right = rcDT.left + iMaxCol2Width;
					pdc->DrawText(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, &rcDT, m_dwCol2DrawTextFlags);
				}

				ptText.y += iTextHeight;
			}
			else {
				CSize siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, 0, NULL, 0);
				ptText.y += siz.cy;
			}
		}

		*pResult = CDRF_SKIPDEFAULT;
		return;
	}

	*pResult = CDRF_DODEFAULT;
}
コード例 #7
0
ファイル: ToolTipCtrlX.cpp プロジェクト: axxapp/winxgui
void CToolTipCtrlX::OnNMCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTTCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTTCUSTOMDRAW>(pNMHDR);
	if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT)
	{
		CWnd* pwnd = CWnd::FromHandle(pNMCD->nmcd.hdr.hwndFrom);
		CDC* pdc = CDC::FromHandle(pNMCD->nmcd.hdc);

		CString strText;
		pwnd->GetWindowText(strText);

		CRect rcWnd;
		pwnd->GetWindowRect(&rcWnd);

		CFont* pOldDCFont = NULL;
		if (m_fontNormal.m_hObject != NULL){
			 pOldDCFont = pdc->SelectObject(&m_fontNormal);
		}
		if (m_bCol1Bold && m_fontBold.m_hObject == NULL) {
			CFont* pFont = pwnd->GetFont();
			if (pFont) {
				LOGFONT lf;
				pFont->GetLogFont(&lf);
				lf.lfWeight = FW_BOLD;
				VERIFY( m_fontBold.CreateFontIndirect(&lf) );
			}
		}
		pdc->SetTextColor(m_crTooltipTextColor);


		int iTextHeight = 0;
		int iMaxCol1Width = 0;
		int iMaxCol2Width = 0;
		int iMaxSingleLineWidth = 0;
		CSize sizText(0);
		int iPos = 0;
		int iCaptionEnd = m_bShowFileIcon ? max(strText.Find(_T("\n<br_head>\n")), 0) : 0; // special tooltip with file icon
		int iCaptionHeigth = 0;
		int iIconMinYBorder = 3;
		int iIconSize = theApp.GetBigSytemIconSize().cx;
		int iIconDrawingSpace = iIconSize + 9;
		while (iPos != -1)
		{
			CString strLine = GetNextString(strText, _T('\n'), iPos);
			int iColon = strLine.Find(_T(':'));
			if (iColon != -1) {
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				CSize siz = pdc->GetTextExtent(strLine, iColon + 1);
				if (pOldFont)
					pdc->SelectObject(pOldFont);
				iMaxCol1Width = max(iMaxCol1Width, siz.cx + ((m_bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength()) ? iIconDrawingSpace : 0));
				iTextHeight = siz.cy + 1; // update height with 'col1' string, because 'col2' string might be empty and therefore has no height
				if (iPos <= iCaptionEnd)
					iCaptionHeigth += siz.cy + 1;
				else
					sizText.cy += siz.cy + 1;

				LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
				while (_istspace((_TUCHAR)*pszCol2))
					pszCol2++;
				if (*pszCol2 != _T('\0')) {
					siz = pdc->GetTextExtent(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2);
					iMaxCol2Width = max(iMaxCol2Width, siz.cx);
				}
			}
			else if (m_bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){
				// file name, printed bold on top without any tabbing or desc
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				CSize siz = pdc->GetTextExtent(strLine);
				if (pOldFont)
					pdc->SelectObject(pOldFont);
				iMaxSingleLineWidth = max(iMaxSingleLineWidth, siz.cx + iIconDrawingSpace);
				iCaptionHeigth += siz.cy + 1;

			}
			else if (!strLine.IsEmpty() && strLine.Compare(_T("<br>")) != 0 && strLine.Compare(_T("<br_head>")) != 0) {
				CSize siz = pdc->GetTextExtent(strLine);
				iMaxSingleLineWidth = max(iMaxSingleLineWidth, siz.cx + ((iPos <= iCaptionEnd) ? iIconDrawingSpace : 0));
				if (m_bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength())
					iCaptionHeigth += siz.cy + 1;
				else
					sizText.cy += siz.cy + 1;
			}
			else{
				CSize siz = pdc->GetTextExtent(_T(" "), 1);
				sizText.cy += siz.cy;
			}
		}
		if (m_bShowFileIcon && iCaptionEnd > 0)
			iCaptionHeigth = max(iCaptionHeigth, iIconSize + (2*iIconMinYBorder));
		sizText.cy += iCaptionHeigth;

		iMaxCol1Width = min(m_iScreenWidth4, iMaxCol1Width);
		iMaxCol2Width = min(m_iScreenWidth4*2, iMaxCol2Width);

		const int iMiddleMargin = 6;
		iMaxSingleLineWidth = max(iMaxSingleLineWidth, iMaxCol1Width + iMiddleMargin + iMaxCol2Width);
		sizText.cx = iMaxSingleLineWidth;
	
		CRect rcNewSize(rcWnd.left, rcWnd.top, rcWnd.left + sizText.cx, rcWnd.top + sizText.cy);
		AdjustRect(&rcNewSize);		
		rcWnd.right = rcWnd.left + rcNewSize.Width();
		rcWnd.bottom = rcWnd.top + rcNewSize.Height();



		if (rcWnd.left >= m_rcScreen.left) {
			if (rcWnd.right > m_rcScreen.right && rcWnd.Width() <= m_rcScreen.Width())
				rcWnd.OffsetRect(-(rcWnd.right - m_rcScreen.right), 0);
		}
		if (rcWnd.top >= m_rcScreen.top) {
			if (rcWnd.bottom > m_rcScreen.bottom && rcWnd.Height() <= m_rcScreen.Height())
				rcWnd.OffsetRect(0, -(rcWnd.bottom - m_rcScreen.bottom));
		}
		CPoint ptText(pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top);

		pwnd->MoveWindow(&rcWnd);
		pwnd->ScreenToClient(&rcWnd);
		pNMCD->nmcd.rc.right = rcWnd.right; 
		pNMCD->nmcd.rc.bottom = rcWnd.bottom;
		pdc->FillSolidRect(&rcWnd, m_crTooltipBkColor);

		
		iPos = 0;
		while (iPos != -1)
		{
			CString strLine = GetNextString(strText, _T('\n'), iPos);
			int iColon = strLine.Find(_T(':'));
			CRect rcDT;
			if (!m_bShowFileIcon || (unsigned)iPos > (unsigned)iCaptionEnd + strLine.GetLength())
				rcDT.SetRect(ptText.x, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight);
			else
				rcDT.SetRect(ptText.x + iIconDrawingSpace, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight);
			if (iColon != -1) {
				// don't draw empty <col1> strings (they are still handy to use for skipping the <col1> space)
				if (iColon > 0) {
					CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
					pdc->DrawText(strLine, iColon + 1, &rcDT, m_dwCol1DrawTextFlags);
					if (pOldFont)
						pdc->SelectObject(pOldFont);
				}

				LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
				while (_istspace((_TUCHAR)*pszCol2))
					pszCol2++;
				if (*pszCol2 != _T('\0')) {
					rcDT.left = ptText.x + iMaxCol1Width + iMiddleMargin;
					rcDT.right = rcDT.left + iMaxCol2Width;
					pdc->DrawText(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, &rcDT, m_dwCol2DrawTextFlags);
				}

				ptText.y += iTextHeight;
			}
			else if (m_bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){
				// first line on special fileicon tab - draw icon and bold filename
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				pdc->DrawText(strLine, CRect(ptText.x  + iIconDrawingSpace, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight), m_dwCol1DrawTextFlags);
				if (pOldFont)
					pdc->SelectObject(pOldFont);

				ptText.y += iTextHeight;
				int iImage = theApp.GetFileTypeSystemImageIdx(strLine, -1, true);
				if (theApp.GetBigSystemImageList() != NULL)
					::ImageList_Draw(theApp.GetBigSystemImageList(), iImage, pdc->GetSafeHdc(), ptText.x, rcDT.top + ((iCaptionHeigth - iIconSize) / 2), ILD_NORMAL|ILD_TRANSPARENT);
			}
			else {
				if (strLine.Compare(_T("<br>")) == 0 || strLine.Compare(_T("<br_head>")) == 0){
					CPen pen;
					pen.CreatePen(0, 1, m_crTooltipTextColor);
					CPen *pOP = pdc->SelectObject(&pen);
					pdc->MoveTo(ptText.x, ptText.y + ((iTextHeight - 2) / 2)); 
					pdc->LineTo(ptText.x + iMaxSingleLineWidth, ptText.y + ((iTextHeight - 2) / 2));
					ptText.y += iTextHeight;
					pdc->SelectObject(pOP);
					pen.DeleteObject();
				}
				else{
					CSize siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, 0, NULL, 0);
					ptText.y += siz.cy;
				}
			}
		}
		if (pOldDCFont)
			pdc->SelectObject(pOldDCFont);
		*pResult = CDRF_SKIPDEFAULT;
		return;
	}
	*pResult = CDRF_DODEFAULT;
}
コード例 #8
0
ファイル: ED2KLink.cpp プロジェクト: tedlz123/EMule-GIFC
CED2KLink* CED2KLink::CreateLinkFromUrl(const TCHAR* uri)
{
    CString strURI(uri);
    strURI.Trim(); // This function is used for various sources, trim the string again.
    int iPos = 0;
    CString strTok = GetNextString(strURI, _T("|"), iPos);
    if (strTok.CompareNoCase(_T("ed2k://")) == 0)
    {
        strTok = GetNextString(strURI, _T("|"), iPos);
        if (strTok == _T("file"))
        {
            CString strName = GetNextString(strURI, _T("|"), iPos);
            if (!strName.IsEmpty())
            {
                CString strSize = GetNextString(strURI, _T("|"), iPos);
                if (!strSize.IsEmpty())
                {
                    CString strHash = GetNextString(strURI, _T("|"), iPos);
                    if (!strHash.IsEmpty())
                    {
                        CStringArray astrEd2kParams;
                        bool bEmuleExt = false;
                        CString strEmuleExt;

                        CString strLastTok;
                        strTok = GetNextString(strURI, _T("|"), iPos);
                        while (!strTok.IsEmpty())
                        {
                            strLastTok = strTok;
                            if (strTok == _T("/"))
                            {
                                if (bEmuleExt)
                                    break;
                                bEmuleExt = true;
                            }
                            else
                            {
                                if (bEmuleExt)
                                {
                                    if (!strEmuleExt.IsEmpty())
                                        strEmuleExt += _T('|');
                                    strEmuleExt += strTok;
                                }
                                else
                                    astrEd2kParams.Add(strTok);
                            }
                            strTok = GetNextString(strURI, _T("|"), iPos);
                        }

                        if (strLastTok == _T("/"))
                            return new CED2KFileLink(strName, strSize, strHash, astrEd2kParams, strEmuleExt.IsEmpty() ? (LPCTSTR)NULL : (LPCTSTR)strEmuleExt);
                    }
                }
            }
        }
        else if (strTok == _T("serverlist"))
        {
            CString strURL = GetNextString(strURI, _T("|"), iPos);
            if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                return new CED2KServerListLink(strURL);
        }
        else if (strTok == _T("server"))
        {
            CString strServer = GetNextString(strURI, _T("|"), iPos);
            if (!strServer.IsEmpty())
            {
                CString strPort = GetNextString(strURI, _T("|"), iPos);
                if (!strPort.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                    return new CED2KServerLink(strServer, strPort);
            }
        }
        else if (strTok == _T("nodeslist"))
        {
            CString strURL = GetNextString(strURI, _T("|"), iPos);
            if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                return new CED2KNodesListLink(strURL);
        }
        else if (strTok == _T("search"))
        {
            CString strSearchTerm = GetNextString(strURI, _T("|"), iPos);
            // might be extended with more parameters in future versions
            if (!strSearchTerm.IsEmpty())
                return new CED2KSearchLink(strSearchTerm);
        }
        // MORPH START - Added by Commander, Friendlinks [emulEspaa] - added by zz_fly
        else if ( strTok == _T("friend") )
        {
            CString sNick = GetNextString(strURI, _T("|"), iPos);
            if ( !sNick.IsEmpty() )
            {
                CString sHash = GetNextString(strURI, _T("|"), iPos);
                if ( !sHash.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                    return new CED2KFriendLink(sNick, sHash);
            }
        }
        else if ( strTok == _T("friendlist") )
        {
            CString sURL = GetNextString(strURI, _T("|"), iPos);
            if ( !sURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/") )
                return new CED2KFriendListLink(sURL);
        }
        // MORPH END - Added by Commander, Friendlinks [emulEspaa]
    }

    throw GetResString(IDS_ERR_NOSLLINK);
}
コード例 #9
0
ファイル: message.c プロジェクト: bowlofstew/ja2
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... )
{
  // this function sets up the string into several single line structures
	 
	ScrollStringStPtr pStringSt;
	UINT32 uiFont = MAP_SCREEN_MESSAGE_FONT;
	UINT16 usPosition=0;
	UINT16 usCount=0;
	UINT16 usStringLength=0;
	UINT16 usCurrentSPosition=0;
	UINT16 usCurrentLookup=0;
	//wchar_t *pString;
	BOOLEAN fLastLine=FALSE;
  va_list argptr;
  wchar_t	DestString[512], DestStringA[ 512 ];
	//wchar_t *pStringBuffer;
  BOOLEAN fMultiLine=FALSE;
  WRAPPED_STRING *pStringWrapper=NULL;
  WRAPPED_STRING *pStringWrapperHead=NULL;
  BOOLEAN fNewString = FALSE;
	UINT16	usLineWidthIfWordIsWiderThenWidth;

	if( fDisableJustForIan == TRUE )
	{
		if( ubPriority == MSG_BETAVERSION )
		{
			return;
		}
		else if( ubPriority == MSG_TESTVERSION )
		{
			return;
		}
		else if ( ubPriority == MSG_DEBUG )
		{
			return;
		}
	}

	if( ubPriority == MSG_BETAVERSION )
	{
		usColor = BETAVERSION_COLOR;
		#ifndef JA2BETAVERSION
			#ifndef JA2TESTVERSION
				return;
			#endif
		#endif

		WriteMessageToFile( DestString );
	}

	if( ubPriority == MSG_TESTVERSION )
	{
		usColor = TESTVERSION_COLOR;

		#ifndef JA2TESTVERSION
			 return;
		#endif
		WriteMessageToFile( DestString );
	}
	// OK, check if we are ani imeediate feedback message, if so, do something else!
	if ( ubPriority == MSG_UI_FEEDBACK )
	{
		va_start(argptr, pStringA);       	// Set up variable argument pointer
		vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
		va_end(argptr);

		BeginUIMessage( DestString );
		return;
	}

	if ( ubPriority == MSG_SKULL_UI_FEEDBACK )
	{
		va_start(argptr, pStringA);       	// Set up variable argument pointer
		vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
		va_end(argptr);

		InternalBeginUIMessage( TRUE, DestString );
		return;
	}

	// check if error
	if ( ubPriority == MSG_ERROR )
	{
		va_start(argptr, pStringA);       	// Set up variable argument pointer
		vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
		va_end(argptr);

		swprintf( DestStringA, L"DEBUG: %s", DestString );

		BeginUIMessage( DestStringA );
		WriteMessageToFile( DestStringA );

		return;
	}


		// OK, check if we are an immediate MAP feedback message, if so, do something else!
	if ( ( ubPriority == MSG_MAP_UI_POSITION_UPPER  ) ||
			 ( ubPriority == MSG_MAP_UI_POSITION_MIDDLE ) ||
			 ( ubPriority == MSG_MAP_UI_POSITION_LOWER  ) )
	{
		va_start(argptr, pStringA);       	// Set up variable argument pointer
		vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
		va_end(argptr);

		BeginMapUIMessage( ubPriority, DestString );
		return;
	}


	if ( fFirstTimeInMessageSystem )
	{
		// Init display array!
		memset( gpDisplayList, 0, sizeof( gpDisplayList ) );
		fFirstTimeInMessageSystem = FALSE;
		//if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" )))
		//	return;
	}

	
	pStringSt=pStringS;
	while(GetNextString(pStringSt))
		    pStringSt=GetNextString(pStringSt);

	va_start(argptr, pStringA);       	// Set up variable argument pointer
	vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
	va_end(argptr);

	if ( ubPriority == MSG_DEBUG )
	{
		#ifndef _DEBUG
			return;
		#endif
		#ifdef JA2DEMO
			return;
		#endif
		usColor = DEBUG_COLOR;
		wcscpy( DestStringA, DestString );
		swprintf( DestString, L"Debug: %s", DestStringA );
	}

	if ( ubPriority == MSG_DIALOG )
	{
		usColor = DIALOGUE_COLOR;
	}

	if ( ubPriority == MSG_INTERFACE )
	{
		usColor = INTERFACE_COLOR;
	}

	pStringWrapperHead=LineWrap(uiFont, MAP_LINE_WIDTH, &usLineWidthIfWordIsWiderThenWidth, DestString);
  pStringWrapper=pStringWrapperHead;
	if(!pStringWrapper)
    return;
	
	fNewString = TRUE;

	while(pStringWrapper->pNextWrappedString!=NULL)
	{
		AddStringToMapScreenMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority );
		fNewString = FALSE;

		pStringWrapper=pStringWrapper->pNextWrappedString;
	}

  AddStringToMapScreenMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority );


	// clear up list of wrapped strings
	ClearWrappedStrings( pStringWrapperHead );

	// play new message beep
	//PlayNewMessageSound( );

	MoveToEndOfMapScreenMessageList( );

	//LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__);
}
コード例 #10
0
ファイル: message.c プロジェクト: bowlofstew/ja2
// new tactical and mapscreen message system
void TacticalScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... )
{
  // this function sets up the string into several single line structures
	
	ScrollStringStPtr pStringSt;
	UINT32 uiFont = TINYFONT1;
	UINT16 usPosition=0;
	UINT16 usCount=0;
	UINT16 usStringLength=0;
	UINT16 usCurrentSPosition=0;
	UINT16 usCurrentLookup=0;
	//wchar_t *pString;
	BOOLEAN fLastLine=FALSE;
  va_list argptr;

  wchar_t	DestString[512], DestStringA[ 512 ];
	//wchar_t *pStringBuffer;
  BOOLEAN fMultiLine=FALSE;
  ScrollStringStPtr pTempStringSt=NULL;
  WRAPPED_STRING *pStringWrapper=NULL;
  WRAPPED_STRING *pStringWrapperHead=NULL;
  BOOLEAN fNewString = FALSE;
	UINT16	usLineWidthIfWordIsWiderThenWidth=0;


	if( giTimeCompressMode > TIME_COMPRESS_X1 )
	{
		return;
	}

	if( fDisableJustForIan == TRUE && ubPriority != MSG_ERROR && ubPriority != MSG_INTERFACE )
	{
		return;
	}

	if( ubPriority == MSG_BETAVERSION )
	{
		usColor = BETAVERSION_COLOR;
		#ifndef JA2BETAVERSION
			#ifndef JA2TESTVERSION
				return;
			#endif
		#endif
		WriteMessageToFile( DestString );

	}

	if( ubPriority == MSG_TESTVERSION )
	{
		usColor = TESTVERSION_COLOR;

		#ifndef JA2TESTVERSION
			 return;
		#endif

		WriteMessageToFile( DestString );

	}


	if ( fFirstTimeInMessageSystem )
	{
		// Init display array!
		memset( gpDisplayList, 0, sizeof( gpDisplayList ) );
		fFirstTimeInMessageSystem = FALSE;
		//if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" )))
		//	return;
	}

	
	pStringSt=pStringS;
	while(GetNextString(pStringSt))
		    pStringSt=GetNextString(pStringSt);

	va_start(argptr, pStringA);       	// Set up variable argument pointer
	vswprintf(DestString, pStringA, argptr);	// process gprintf string (get output str)
	va_end(argptr);

	if ( ubPriority == MSG_DEBUG )
	{
		#ifndef _DEBUG
			return;
		#endif
		#ifdef JA2DEMO
			return;
		#endif
		usColor = DEBUG_COLOR;
		wcscpy( DestStringA, DestString );
		swprintf( DestString, L"Debug: %s", DestStringA );
		WriteMessageToFile( DestStringA );
	}

	if ( ubPriority == MSG_DIALOG )
	{
		usColor = DIALOGUE_COLOR;
	}

	if ( ubPriority == MSG_INTERFACE )
	{
		usColor = INTERFACE_COLOR;
	}



	pStringWrapperHead=LineWrap(uiFont, LINE_WIDTH, &usLineWidthIfWordIsWiderThenWidth, DestString);
  pStringWrapper=pStringWrapperHead;
	if(!pStringWrapper)
    return;
	
	fNewString = TRUE;
	while(pStringWrapper->pNextWrappedString!=NULL)
	{
	 if(!pStringSt)
	 {
    pStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority );
		fNewString = FALSE;
		pStringSt->pNext=NULL;
		pStringSt->pPrev=NULL;
    pStringS=pStringSt;
	 }
	 else
	 {
	  pTempStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority);
    fNewString = FALSE;
		pTempStringSt->pPrev=pStringSt;
	  pStringSt->pNext=pTempStringSt;
	  pStringSt=pTempStringSt;
	  pTempStringSt->pNext=NULL;
	 }
   pStringWrapper=pStringWrapper->pNextWrappedString;
	}
  pTempStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority );
	if(pStringSt)
	{
	 pStringSt->pNext=pTempStringSt;
	 pTempStringSt->pPrev=pStringSt;
	 pStringSt=pTempStringSt;
	 pStringSt->pNext=NULL;
	}
  else
	{
		pStringSt=pTempStringSt;
		pStringSt->pNext=NULL;
		pStringSt->pPrev=NULL;
    pStringS=pStringSt;
	}
	
	// clear up list of wrapped strings
	ClearWrappedStrings( pStringWrapperHead );

 //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__);
 return;
} 
コード例 #11
0
ファイル: AddSourceDlg.cpp プロジェクト: LjApps/eMule-VeryCD
void CAddSourceDlg::OnBnClickedButton1()
{
	if (!m_pFile)
		return;

	switch (m_nSourceType)
	{
		case 0:
		{
			CString sip;
			GetDlgItem(IDC_EDIT2)->GetWindowText(sip);
			if (sip.IsEmpty())
				return;

			// if the port is specified with the IP, ignore any possible specified port in the port control
			uint16 port;
			int iColon = sip.Find(_T(':'));
			if (iColon != -1) {
				port = (uint16)_tstoi(sip.Mid(iColon + 1));
				sip = sip.Left(iColon);
			}
			else {
				BOOL bTranslated = FALSE;
				port = (uint16)GetDlgItemInt(IDC_EDIT3, &bTranslated, FALSE);
				if (!bTranslated)
					return;
			}

			uint32 ip;
			if ((ip = inet_addr(CT2CA(sip))) == INADDR_NONE && _tcscmp(sip, _T("255.255.255.255")) != 0)
				ip = 0;
			if (IsGoodIPPort(ip, port))
			{
				CUpDownClient* toadd = new CUpDownClient(m_pFile, port, ntohl(ip), 0, 0);
				toadd->SetSourceFrom(SF_PASSIVE);
				theApp.downloadqueue->CheckAndAddSource(m_pFile, toadd);
			}
			break;
		}
		case 1:
		{
			CString strURL;
			GetDlgItem(IDC_EDIT10)->GetWindowText(strURL);

			if( strURL.Find( _T("peer://|") )!=-1 )
			{				
				int iPos = 0;
				uint32 buddyIP,peerIP;
				uint16 buddyPort,peerKadPort;
				BYTE cBuddyID[16];
				BYTE cUserHash[16];
				memset(cBuddyID,0,16);
				memset(cUserHash,0,16);
				CString sBuddyID,sBuddyIP,sBuddyPort,sUserHash,sPeerIP,sPeerKadPort;

				CString strTok = GetNextString(strURL, _T("|"), iPos);
				if (strTok == _T("peer://"))
				{
					sBuddyID = GetNextString(strURL, _T("|"), iPos);
					sBuddyIP = GetNextString(strURL, _T("|"), iPos);
					sBuddyPort = GetNextString(strURL, _T("|"), iPos);
					sUserHash = GetNextString(strURL, _T("|"), iPos);
					sPeerIP = GetNextString(strURL, _T("|"), iPos);
					sPeerKadPort = GetNextString(strURL, _T("|"), iPos);
				}
				LPCTSTR pszBuddyID = (LPCTSTR)sBuddyID;
				if( sBuddyID!=_T("0") )
				{
					for (int idx = 0; idx < 16; ++idx) 
					{
						cBuddyID[idx] = (BYTE)(FromHexDigit(*pszBuddyID++)*16);
						cBuddyID[idx] = (BYTE)(cBuddyID[idx] + FromHexDigit(*pszBuddyID++));
					}
				}				
				LPCTSTR pszUserHash = (LPCTSTR)sUserHash;
				if(sUserHash!=_T("0"))
				for (int idx = 0; idx < 16; ++idx) 
				{
					cUserHash[idx] = (BYTE)(FromHexDigit(*pszUserHash++)*16);
					cUserHash[idx] = (BYTE)(cUserHash[idx] + FromHexDigit(*pszUserHash++));
				}
				buddyIP = inet_addr( CStringA(sBuddyIP) );
				unsigned long ul;
				ul = _tcstoul( sBuddyPort, 0, 10 );
				buddyPort = static_cast<uint16>(ul);
				peerIP = inet_addr( CStringA(sPeerIP) );
				peerKadPort = static_cast<uint16>(ul);

				CUpDownClient* toadd = new CUpDownClient(m_pFile,-1,1,0,0,false);//tcp(-1) 表示默认支持 Nat Trans										
				toadd->SetSourceFrom(SF_KADEMLIA);				
				toadd->SetBuddyID(cBuddyID);
				toadd->SetBuddyIP(buddyIP);
				toadd->SetBuddyPort(buddyPort);	
				toadd->SetUserHash(cUserHash);
				toadd->SetIP(peerIP);
				toadd->SetKadPort(peerKadPort);	
				theApp.downloadqueue->CheckAndAddSource(m_pFile, toadd);
			}
			else if (!strURL.IsEmpty())
			{
				TCHAR szScheme[INTERNET_MAX_SCHEME_LENGTH];
				TCHAR szHostName[INTERNET_MAX_HOST_NAME_LENGTH];
				TCHAR szUrlPath[INTERNET_MAX_PATH_LENGTH];
				TCHAR szUserName[INTERNET_MAX_USER_NAME_LENGTH];
				TCHAR szPassword[INTERNET_MAX_PASSWORD_LENGTH];
				TCHAR szExtraInfo[INTERNET_MAX_URL_LENGTH];
				URL_COMPONENTS Url = {0};
				Url.dwStructSize = sizeof(Url);
				Url.lpszScheme = szScheme;
				Url.dwSchemeLength = ARRSIZE(szScheme);
				Url.lpszHostName = szHostName;
				Url.dwHostNameLength = ARRSIZE(szHostName);
				Url.lpszUserName = szUserName;
				Url.dwUserNameLength = ARRSIZE(szUserName);
				Url.lpszPassword = szPassword;
				Url.dwPasswordLength = ARRSIZE(szPassword);
				Url.lpszUrlPath = szUrlPath;
				Url.dwUrlPathLength = ARRSIZE(szUrlPath);
				Url.lpszExtraInfo = szExtraInfo;
				Url.dwExtraInfoLength = ARRSIZE(szExtraInfo);
				if (InternetCrackUrl(strURL, 0, 0, &Url) && Url.dwHostNameLength > 0 && Url.dwHostNameLength < INTERNET_MAX_HOST_NAME_LENGTH)
				{
					SUnresolvedHostname* hostname = new SUnresolvedHostname;
					hostname->strURL = strURL;
					hostname->strHostname = szHostName;
					theApp.downloadqueue->AddToResolved(m_pFile, hostname);
					delete hostname;
				}
			}
			break;
		}
	}
}
コード例 #12
0
void CToolTipCtrlX::CustomPaint(LPNMTTCUSTOMDRAW pNMCD)
{
	CWnd* pwnd = CWnd::FromHandle(pNMCD->nmcd.hdr.hwndFrom);
	CDC* pdc = CDC::FromHandle(pNMCD->nmcd.hdc);

	// Windows Vista (General)
	// -----------------------
	// *Need* to use (some aspects) of the 'TOOLTIP' theme to get typical Vista tooltips.
	//
	// Windows Vista *without* SP1
	// ---------------------------
	// The Vista 'TOOLTIP' theme offers a bold version of the standard tooltip font via 
	// the TTP_STANDARDTITLE part id. Furthermore TTP_STANDARDTITLE is the same font as
	// the standard tooltip font (TTP_STANDARD). So, the 'TOOLTIP' theme can get used
	// thoroughly.
	//
	// Windows Vista *with* SP1
	// ------------------------
	// The Vista SP1(!) 'TOOLTIP' theme does though *not* offer a bold font. Keep
	// in mind that TTP_STANDARDTITLE does not return a bold font. Keep also in mind
	// that TTP_STANDARDTITLE is even a *different* font than TTP_STANDARD!
	// Which means, that TTP_STANDARDTITLE should *not* be used within the same line
	// as TTP_STANDARD. It just looks weird. TTP_STANDARDTITLE could be used for a
	// single line (the title line), but it would though not give us a bold font.
	// So, actually we can use the Vista 'TOOLTIP' theme only for getting the proper
	// tooltip background.
	//
	// Windows XP
	// ----------
	// Can *not* use the 'TOOLTIP' theme at all because it would give us only a (non-bold)
	// black font on a white tooltip window background. Seems that the 'TOOLTIP' theme under 
	// WinXP is just using the default Window values (black+white) and does not
	// use any of the tooltip specific Window metrics...
	//
	bool bUseEmbeddedThemeFonts = false;
	HTHEME hTheme = NULL;
	if (theApp.IsVistaThemeActive()) {
		hTheme = OpenThemeData(*pwnd, L"TOOLTIP");
		// Using the theme's fonts works only under Vista without SP1. When SP1
		// is installed the fonts which are used for TTP_STANDARDTITLE and TTP_STANDARD
		// do no longer match (should not get displayed within the same text line).
		if (hTheme) bUseEmbeddedThemeFonts = true;
	}

	CString strText;
	pwnd->GetWindowText(strText);

	CRect rcWnd;
	pwnd->GetWindowRect(&rcWnd);

	CFont* pOldDCFont = NULL;
	if (hTheme == NULL || !bUseEmbeddedThemeFonts)
	{
		// If we have a theme, we try to query the correct fonts from it
		if (m_fontNormal.m_hObject == NULL && hTheme) {
			// Windows Vista Ultimate, 6.0.6001 SP1 Build 6001, English with German Language Pack
			// ----------------------------------------------------------------------------------
			// TTP_STANDARD, TTSS_NORMAL
			//  Height   -12
			//  Weight   400
			//  CharSet  1
			//  Quality  5
			//  FaceName "Segoe UI"
			//
			// TTP_STANDARDTITLE, TTSS_NORMAL
			//  Height   -12
			//  Weight   400
			//  CharSet  1
			//  Quality  5
			//  FaceName "Segoe UI Fett" (!!!) Note: "Fett" (that is German !?)
			//
			// That font name ("Segoe UI *Fett*") looks quite suspicious. I would not be surprised
			// if that eventually leads to a problem within the font mapper which may not be capable
			// of finding the (english) version of that font and thus falls back to the standard
			// system font. At least this would explain why the TTP_STANDARD and TTP_STANDARDTITLE
			// fonts are *different* on that particular Windows Vista system.
			LOGFONT lf = {0};
			if (GetThemeFont(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, TMT_FONT, &lf) == S_OK) {
				VERIFY( m_fontNormal.CreateFontIndirect(&lf) );

				if (m_bCol1Bold && m_fontBold.m_hObject == NULL) {
					memset(&lf, 0, sizeof(lf));
					if (GetThemeFont(hTheme, pdc->m_hDC, TTP_STANDARDTITLE, TTSS_NORMAL, TMT_FONT, &lf) == S_OK)
						VERIFY( m_fontBold.CreateFontIndirect(&lf) );
				}

				// Get the tooltip font color
				COLORREF crText;
				if (GetThemeColor(hTheme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &crText) == S_OK)
					m_crTooltipTextColor = crText;
			}
		}

		// If needed, create the standard tooltip font which was queried from the system metrics
		if (m_fontNormal.m_hObject == NULL && m_lfNormal.lfHeight != 0)
			VERIFY( m_fontNormal.CreateFontIndirect(&m_lfNormal) );

		// Select the tooltip font
		if (m_fontNormal.m_hObject != NULL) {
			pOldDCFont = pdc->SelectObject(&m_fontNormal);

			// If needed, create the bold version of the tooltip font by deriving it from the standard font
			if (m_bCol1Bold && m_fontBold.m_hObject == NULL) {
				LOGFONT lf;
				m_fontNormal.GetLogFont(&lf);
				lf.lfWeight = FW_BOLD;
				VERIFY( m_fontBold.CreateFontIndirect(&lf) );
			}
		}

		// Set the font color (queried from system metrics or queried from theme)
		pdc->SetTextColor(m_crTooltipTextColor);
	}

	// Auto-format the text only if explicitly requested. Otherwise we would also format
	// single line tooltips for regular list items, and if those list items contain ':'
	// characters they would be shown partially in bold. For performance reasons, the
	// auto-format is to be requested by appending the TOOLTIP_AUTOFORMAT_SUFFIX_CH 
	// character. Appending, because we can remove that character efficiently without
	// re-allocating the entire string.
	bool bAutoFormatText = strText.GetLength() > 0 && strText[strText.GetLength() - 1] == TOOLTIP_AUTOFORMAT_SUFFIX_CH;
	if (bAutoFormatText)
		strText.Truncate(strText.GetLength() - 1); // truncate the TOOLTIP_AUTOFORMAT_SUFFIX_CH char by setting it to NUL
	bool bShowFileIcon = m_bShowFileIcon && bAutoFormatText;
	if (bShowFileIcon) {
		int iPosNL = strText.Find(_T('\n'));
		if (iPosNL > 0) {
			int iPosColon = strText.Find(_T(':'));
			if (iPosColon < iPosNL)
				bShowFileIcon = false; // 1st line does not contain a filename
		}
	}
	
	int iTextHeight = 0;
	int iMaxCol1Width = 0;
	int iMaxCol2Width = 0;
	int iMaxSingleLineWidth = 0;
	CSize sizText(0);
	int iPos = 0;
	int iCaptionHeight = 0;
	const int iCaptionEnd = bShowFileIcon ? max(strText.Find(_T("\n<br_head>\n")), 0) : 0; // special tooltip with file icon
	const int iLineHeightOff = 1;
	const int iIconMinYBorder = bShowFileIcon ? 3 : 0;
	const int iIconWidth = bShowFileIcon ? theApp.GetBigSytemIconSize().cx : 0;
	const int iIconHeight = bShowFileIcon ? theApp.GetBigSytemIconSize().cy : 0;
	const int iIconDrawingWidth = bShowFileIcon ? (iIconWidth + 9) : 0;
	while (iPos != -1)
	{
		CString strLine = GetNextString(strText, _T('\n'), iPos);
		int iColon = bAutoFormatText ? strLine.Find(_T(':')) : -1;
		if (iColon != -1) {
			CSize siz;
			if (hTheme && bUseEmbeddedThemeFonts) {
				CRect rcExtent;
				CRect rcBounding(0, 0, 32767, 32767);
				GetThemeTextExtent(hTheme, *pdc, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, iColon + 1, m_dwCol1DrawTextFlags, &rcBounding, &rcExtent);
				siz.cx = rcExtent.Width();
				siz.cy = rcExtent.Height();
			}
			else {
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				siz = pdc->GetTextExtent(strLine, iColon + 1);
				if (pOldFont)
					pdc->SelectObject(pOldFont);
			}
			iMaxCol1Width = max<int>(iMaxCol1Width, siz.cx + ((bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength()) ? iIconDrawingWidth : 0));
			iTextHeight = siz.cy + iLineHeightOff; // update height with 'col1' string, because 'col2' string might be empty and therefore has no height
			if (iPos <= iCaptionEnd)
				iCaptionHeight += siz.cy + iLineHeightOff;
			else
				sizText.cy += siz.cy + iLineHeightOff;

			LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
			while (_istspace((_TUCHAR)*pszCol2))
				pszCol2++;
			if (*pszCol2 != _T('\0')) {
				if (hTheme && bUseEmbeddedThemeFonts) {
					CRect rcExtent;
					CRect rcBounding(0, 0, 32767, 32767);
					GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, m_dwCol2DrawTextFlags, &rcBounding, &rcExtent);
					siz.cx = rcExtent.Width();
					siz.cy = rcExtent.Height();
				}
				else {
					siz = pdc->GetTextExtent(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2);
				}
				iMaxCol2Width = max<int>(iMaxCol2Width, siz.cx);
			}
		}
		else if (bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){
			// file name, printed bold on top without any tabbing or desc
			CSize siz;
			if (hTheme && bUseEmbeddedThemeFonts) {
				CRect rcExtent;
				CRect rcBounding(0, 0, 32767, 32767);
				GetThemeTextExtent(hTheme, *pdc, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, &rcBounding, &rcExtent);
				siz.cx = rcExtent.Width();
				siz.cy = rcExtent.Height();
			}
			else {
				CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
				siz = pdc->GetTextExtent(strLine);
				if (pOldFont)
					pdc->SelectObject(pOldFont);
			}
			iMaxSingleLineWidth = max<int>(iMaxSingleLineWidth, siz.cx + iIconDrawingWidth);
			iCaptionHeight += siz.cy + iLineHeightOff;
		}
		else if (!strLine.IsEmpty() && strLine.Compare(_T("<br>")) != 0 && strLine.Compare(_T("<br_head>")) != 0) {
			CSize siz;
			if (hTheme && bUseEmbeddedThemeFonts) {
				CRect rcExtent;
				CRect rcBounding(0, 0, 32767, 32767);
				GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol2DrawTextFlags, &rcBounding, &rcExtent);
				siz.cx = rcExtent.Width();
				siz.cy = rcExtent.Height();
			}
			else {
				siz = pdc->GetTextExtent(strLine);
			}
			iMaxSingleLineWidth = max<int>(iMaxSingleLineWidth, siz.cx + ((bShowFileIcon && iPos <= iCaptionEnd) ? iIconDrawingWidth : 0));
			if (bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength())
				iCaptionHeight += siz.cy + iLineHeightOff;
			else
				sizText.cy += siz.cy + iLineHeightOff;
		}
		else{
			CSize siz;
			if (hTheme && bUseEmbeddedThemeFonts) {
				CRect rcExtent;
				CRect rcBounding(0, 0, 32767, 32767);
				GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, _T(" "), 1, m_dwCol2DrawTextFlags, &rcBounding, &rcExtent);
				siz.cx = rcExtent.Width();
				siz.cy = rcExtent.Height();
			}
			else {
				// TODO: Would need to use 'GetTabbedTextExtent' here, but do we actually use 'tabbed' text here at all ??
				siz = pdc->GetTextExtent(_T(" "), 1);
			}
			sizText.cy += siz.cy + iLineHeightOff;
		}
	}
	if (bShowFileIcon && iCaptionEnd > 0)
		iCaptionHeight = max<int>(iCaptionHeight, theApp.GetBigSytemIconSize().cy + (2*iIconMinYBorder));
	sizText.cy += iCaptionHeight;
	if (hTheme && theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6,16,0,0))
		sizText.cy += 2; // extra bottom margin for Vista/Theme

	iMaxCol1Width = min(m_iScreenWidth4, iMaxCol1Width);
	iMaxCol2Width = min(m_iScreenWidth4*2, iMaxCol2Width);

	const int iMiddleMargin = 6;
	iMaxSingleLineWidth = max(iMaxSingleLineWidth, iMaxCol1Width + iMiddleMargin + iMaxCol2Width);
	if (iMaxSingleLineWidth > m_iScreenWidth4*3)
		iMaxSingleLineWidth = m_iScreenWidth4*3;
	sizText.cx = iMaxSingleLineWidth;

	if (pNMCD->uDrawFlags & DT_CALCRECT)
	{
		pNMCD->nmcd.rc.left = rcWnd.left;
		pNMCD->nmcd.rc.top = rcWnd.top;
		pNMCD->nmcd.rc.right = rcWnd.left + sizText.cx;
		pNMCD->nmcd.rc.bottom = rcWnd.top + sizText.cy;
	}
	else
	{
		pwnd->ScreenToClient(&rcWnd);

		int iOldBkColor = -1;
		if (hTheme) {
			int iPartId = TTP_STANDARD;
			int iStateId = TTSS_NORMAL;
			if (IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
				DrawThemeParentBackground(m_hWnd, pdc->m_hDC, &rcWnd);
			DrawThemeBackground(hTheme, pdc->m_hDC, iPartId, iStateId, &rcWnd, NULL);
		}
		else {
			::FillRect(*pdc, &rcWnd, GetSysColorBrush(COLOR_INFOBK));
			iOldBkColor = pdc->SetBkColor(m_crTooltipBkColor);
			// Vista: Need to draw the window border explicitly !?
			if (theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6,16,0,0)) {
				CPen pen;
				pen.CreatePen(0, 1, m_crTooltipTextColor);
				CPen *pOP = pdc->SelectObject(&pen);
				pdc->MoveTo(rcWnd.left, rcWnd.top);
				pdc->LineTo(rcWnd.right - 1, rcWnd.top);
				pdc->LineTo(rcWnd.right - 1, rcWnd.bottom - 1);
				pdc->LineTo(rcWnd.left, rcWnd.bottom - 1);
				pdc->LineTo(rcWnd.left, rcWnd.top);
				pdc->SelectObject(pOP);
				pen.DeleteObject();
			}
		}

		int iOldBkMode = 0;
		if ((hTheme && !bUseEmbeddedThemeFonts) || (hTheme == NULL && iOldBkColor != -1))
			iOldBkMode = pdc->SetBkMode(TRANSPARENT);

		CPoint ptText(pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top);
		iPos = 0;
		while (iPos != -1)
		{
			CString strLine = GetNextString(strText, _T('\n'), iPos);
			int iColon = bAutoFormatText ? strLine.Find(_T(':')) : -1;
			CRect rcDT;
			if (!bShowFileIcon || (unsigned)iPos > (unsigned)iCaptionEnd + strLine.GetLength())
				rcDT.SetRect(ptText.x, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight);
			else
				rcDT.SetRect(ptText.x + iIconDrawingWidth, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight);
			if (iColon != -1) {
				// don't draw empty <col1> strings (they are still handy to use for skipping the <col1> space)
				if (iColon > 0) {
					if (hTheme && bUseEmbeddedThemeFonts)
						DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, iColon + 1, m_dwCol1DrawTextFlags, 0, &rcDT);
					else {
						CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
						pdc->DrawText(strLine, iColon + 1, &rcDT, m_dwCol1DrawTextFlags);
						if (pOldFont)
							pdc->SelectObject(pOldFont);
					}
				}

				LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1;
				while (_istspace((_TUCHAR)*pszCol2))
					pszCol2++;
				if (*pszCol2 != _T('\0')) {
					rcDT.left = ptText.x + iMaxCol1Width + iMiddleMargin;
					rcDT.right = rcDT.left + iMaxCol2Width;
					if (hTheme && bUseEmbeddedThemeFonts)
						DrawThemeText(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, m_dwCol2DrawTextFlags, 0, &rcDT);
					else
						pdc->DrawText(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, &rcDT, m_dwCol2DrawTextFlags);
				}

				ptText.y += iTextHeight;
			}
			else if (bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){
				// first line on special fileicon tab - draw icon and bold filename
				if (hTheme && bUseEmbeddedThemeFonts)
					DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, 0, &CRect(ptText.x  + iIconDrawingWidth, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight));
				else {
					CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
					pdc->DrawText(strLine, CRect(ptText.x  + iIconDrawingWidth, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight), m_dwCol1DrawTextFlags);
					if (pOldFont)
						pdc->SelectObject(pOldFont);
				}

				ptText.y += iTextHeight;
				int iImage = (int) theApp.GetFileTypeSystemImageIdx(strLine, -1, true);
				if (theApp.GetBigSystemImageList() != NULL) {
					int iPosY = rcDT.top;
					if (iCaptionHeight > iIconHeight)
						iPosY += (iCaptionHeight - iIconHeight) / 2;
					::ImageList_Draw(theApp.GetBigSystemImageList(), iImage, pdc->GetSafeHdc(), ptText.x, iPosY, ILD_TRANSPARENT);
				}
			}
			else {
				bool bIsBrHeadLine = false;
				if (bAutoFormatText && (strLine.Compare(_T("<br>")) == 0 || (bIsBrHeadLine = strLine.Compare(_T("<br_head>")) == 0) == true)){
					CPen pen;
					pen.CreatePen(0, 1, m_crTooltipTextColor);
					CPen *pOP = pdc->SelectObject(&pen);
					if (bIsBrHeadLine)
						ptText.y = iCaptionHeight;
					pdc->MoveTo(ptText.x, ptText.y + ((iTextHeight - 2) / 2)); 
					pdc->LineTo(ptText.x + iMaxSingleLineWidth, ptText.y + ((iTextHeight - 2) / 2));
					ptText.y += iTextHeight;
					pdc->SelectObject(pOP);
					pen.DeleteObject();
				}
				else{
					if (hTheme && bUseEmbeddedThemeFonts) {
						CRect rcLine(ptText.x, ptText.y, 32767, 32767);
						DrawThemeText(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), DT_EXPANDTABS | m_dwCol2DrawTextFlags, 0, &rcLine);
						ptText.y += iTextHeight;
					}
					else {
						// Text is written in the currently selected font. If 'nTabPositions' is 0 and 'lpnTabStopPositions' is NULL,
						// tabs are expanded to eight times the average character width.
						CSize siz;
						if (strLine.IsEmpty()) // Win98: To draw an empty line we need to output at least a space.
							siz = pdc->TabbedTextOut(ptText.x, ptText.y, _T(" "), 1, NULL, 0);
						else
							siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, strLine.GetLength(), NULL, 0);
						ptText.y += siz.cy + iLineHeightOff;
					}
				}
			}
		}
		if (iOldBkColor != -1)
			pdc->SetBkColor(iOldBkColor);
		if (hTheme && !bUseEmbeddedThemeFonts)
			pdc->SetBkMode(iOldBkMode);
	}
	if (pOldDCFont)
		pdc->SelectObject(pOldDCFont);
	if (hTheme)
		CloseThemeData(hTheme);
}