當前位置: 首頁>>代碼示例>>C++>>正文


C++ XString::Replace方法代碼示例

本文整理匯總了C++中XString::Replace方法的典型用法代碼示例。如果您正苦於以下問題:C++ XString::Replace方法的具體用法?C++ XString::Replace怎麽用?C++ XString::Replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XString的用法示例。


在下文中一共展示了XString::Replace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: PaintMe

void PaintMe(HWND hwnd)
{
	HDC hDC;
	PAINTSTRUCT ps;
	RECT rcWindow;
	HFONT hSysFont, hFont, hFontOld;
	LOGFONT lfFont;
	COLORREF crText;
	TCHAR szTextBuffer[50], szTextBuffer2[50], szInternetTime[5];
	XString xsTextBuffer;
	int iFontSizePixel;
	
	GetWindowRect(hwnd, &rcWindow);
	OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);

	hDC = BeginPaint(hwnd, &ps);
	SetBkMode(hDC, TRANSPARENT);

	if (bSelected == TRUE) {
		HBRUSH hBrush = GetSysColorBrush(COLOR_HIGHLIGHT);

		FillRect(hDC, &rcWindow, hBrush);

		DeleteObject(hBrush);
	}

	if (g_iTextSize == 0)
	{
		SHGetUIMetrics(SHUIM_FONTSIZE_PIXEL, &iFontSizePixel, sizeof(iFontSizePixel), NULL);
	}
	else
	{
		iFontSizePixel = MulDiv(g_iTextSize + MIN_FONT_SIZE - 1, DRA::LogPixelsY(), 72);
	}

	hSysFont = (HFONT) GetStockObject(SYSTEM_FONT);
	GetObject(hSysFont, sizeof(LOGFONT), &lfFont);
	//memset(&lfFont, 0, sizeof(LOGFONT));
	lfFont.lfWeight = FW_SEMIBOLD;
	lfFont.lfHeight = -iFontSizePixel;
	hFont = CreateFontIndirect(&lfFont);
	hFontOld = (HFONT) SelectObject(hDC, hFont);

	crText = SendMessage(GetParent(hwnd), TODAYM_GETCOLOR, (WPARAM) TODAYCOLOR_TEXT, NULL);
	SetTextColor(hDC, crText);

	InflateRect(&rcWindow, -2, 0);

	_itot(g_iInternetTime, szInternetTime, 10);
	//_ttoi

	_tcscpy(szTextBuffer, _T("a\0"));
	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, g_xsLeftFormat.Replace(_T("'"), _T("'''")).GetBuffer(), szTextBuffer, sizeof szTextBuffer);
	GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, szTextBuffer, szTextBuffer2, sizeof szTextBuffer2);
	xsTextBuffer = XString(szTextBuffer2).Replace(_T("@"), XString(_T("@"), szInternetTime));
	DrawText(hDC, xsTextBuffer.GetBuffer(), -1, &rcWindow, DT_VCENTER | DT_LEFT);

	_tcscpy(szTextBuffer, _T("a\0"));
	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, g_xsRightFormat.Replace(_T("'"), _T("'''")).GetBuffer(), szTextBuffer, sizeof szTextBuffer);
	GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, szTextBuffer, szTextBuffer2, sizeof szTextBuffer2);
	xsTextBuffer = XString(szTextBuffer2).Replace(_T("@"), XString(_T("@"), szInternetTime));
	DrawText(hDC, xsTextBuffer.GetBuffer(), -1, &rcWindow, DT_VCENTER | DT_RIGHT);

	SelectObject(hDC, hFontOld);
	DeleteObject(hFont);

	EndPaint(hwnd, &ps);
}
開發者ID:PedroLamas,項目名稱:TodayTime,代碼行數:68,代碼來源:TodayTime.cpp


注:本文中的XString::Replace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。