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


C++ CFont::CreateFontW方法代码示例

本文整理汇总了C++中CFont::CreateFontW方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::CreateFontW方法的具体用法?C++ CFont::CreateFontW怎么用?C++ CFont::CreateFontW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFont的用法示例。


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

示例1: _ResizeWindow

void WeaselPanel::_ResizeWindow()
{
	if (!m_status.composing)
	{
		SetWindowPos( NULL, 0, 0, STATUS_ICON_SIZE, STATUS_ICON_SIZE, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
		return;
	}
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);

	CSize size = m_layout->GetContentSize();
	SetWindowPos(NULL, 0, 0, size.cx, size.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
	dc.DeleteDC();
}
开发者ID:wlnetman,项目名称:weasel,代码行数:17,代码来源:WeaselPanel.cpp

示例2: Refresh

//¸üнçÃæ
void WeaselPanel::Refresh()
{
	if (m_layout != NULL)
		delete m_layout;
	if (m_style.layout_type == LAYOUT_VERTICAL)
		m_layout = new VerticalLayout(m_style, m_ctx);
	else if (m_style.layout_type == LAYOUT_HORIZONTAL)
		m_layout = new HorizontalLayout(m_style, m_ctx);
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);
	m_layout->DoLayout(dc);
	dc.DeleteDC();

	_ResizeWindow();
	_RepositionWindow();
	RedrawWindow();
}
开发者ID:wlnetman,项目名称:weasel,代码行数:21,代码来源:WeaselPanel.cpp

示例3: OnSetSize

void CdlTxtView::OnSetSize(NMHDR* pNMHDR, LRESULT* pRes)
{
	
	CFont cfont;
	cfont.CreateFontW(-((CHARNMHDR*)pNMHDR)->cf.yHeight/20,                        // nHeight
					0,                         // nWidth
				  0,                         // nEscapement
				  0,                         // nOrientation
				  400,                 // nWeight
				  FALSE,                     // bItalic
				  FALSE,                     // bUnderline
				  0,                         // cStrikeOut
				  ANSI_CHARSET,              // nCharSet
				  OUT_DEFAULT_PRECIS,        // nOutPrecision
				  CLIP_DEFAULT_PRECIS,       // nClipPrecision
				  DEFAULT_QUALITY,           // nQuality
				  DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
				  _T("Arial"));
	GetRichEditCtrl().SetFont(&cfont);

	*pRes =1;
}
开发者ID:DLive,项目名称:itbook_access,代码行数:22,代码来源:dlTxtView.cpp

示例4: OnPaint

void CClosableTabCtrl::OnPaint(){
	//CTabCtrl::OnPaint();
	ModifyStyle(0, WS_CLIPCHILDREN);
	if( !m_pSpinCtrl )
    {
      CWnd * pWnd = FindWindowEx( GetSafeHwnd(), 0, _T("msctls_updown32"), 0 );
      if( pWnd )
      {
        m_pSpinCtrl = new CSpinButtonCtrl;
        m_pSpinCtrl->Attach(pWnd->GetSafeHwnd());
      }
    }

	BOOL aero=false;
	HMODULE hm=LoadLibrary(L"dwmapi.dll");
	if(hm){
		DWMISCOMPOSITIONENABLED* ic=(DWMISCOMPOSITIONENABLED*)GetProcAddress(hm, "DwmIsCompositionEnabled");
		(ic)(&aero);
		FreeLibrary(hm);
	}

	RECT wrect;
	GetWindowRect(&wrect);
	int w=wrect.right-wrect.left;
	int h=TAB_HEIGHT+TAB_TOP_MARGIN;
	CPaintDC _dc(this);
	if(!_dc.m_hDC)return;
	CDC dc;
	dc.CreateCompatibleDC(&_dc);
	if(!dc.m_hDC){
		ReleaseDC(&_dc);
		return;
	}
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&_dc, w, h);
	if(!bmp.m_hObject){
		ReleaseDC(&_dc);
		ReleaseDC(&dc);
		return;
	}
	CBitmap* obmp=dc.SelectObject(&bmp);

	
	CFont fnt;
	fnt.CreateFontW(-11, 0, 0, 0, 0, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, L"Tahoma"); 
	CFont* ofnt=dc.SelectObject(&fnt);
	
	

	dc.SetBkMode(TRANSPARENT);

	//skin.tabbarBG.bmp.DrawStretched(&dc, 0, 0, w, 20, 0, 0, 0, 0);
	if(!aero){
		COLORREF bgcol=IsTopParentActive()?GetSysColor(COLOR_ACTIVECAPTION):GetSysColor(COLOR_INACTIVECAPTION);
		dc.FillSolidRect(0, 0, w, h, bgcol);
	}

	int offset=5;

	if(m_pSpinCtrl){
		int p=LOWORD(m_pSpinCtrl->GetPos());
		for(int i=0;i<p;i++){
			offset-=itemWidths[i];
		}
	}

	itemWidths.clear();
	int totalWidth=5;

	for(int i=0;i<GetItemCount();i++){
		TC_ITEM item;
		memset(&item, 0, sizeof(TC_ITEM));
		item.mask=TCIF_TEXT|TCIF_IMAGE|TCIF_PARAM;
		item.pszText=new wchar_t[512];
		item.cchTextMax=512;
		GetItem(i, &item);
		int tw=dc.GetTextExtent(item.pszText, wcslen(item.pszText)).cx+40;
		RECT rect;
		rect.top=TAB_TOP_MARGIN;
		rect.bottom=h;
		rect.left=offset;
		rect.right=offset+tw;
		CTalkTab* tab=(CTalkTab*)item.lParam;

		totalWidth+=tw;

		if(i==this->GetCurSel()){
			skin.tabActive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			dc.SetTextColor(skin.tabActiveTextColor);
		}else if(over_idx==i){
			skin.tabOver.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabOverTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}else{
			skin.tabInactive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabIncativeTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}

		HICON hIcon=skin.iconUnknown;
//.........这里部分代码省略.........
开发者ID:Enelar,项目名称:VkIM,代码行数:101,代码来源:ClosableTabCtrl.cpp

示例5: DoPaint

//draw client area
void WeaselPanel::DoPaint(CDCHandle dc)
{
	CRect rc;
	GetClientRect(&rc);

	if (!m_status.composing)
	{
		if (m_status.ascii_mode)
			dc.DrawIconEx(0, 0, m_iconAlpha, 0, 0);
		else
			dc.DrawIconEx(0, 0, m_iconEnabled, 0, 0); 
		return;
	}

	// background
	{
		CBrush brush;
		brush.CreateSolidBrush(m_style.back_color);
		CRgn rgn;
		rgn.CreateRectRgnIndirect(&rc);
		dc.FillRgn(rgn, brush);

		CPen pen;
		pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, m_style.border, m_style.border_color);
		CPenHandle oldPen = dc.SelectPen(pen);
		CBrushHandle oldBrush = dc.SelectBrush(brush);
		dc.Rectangle(&rc);
		dc.SelectPen(oldPen);
		dc.SelectBrush(oldBrush);
	}

	long height = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);

	CFont font;
	font.CreateFontW(height, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	CFontHandle oldFont = dc.SelectFont(font);

	dc.SetTextColor(m_style.text_color);
	dc.SetBkColor(m_style.back_color);
	dc.SetBkMode(TRANSPARENT);
	
	bool drawn = false;

	// draw preedit string
	if (!m_style.inline_preedit)
		drawn |= _DrawPreedit(m_ctx.preedit, dc, m_layout->GetPreeditRect());
	
	/* FIXME: What's this?
	// ascii mode icon
	if (m_status.ascii_mode && y > rc.top)
	{
		int icon_x = rc.right - STATUS_ICON_SIZE;
		int icon_y = (rc.top + y - m_style.spacing - STATUS_ICON_SIZE) / 2;
		dc.DrawIconEx(icon_x, icon_y, m_iconAlpha, 0, 0);
	}*/

	/* TODO: Deprecated? */
	// draw auxiliary string
	drawn |= _DrawPreedit(m_ctx.aux, dc, m_layout->GetAuxiliaryRect());

	// draw candidates
	drawn |= _DrawCandidates(dc);

	/* Nothing drawn, hide candidate window */
	if (!drawn)
		ShowWindow(SW_HIDE);

	dc.SelectFont(oldFont);	
}
开发者ID:wlnetman,项目名称:weasel,代码行数:70,代码来源:WeaselPanel.cpp

示例6: OnPaint

void CConfigAppearance::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// Do not call CPropertyPage::OnPaint() for painting messages

	CRect Rect, ParentRect;
	GetWindowRect(ParentRect);

	CWnd *pWnd = GetDlgItem(IDC_COL_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	CBrush BrushColor;
	BrushColor.CreateSolidBrush(m_iColors[m_iSelectedItem]);

	// Solid color box
	CBrush *pOldBrush = dc.SelectObject(&BrushColor);
	dc.Rectangle(Rect);
	dc.SelectObject(pOldBrush);

	// Preview all colors

	pWnd = GetDlgItem(IDC_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;// - 16;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	int WinHeight = Rect.bottom - Rect.top;

	CFont Font;		// // //
	Font.CreateFontW(-m_iFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET,
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, m_strFont.data());
	CFont *OldFont = OldFont = dc.SelectObject(&Font);

	// Background
	dc.FillSolidRect(Rect, GetColor(COL_BACKGROUND));
	dc.SetBkMode(TRANSPARENT);

	COLORREF ShadedCol = DIM(GetColor(COL_PATTERN_TEXT), .5);
	COLORREF ShadedHiCol = DIM(GetColor(COL_PATTERN_TEXT_HILITE), .5);

	int iRowSize = m_iFontSize;
	int iRows = (WinHeight - 12) / iRowSize;// 12;

	COLORREF CursorCol = GetColor(COL_CURSOR);
	COLORREF CursorShadedCol = DIM(CursorCol, .5);
	COLORREF BgCol = GetColor(COL_BACKGROUND);
	COLORREF HilightBgCol = GetColor(COL_BACKGROUND_HILITE);
	COLORREF Hilight2BgCol = GetColor(COL_BACKGROUND_HILITE2);

	const auto BAR = [&] (int x, int y) {
		dc.FillSolidRect(x + 3, y + (iRowSize / 2) + 1, 10 - 7, 1, ShadedCol);
	};

	for (int i = 0; i < iRows; ++i) {

		int OffsetTop = Rect.top + (i * iRowSize) + 6;
		int OffsetLeft = Rect.left + 9;

		if (OffsetTop > (Rect.bottom - iRowSize))
			break;

		if ((i & 3) == 0) {
			if ((i & 6) == 0)
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, Hilight2BgCol, BgCol);		// // //
			else
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, HilightBgCol, BgCol);

			if (i == 0) {
				dc.SetTextColor(GetColor(COL_PATTERN_TEXT_HILITE));
				GradientBar(dc, Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, GetColor(COL_BACKGROUND));
				dc.Draw3dRect(Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, CursorShadedCol);
			}
			else
				dc.SetTextColor(ShadedHiCol);
		}
		else {
			dc.SetTextColor(ShadedCol);
		}

		if (i == 0) {
			dc.TextOutW(OffsetLeft, OffsetTop - 2, L"C");
			dc.TextOutW(OffsetLeft + 12, OffsetTop - 2, L"-");
			dc.TextOutW(OffsetLeft + 24, OffsetTop - 2, L"4");
		}
		else {
			BAR(OffsetLeft, OffsetTop - 2);
			BAR(OffsetLeft + 12, OffsetTop - 2);
			BAR(OffsetLeft + 24, OffsetTop - 2);
		}

		if ((i & 3) == 0) {
			dc.SetTextColor(ShadedHiCol);
//.........这里部分代码省略.........
开发者ID:jpmac26,项目名称:0CC-FamiTracker,代码行数:101,代码来源:ConfigAppearance.cpp

示例7: OnPaint

void CColorTree::OnPaint()
{
	CTreeCtrl::OnPaint();
	CPaintDC dc(this); // device context for painting
	HTREEITEM hItem;
	CImageList *List;
			List = GetImageList(0);

	
	hItem = GetFirstVisibleItem();
	CRect rec, recText;

	 CBrush brush0(m_colRow1);
	CBrush brush1(m_colRow2);

	int i;
	i = 0;
	CDC * pDC;
	pDC = GetDC();
	CFont Font;
	Font.CreateFontW(15,0,0,0,FW_NORMAL, FALSE, FALSE,FALSE,RUSSIAN_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_MODERN|DEFAULT_PITCH,_T("TestFont"));
	pDC->SelectObject(Font);
	while(hItem!=NULL)
	{
		GetItemRect(hItem,rec,FALSE);
		GetItemRect(hItem,recText,TRUE);
		//
		if(i % 2 == 0)
			{
				pDC->FillRect(rec,&brush0);
				pDC->SetBkColor(m_colRow1);
			}
		else
			{
				pDC->SetBkColor(m_colRow2);
				pDC->FillRect(rec,&brush1);
			}
		CString sName;
		sName = GetItemText(hItem);
		if(sName.Find(_T("\n"))>-1)
		{
			sName =  sName.Left(sName.Find(_T("\n")));
		}
		if(sName.Find(_T("\t"))>-1)
			{
				CString sVal;
				sVal = sName.Left(sName.Find(_T("\t")));
				pDC->TextOutW(recText.left-20 ,rec.top,sVal,sVal.GetLength());
				
				sVal = sName.Right(sName.GetLength()-1-sVal.GetLength());
				pDC->TextOutW(rec.left + (rec.right - rec.left)/2,rec.top,sVal,sVal.GetLength());
			}
		else
			pDC->TextOutW(recText.left - 20,rec.top,sName,sName.GetLength());


		if(GetItemState(hItem, TVIS_EXPANDED)& TVIS_EXPANDED)
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				List->Draw(pDC,1,xy,ILD_NORMAL);
			}
		}
		else
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				if(GetChildItem(hItem)!=NULL)
					List->Draw(pDC,0, xy,ILD_NORMAL);
				else
					List->Draw(pDC,2, xy,ILD_NORMAL);
			}
		}

		hItem = GetNextVisibleItem(hItem);
		i++;
	}
}
开发者ID:BeL1kOFF,项目名称:SHATE,代码行数:84,代码来源:ColorTree.cpp


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