这篇教程C++ DrawTextW函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DrawTextW函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawTextW函数的具体用法?C++ DrawTextW怎么用?C++ DrawTextW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DrawTextW函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ex_trace_scrnvoid ex_trace_scrn(int x, int y, char* _msg){#ifdef _WIN32 HDC hDC = GetDC(NULL); RECT rtScreen; SetRectEmpty(&rtScreen); SetTextColor(hDC, 0x00ff0000); SetBkColor(hDC, 0x00FF00FF); #if defined(UNICODE) || defined(_UNICODE) wchar_t uni_msg[128]; memset(uni_msg, 0, sizeof(uni_msg)); ex_char2uni(_msg, uni_msg, Ex_MIDOF(uni_msg) ); DrawTextW(hDC, uni_msg, wcslen(uni_msg) , &rtScreen, DT_CALCRECT ); OffsetRect(&rtScreen, x, y ); DrawTextW(hDC, uni_msg, wcslen(uni_msg) , &rtScreen, DT_LEFT|DT_TOP ); #else DrawTextA(hDC, _msg, strlen(_msg) , &rtScreen, DT_CALCRECT ); OffsetRect(&rtScreen, x, y ); DrawTextA(hDC, _msg, strlen(_msg) , &rtScreen, DT_LEFT|DT_TOP ); #endif ReleaseDC(NULL, hDC);#endif}
开发者ID:gaojihao,项目名称:7520Inspru,代码行数:29,
示例2: DrawFrame// *********************************************************************// DrawLabel() // *********************************************************************void GdiLabelDrawer::DrawLabel(CLabelOptions* options, CLabelInfo* lbl, CRect& rect, double angleRad, double piX, double piY){ // ------------------------------------------------------ // GDI drawing w/o transparency, gradients, etc // ------------------------------------------------------ XFORM xForm; xForm.eM11 = (FLOAT)cos(angleRad); xForm.eM12 = (FLOAT)sin(angleRad); xForm.eM21 = (FLOAT)-sin(angleRad); xForm.eM22 = (FLOAT)cos(angleRad); xForm.eDx = (FLOAT)piX; xForm.eDy = (FLOAT)piY; _dc->SetWorldTransform(&xForm); CPen* oldPen = NULL; // drawing frame if (options->frameVisible) { oldPen = _dc->SelectObject(&_penFrameOutline); DrawFrame(&rect, options); _dc->SelectObject(oldPen); } // drawing outlines if (options->shadowVisible) { _dc->SetWindowOrg(-options->shadowOffsetX, -options->shadowOffsetY); _dc->SetTextColor(options->shadowColor); DrawTextW(_dc->m_hDC, lbl->text, -1, rect, _alignment); _dc->SetTextColor(options->fontColor); _dc->SetWindowOrg(0, 0); } if (options->haloVisible) { _dc->BeginPath(); DrawTextW(_dc->m_hDC, lbl->text, -1, rect, _alignment); _dc->EndPath(); oldPen = _dc->SelectObject(&_penHalo); _dc->StrokePath(); _dc->SelectObject(oldPen); } if (options->fontOutlineVisible) { _dc->BeginPath(); DrawTextW(_dc->m_hDC, lbl->text, -1, rect, _alignment); _dc->EndPath(); oldPen = _dc->SelectObject(&_penFontOutline); _dc->StrokePath(); _dc->SelectObject(oldPen); } DrawTextW(_dc->m_hDC, lbl->text, -1, rect, _alignment);}
开发者ID:liuzhumei,项目名称:MapWinGIS,代码行数:59,
示例3: DrawTextUWstatic WINUSERAPI int WINAPI DrawTextUW(HDC hDC, LPCSTR lpchText, int nCount, LPRECT lpRect, UINT uFormat){ if (!lpchText) { // String not specified. Don't bother converting anything. return DrawTextW(hDC, (LPCWSTR)lpchText, nCount, lpRect, uFormat); } // Convert lpchText from UTF-8 to UTF-16. wchar_t *lpchwText = w32u_UTF8toUTF16(lpchText); int ret = DrawTextW(hDC, lpchwText, nCount, lpRect, uFormat); free(lpchwText); return ret;}
开发者ID:PhilrocWP,项目名称:gens,代码行数:14,
示例4: LLabel_OnPaintstatic void LLabel_OnPaint(HWND hwnd){ PAINTSTRUCT ps; RECT rc; int state; HFONT hFont; int style = DT_SINGLELINE | DT_VCENTER; BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); state = SaveDC(ps.hdc); SetBkMode(ps.hdc, TRANSPARENT); hFont = CreateFontIndirectW((LPLOGFONTW)GetWindowLongPtrW(hwnd, 4)); SelectFont(ps.hdc, hFont); SetTextColor(ps.hdc, RGB(0, 0, 255)); if(IsWindowUnicode(hwnd)){ if(GetPropW(hwnd, LL_ALIGNW)) style |= DT_RIGHT; else style |= DT_LEFT; DrawTextW(ps.hdc, (wchar_t *)GetWindowLongPtrW(hwnd, 0), -1, &rc, style); } else{ if(GetProp(hwnd, LL_ALIGN)) style |= DT_RIGHT; else style |= DT_LEFT; DrawText(ps.hdc, (char *)GetWindowLongPtr(hwnd, 0), -1, &rc, style); } RestoreDC(ps.hdc, state); DeleteFont(hFont); EndPaint(hwnd, &ps);}
开发者ID:mju-oss-13-a,项目名称:team5-NoteMaster,代码行数:33,
示例5: DrawTextWvoid Lexem::calc(HDC hdc, double multiplier){ if (width * height == 0) { HFONT hf = winWrap::setFont(hdc, FONT_SIZE * multiplier); RECT r; DrawTextW(hdc, name.data(), name.length(), &r, DT_CALCRECT); width = r.right - r.left; height = r.bottom - r.top; DeleteObject(hf); int scr_w = 0, h = 0; if (supscript != NULL) { supscript->calc(hdc, multiplier * SCRIPT_SIZE); scr_w = supscript->getWidth(); h = height / 2; } if (subscript != NULL) { subscript->calc(hdc, multiplier * SCRIPT_SIZE); scr_w = max(scr_w, subscript->getWidth()); h += height / 2; } width += scr_w; height += getSubScriptHeight() + getSuperScriptHeight() - h; }}
开发者ID:teutonos,项目名称:TEX-with-BlackJack,代码行数:29,
示例6: dialog_paint_motdvoiddialog_paint_motd(HDC hDC){ HANDLE hFont; CHAR date_line[64]; RECT r = { 300, 90, 565, 330 }; // invalid month if (motd.month < 1 || motd.month > 12) return; SetBkMode(hDC, TRANSPARENT); // title hFont = CreateFont(16, 0, 0, 0, FW_BOLD, FALSE, TRUE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Tahoma")); SelectObject(hDC, hFont); sprintf_s(date_line, sizeof(date_line), "%d %s %d", motd.day, month_names[motd.month-1], motd.year); DrawText(hDC, date_line, -1, &r, DT_WORDBREAK); r.top = 115; // text hFont = CreateFont(16, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Tahoma")); SelectObject(hDC, hFont); DrawTextW(hDC, motd.text, -1, &r, DT_WORDBREAK);}
开发者ID:luza,项目名称:tehpatcher,代码行数:28,
示例7: WndProcLRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ HDC hdc; PAINTSTRUCT ps; RECT rect; switch (message) { case WM_CREATE: PlaySoundW(L"hellowin.wav", NULL, SND_FILENAME | SND_ASYNC); return 0; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); DrawTextW(hdc, L"Hello, Windows 98!汉字", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam);}
开发者ID:zhouyang209117,项目名称:CppTutorial,代码行数:29,
示例8: sizeWithText SIZE sizeWithText(const wchar_t * pszText, int nLen, DWORD dwFmt, LONG nWidthLimit) { SIZE tRet = {0}; do { CC_BREAK_IF(! pszText || nLen <= 0); RECT rc = {0, 0, 0, 0}; DWORD dwCalcFmt = DT_CALCRECT; if (nWidthLimit > 0) { rc.right = nWidthLimit; dwCalcFmt |= DT_WORDBREAK | (dwFmt & DT_CENTER) | (dwFmt & DT_RIGHT); } // use current font to measure text extent HGDIOBJ hOld = SelectObject(_DC, _font); // measure text size DrawTextW(_DC, pszText, nLen, &rc, dwCalcFmt); SelectObject(_DC, hOld); tRet.cx = rc.right; tRet.cy = rc.bottom; } while (0); return tRet; }
开发者ID:253627764,项目名称:FantasyWarrior3D,代码行数:30,
示例9: OnPaintvoid OnPaint(HWND hWnd){ HDC dialogDC; PAINTSTRUCT paint; RECT cRC, textRC; int i; HBRUSH hBrush; HPEN hPen; HFONT dcFont; COLORREF cr; int nch = GetWindowTextW(windowList[selectedWindow], windowText, 1023); dialogDC = BeginPaint(hWnd, &paint); { GetClientRect(hWnd, &cRC); FillRect(dialogDC, &cRC, GetSysColorBrush(COLOR_MENU)); for(i=0; i< windowCount; i++) { HICON hIcon = iconList[i]; int xpos = xOffset + 40 * (i % nCols); int ypos = yOffset + 40 * (i / nCols); if (selectedWindow == i) { hBrush = GetSysColorBrush(COLOR_HIGHLIGHT); } else { hBrush = GetSysColorBrush(COLOR_MENU); }#if TRUE cr = GetSysColor(COLOR_BTNTEXT); // doesn't look right! >_< hPen = CreatePen(PS_DOT, 1, cr); SelectObject(dialogDC, hPen); SelectObject(dialogDC, hBrush); Rectangle(dialogDC, xpos-2, ypos-2, xpos+32+2, ypos+32+2); DeleteObject(hPen); // Must NOT destroy the system brush!#else RECT rc = { xpos-2, ypos-2, xpos+32+2, ypos+32+2 }; FillRect(dialogDC, &rc, hBrush);#endif DrawIcon(dialogDC, xpos, ypos, hIcon); } dcFont = SelectObject(dialogDC, dialogFont); SetTextColor(dialogDC, GetSysColor(COLOR_BTNTEXT)); SetBkColor(dialogDC, GetSysColor(COLOR_BTNFACE)); textRC.top = itemsH; textRC.left = 8; textRC.right = totalW - 8; textRC.bottom = totalH - 8; DrawTextW(dialogDC, windowText, nch, &textRC, DT_CENTER|DT_END_ELLIPSIS); SelectObject(dialogDC, dcFont); } EndPaint(hWnd, &paint);}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:60,
示例10: draw_launchersstatic void draw_launchers( HDC hdc, RECT update_rect ){ COLORREF color = SetTextColor( hdc, RGB(255,255,255) ); /* FIXME: depends on background color */ int mode = SetBkMode( hdc, TRANSPARENT ); unsigned int i; LOGFONTW lf; HFONT font; SystemParametersInfoW( SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0 ); font = SelectObject( hdc, CreateFontIndirectW( &lf ) ); for (i = 0; i < nb_launchers; i++) { RECT dummy, icon = get_icon_rect( i ), title = get_title_rect( i ); if (IntersectRect( &dummy, &icon, &update_rect )) DrawIconEx( hdc, icon.left, icon.top, launchers[i]->icon, icon_cx, icon_cy, 0, 0, DI_DEFAULTSIZE|DI_NORMAL ); if (IntersectRect( &dummy, &title, &update_rect )) DrawTextW( hdc, launchers[i]->title, -1, &title, DT_CENTER|DT_WORDBREAK|DT_EDITCONTROL|DT_END_ELLIPSIS ); } SelectObject( hdc, font ); SetTextColor( hdc, color ); SetBkMode( hdc, mode );}
开发者ID:AmineKhaldi,项目名称:mbedtls-cleanup,代码行数:28,
|