当前位置: 首页>>代码示例>>C++>>正文


C++ DrawTextW函数代码示例

本文整理汇总了C++中DrawTextW函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawTextW函数的具体用法?C++ DrawTextW怎么用?C++ DrawTextW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DrawTextW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ex_trace_scrn

void  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,代码来源:ex_debug.cpp

示例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,代码来源:GdiLabelDrawer.cpp

示例3: DrawTextUW

static 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,代码来源:w32u_windowsW.c

示例4: LLabel_OnPaint

static 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,代码来源:linklabel.c

示例5: DrawTextW

void 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,代码来源:drawing.cpp

示例6: dialog_paint_motd

void
dialog_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,代码来源:dialog.c

示例7: WndProc

LRESULT 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,代码来源:C01HelloWinW.c

示例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,代码来源:CCDevice-win32.cpp

示例9: OnPaint

void 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,代码来源:appswitch.c

示例10: draw_launchers

static 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,代码来源:desktop.c

示例11: DrawShadowText

/***********************************************************************
 * DrawShadowText [[email protected]]
 *
 * Draw text with shadow.
 */
int WINAPI DrawShadowText(HDC hdc, LPCWSTR pszText, UINT cch, RECT *rect, DWORD dwFlags,
                          COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset)
{
    FIXME("(%p, %s, %d, %p, %d, 0x%08x, 0x%08x, %d, %d): stub\n", hdc, debugstr_w(pszText), cch, rect, dwFlags,
                                                                  crText, crShadow, ixOffset, iyOffset);
    return DrawTextW(hdc, pszText, cch, rect, DT_LEFT);
}
开发者ID:DeltaYang,项目名称:wine,代码行数:12,代码来源:commctrl.c

示例12: paint_document

static void paint_document(HTMLDocumentObj *This)
{
    PAINTSTRUCT ps;
    RECT rect;
    HDC hdc;

    GetClientRect(This->hwnd, &rect);

    hdc = BeginPaint(This->hwnd, &ps);

    if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER)))
        DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST);

    if(!This->nscontainer) {
        WCHAR wszHTMLDisabled[100];
        HFONT font;

        LoadStringW(hInst, IDS_HTMLDISABLED, wszHTMLDisabled, sizeof(wszHTMLDisabled)/sizeof(WCHAR));

        font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);

        SelectObject(hdc, font);
        SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW));

        Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
        DrawTextW(hdc, wszHTMLDisabled,-1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);

        DeleteObject(font);
    }

    EndPaint(This->hwnd, &ps);
}
开发者ID:pstrealer,项目名称:wine,代码行数:32,代码来源:view.c

示例13: DrawTextW

// *********************************************************************
// 					MeasureString()										
// *********************************************************************
void GdiLabelDrawer::MeasureString(CLabelInfo* lbl, CRect& rect)
{
	DrawTextW(_dc->m_hDC, lbl->text, -1, rect, DT_CALCRECT);

	// frame for GDI is very narrow; so we'll enlarge it a bit					
	rect.left -= rect.Height() / 6;
	rect.right += rect.Height() / 6;
}
开发者ID:liuzhumei,项目名称:MapWinGIS,代码行数:11,代码来源:GdiLabelDrawer.cpp

示例14: ICONTITLE_Paint

/***********************************************************************
 *           ICONTITLE_Paint
 */
static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive )
{
    RECT rect;
    HFONT hPrevFont;
    HBRUSH hBrush;
    COLORREF textColor = 0;

    if( bActive )
    {
	hBrush = GetSysColorBrush(COLOR_ACTIVECAPTION);
	textColor = GetSysColor(COLOR_CAPTIONTEXT);
    }
    else
    {
        if( GetWindowLongPtrA( hwnd, GWL_STYLE ) & WS_CHILD )
	{
	    hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
	    if( hBrush )
	    {
		INT level;
		LOGBRUSH logBrush;
		GetObjectA( hBrush, sizeof(logBrush), &logBrush );
		level = GetRValue(logBrush.lbColor) +
			   GetGValue(logBrush.lbColor) +
			      GetBValue(logBrush.lbColor);
		if( level < (0x7F * 3) )
		    textColor = RGB( 0xFF, 0xFF, 0xFF );
	    }
	    else
		hBrush = GetStockObject( WHITE_BRUSH );
	}
	else
	{
	    hBrush = GetStockObject( BLACK_BRUSH );
	    textColor = RGB( 0xFF, 0xFF, 0xFF );
	}
    }

    GetClientRect( hwnd, &rect );
    DPtoLP( hDC, (LPPOINT)&rect, 2 );
    FillRect( hDC, &rect, hBrush );

    hPrevFont = SelectObject( hDC, hIconTitleFont );
    if( hPrevFont )
    {
	WCHAR buffer[80];

        INT length = GetWindowTextW( owner, buffer, sizeof(buffer)/sizeof(buffer[0]) );
        SetTextColor( hDC, textColor );
        SetBkMode( hDC, TRANSPARENT );

        DrawTextW( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
                   DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) );

	SelectObject( hDC, hPrevFont );
    }
    return (hPrevFont != 0);
}
开发者ID:GYGit,项目名称:reactos,代码行数:61,代码来源:icontitle.c

示例15: ListView_GetItemText

int SensorListControl::CustomDrawText(HDC hdc, int rowIndex, int columnIndex, HFONT hFont, RECT& rect)
{
    WCHAR text[MaxTextLength] = {0};
    ListView_GetItemText(m_hWnd, rowIndex, columnIndex, text, _countof(text));

    SelectObject(hdc, hFont);

    return DrawTextW(hdc, text, (int)wcsnlen_s(text, MaxTextLength), &rect, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
}
开发者ID:sterlingware,项目名称:starship,代码行数:9,代码来源:CustomDrawListControl.cpp


注:本文中的DrawTextW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。