void KSMsgDrawer::DisplayMessages(CDC * pDC,const CRect & client)
{
	if(!m_showMessage)
		return;
	// 设置字体
	LOGFONT lf;
	memset(&lf,0,sizeof lf);
	lf.lfCharSet = GB2312_CHARSET;
	strcpy(lf.lfFaceName,m_fontName);
	lf.lfHeight = m_fontSize;
	lf.lfWeight = FW_BOLD;

	CFont font;
	CFont *oldFont;
	font.CreateFontIndirect(&lf);
	oldFont = pDC->SelectObject(&font);
	// 如果只有一行就居中
	int line_top = (m_displayMsgList.size() == 1) ? client.Height() / 2 :
		client.Height() / 3;
	int last_line = 1;

	for(cstr_vector::iterator i = m_displayMsgList.begin();
		i != m_displayMsgList.end();++i)
	{
		cstring_msg msg = (*i).second;
		int lineno = msg.GetLineno();
		if( lineno <= 0)
			continue;

		CString msg_str = msg.GetMsg();
		if(msg.GetSizeOffset() != 0)
		{
			font.DeleteObject();
			lf.lfHeight = m_fontSize + msg.GetSizeOffset();
			font.CreateFontIndirect(&lf);
			pDC->SelectObject(&font);
		}
		CSize size = pDC->GetTextExtent(msg_str);
		RECT textRect;
		textRect.left = (client.Width() - size.cx) / 2;
		if(textRect.left < 1)
			textRect.left = 1;
		textRect.right = textRect.left + size.cx;
		if (textRect.right >= client.right )
			textRect.right = client.right - 1;
		textRect.top = line_top + (lineno - last_line) * size.cy;
		textRect.bottom = client.bottom;
		pDC->DrawText(msg_str,&textRect,DT_CENTER|DT_SINGLELINE);
		last_line = msg.GetLineno();
		line_top = textRect.top + size.cy;
	}
	pDC->SelectObject(oldFont);
}
Exemple #2
0
void CSplashScreen::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	if (m_imgSplash.GetSafeHandle())
	{
		CDC dcMem;
		if (dcMem.CreateCompatibleDC(&dc))
		{
			CBitmap* pOldBM = dcMem.SelectObject(&m_imgSplash);
			BITMAP BM;
			m_imgSplash.GetBitmap(&BM);
			dc.BitBlt(0, 0, BM.bmWidth, BM.bmHeight, &dcMem, 0, 0, SRCCOPY);
			if (pOldBM)
				dcMem.SelectObject(pOldBM);

			CRect rc(0, (int)(BM.bmHeight * 0.65), BM.bmWidth, BM.bmHeight);
			dc.FillSolidRect(rc.left+1, rc.top+1, rc.Width()-2, rc.Height()-2, RGB(255,255,255));

			LOGFONT lf = {0};
			lf.lfHeight = 30;
			lf.lfWeight = FW_BOLD;
			lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY;
			_tcscpy(lf.lfFaceName, _T("Arial"));
			CFont font;
			font.CreateFontIndirect(&lf);
			CFont* pOldFont = dc.SelectObject(&font);
			CString strAppVersion(_T("eMule ") + theApp.m_strCurVersionLong);
			rc.top += dc.DrawText(strAppVersion, &rc, DT_CENTER | DT_NOPREFIX);
			if (pOldFont)
				dc.SelectObject(pOldFont);
			font.DeleteObject();

			rc.top += 8;

			lf.lfHeight = 14;
			lf.lfWeight = FW_NORMAL;
			lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY;
			_tcscpy(lf.lfFaceName, _T("Arial"));
			font.CreateFontIndirect(&lf);
			pOldFont = dc.SelectObject(&font);
			dc.DrawText(_T("Copyright (C) 2002-2015 Merkur"), &rc, DT_CENTER | DT_NOPREFIX);
			if (pOldFont)
				dc.SelectObject(pOldFont);
			font.DeleteObject();
		}
	}
}
Exemple #3
0
/*

* Method preamble ************************************************************
*
* CLASS:            TFXDataTip
* NAME:             Initialise
*
* DESCRIPTION:      This method initialise the DataTip class. It creates the
*                   default font used for DataTips, the brush used to paint
*                   windows background, and registers the window class. 
*
*                   If there is currently no hook procedure instaklled for
*                   the class it alos installs a keyboard hook procedure.
*
* PARAMETERS:       none
*
* RETURN TYPE:      void
*
******************************************************************************
*                                  REVISION HISTORY                                                               
*
******************************************************************************
*/
void TFXDataTip::Initialise( )
{
    if (_font.GetSafeHandle( ) == NULL)
    {
        // create the default tip font
        LOGFONT lFont;
        GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof lFont, &lFont);
        _font.CreateFontIndirect(&lFont);

        // create the other GDI objects
        //_brush = new CBrush(::GetSysColor(COLOR_INFOBK));
        _brush = new CBrush( RGB(32,32,32) );
    }

    // register the window class
    RegisterWnd( );

    // install the keyboard hook procedure
    if (_hookProc == NULL)
    {
        _hookProc = ::SetWindowsHookEx(WH_KEYBOARD, 
                                       (HOOKPROC)KeyboardHookCallback,
                                       NULL,
                                       ::GetCurrentThreadId( ));
    }
}
Exemple #4
0
/*============================================================================*/
	void MyFontDialog::
SetFontIndirect(const LOGFONT& lf)                                      /*

	Set the current font to have the characteristics contained in the
	supplied LOGFONT structure lf. Copy the face name into the font choice
	style name.
*-----------------------------------------------------------------------------*/
{
	  // convert lf to a CFont
	CFont hf;
	hf.CreateFontIndirect(&lf);

	  // if it worked, put it in this object
	if(hf)
	{
		DeleteObject(m_Font);
		m_Font = hf;
	}
	else
	{
		::MessageBox(NULL, _T("Font creation error."),
		    _T("Error"), MB_OK | MB_ICONEXCLAMATION |
		    MB_TASKMODAL);
	}
}
Exemple #5
0
////////////////////////////////////////////////////////////////////
// Public functions
//
void CDrawField::Draw( int page, CDC* dc )
/* ============================================================
	Function :		CDrawField::Draw
	Description :	Draws this object.
	Access :		Public
					
	Return :		void
	Parameters :	int page	-	Current page
					CDC* dc		-	CDC to draw to

	Usage :			Called by the generator to draw the object.

   ============================================================*/
{

	CString title = GetTitle();
	CDoubleRect rect = GetPosition();
	CUnitConversion::InchesToPixels( rect );

	CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) );
	CUnitConversion::AdjustPixelsToPaper( dc, r );

	LOGFONT	lf;
	ZeroMemory( &lf, sizeof( lf ) );

	lstrcpy( lf.lfFaceName, GetFontName() );
	lf.lfHeight = CUnitConversion::PointsToPixels( static_cast< double >( GetFontSize() ) / 10.0 );
	lf.lfItalic = static_cast< BYTE >( GetFontItalic() );
	lf.lfUnderline = static_cast< BYTE >( GetFontUnderline() );
	lf.lfStrikeOut = static_cast< BYTE >( GetFontStrikeout() );
	lf.lfCharSet = static_cast< BYTE >( GetFontCharset() );

	if( GetFontBold() )
		lf.lfWeight = FW_BOLD;
	else
		lf.lfWeight = FW_NORMAL;

	if( IsBold( title ) )
		lf.lfWeight = FW_BOLD;

	if( IsItalic( title ) )
		lf.lfItalic = TRUE;

	CFont	font;
	font.CreateFontIndirect( &lf );

	dc->SelectObject( &font );
	int color = dc->SetTextColor( GetFontColor() );
	int mode = dc->SetBkMode( TRANSPARENT );
	int justification = GetJustification();

	ReplaceFields( page, title );

	dc->DrawText( title, r, DT_NOPREFIX | DT_WORDBREAK | justification );

	dc->SetBkMode( mode );
	dc->SetTextColor( color );
	dc->SelectStockObject( ANSI_VAR_FONT );

}
void CDiagramRadiobutton::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CDiagramRadiobutton::Draw
	Description :	Draws the "control"
					
	Return :		void
	Parameters :	CDC* dc		-	CDC to draw to
					CRect rect	-	Total object rect (zoomed)
					
	Usage :			

   ============================================================*/
{

	dc->SelectObject( CStdGrfx::dialogBrush() );
	dc->SelectObject( CStdGrfx::dialogPen() );

	dc->Rectangle( rect );

	LOGFONT lf;
	CFont chk;
	CFont font;

	GetFont( lf );
	// MS Sans Serif will not scale below 8 pts
	if( GetZoom() < 1 )
		lstrcpy( lf.lfFaceName, _T( "Arial" ) );
	font.CreateFontIndirect( &lf );

	// Marlett is used for the circle
	chk.CreateFont(  ( int ) ( ( double ) lf.lfHeight * 1.25 ), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DECORATIVE, "Marlett" );
	dc->SetBkMode( TRANSPARENT );
	dc->SelectObject( &chk );

	dc->SetTextColor( ::GetSysColor( COLOR_WINDOW ) );
	dc->TextOut( rect.left, rect.top, "n" );

	dc->SetTextColor( ::GetSysColor( COLOR_3DSHADOW ) );
	dc->TextOut( rect.left, rect.top, "j" );

	dc->SetTextColor( ::GetSysColor( COLOR_3DHIGHLIGHT  ) );
	dc->TextOut( rect.left, rect.top, "k" );

	dc->SetTextColor( ::GetSysColor( COLOR_3DDKSHADOW ) );
	dc->TextOut( rect.left, rect.top, "l" );

	dc->SetTextColor( ::GetSysColor( COLOR_3DLIGHT ) );
	dc->TextOut( rect.left, rect.top, "m" );

	dc->SelectObject( &font );

	dc->SetTextColor( ::GetSysColor( COLOR_BTNTEXT ) );
	rect.left += ( int ) ( ( double ) abs( lf.lfHeight ) * 1.5 );
	dc->DrawText( GetTitle(), rect, DT_SINGLELINE );

	dc->SelectStockObject( DEFAULT_GUI_FONT );
	dc->SelectStockObject( BLACK_PEN );
	dc->SelectStockObject( WHITE_BRUSH );

}
Exemple #7
0
void paintDialogHeader(CDC* pDC, const CString &strTitle) {
  int nWidth = pDC->GetDeviceCaps(HORZRES);
  const int nHeaderHeight = 24;

  // paint title
  CFont *pCurrentFont = pDC->GetCurrentFont();
  LOGFONT lf;
  pCurrentFont->GetLogFont(&lf);
  lf.lfWeight = FW_BOLD;
  CFont newFont;
  newFont.CreateFontIndirect(&lf);

  CFont *pSave = pDC->SelectObject(&newFont);
  //pDC->SetBkColor(RGB(100,100,100));
  pDC->SetBkColor(::GetSysColor(COLOR_STATIC));
  pDC->SetTextColor(RGB(0, 0, 156));
  pDC->DrawText(strTitle, CRect(8, 0, nWidth, nHeaderHeight), DT_VCENTER | DT_SINGLELINE);
  pDC->SelectObject(pSave);

  // paint line
  CPen blackPen(PS_SOLID, 1, RGB(0,0,0));
  CPen *pOldPen = pDC->SelectObject(&blackPen);

  pDC->MoveTo(0, nHeaderHeight);
  pDC->LineTo(nWidth, nHeaderHeight);

  pDC->SelectObject(pOldPen);	
}
void CGradientStatic::DrawVerticalText(CRect *pRect)
{	
	CFont *pOldFont = NULL;;

	LOGFONT lfFont;
	if(m_cfFont.GetSafeHandle())
	{	
		m_cfFont.GetLogFont(&lfFont);
	}
	else
	{	
		CFont *pFont = GetFont();
		pFont->GetLogFont(&lfFont);
		_tcscpy(lfFont.lfFaceName, _T("Arial"));	// some fonts won't turn :(
	}
	lfFont.lfEscapement = 900;
	
	CFont Font;
	Font.CreateFontIndirect(&lfFont);
	pOldFont = m_Mem.dc.SelectObject(&Font);

	CString strText;
	GetWindowText(strText);

	m_Mem.dc.SetTextColor(m_crTextColor);
	m_Mem.dc.SetBkColor(TRANSPARENT);
	CRect rText = pRect;
	rText.bottom -= 5;
	DrawRotatedText(m_Mem.dc.m_hDC, strText, rText, 90);
	
	m_Mem.dc.SelectObject(pOldFont);
}	
Exemple #9
0
//--------------------------------------------------------------------------
// 그리기 함수
//--------------------------------------------------------------------------
void GText::Draw(CDC* pDC)
{
	CFont font;
	font.CreateFontIndirect(&m_sLogFont); //폰트 생성
	CFont *oldFont = pDC->SelectObject(&font); //폰트 지정
	
	COLORREF oldTextColor, oldBkColor;
	oldTextColor = pDC->SetTextColor(m_sLineColor); //글자 색 지정
	oldBkColor = pDC->SetBkColor(m_sBgColor); //배경 색 지정

	int oldBkMode;
	if(m_bsTransparent == TRUE) //배경 투명일 경우
		oldBkMode = pDC->SetBkMode(TRANSPARENT); //투명 배경
	else //투명이 아닐 경우
		oldBkMode = pDC->SetBkMode(OPAQUE); //지정한 배경색의 배경

	CSize textSize = pDC->GetTextExtent(m_sArrayString.GetData(), m_sArrayString.GetSize()); //텍스트가 그려질 영역의 크기를 구함
	
	//글자 끝 위치 지정
	m_sEndPoint.x = m_sStartPoint.x + textSize.cx;
	m_sEndPoint.y = m_sStartPoint.y + textSize.cy;

	CRect textRect(m_sStartPoint.x, m_sStartPoint.y, m_sEndPoint.x, m_sEndPoint.y); //텍스트가 그려질 rect
	pDC->DrawText(m_sArrayString.GetData(), m_sArrayString.GetSize(), &textRect, DT_LEFT | DT_SINGLELINE); //글자 쓰기
	
	//이전 설정으로 되돌리기
	pDC->SetTextColor(oldTextColor); //이전 텍스트 컬러로 되돌리기
	pDC->SetBkColor(oldBkColor); //이전 백그라운드 컬러로 되돌리기
	pDC->SetBkMode(oldBkMode); //이전 백그라운드 모드로 되돌리기
	pDC->SelectObject(oldFont); //옛날 폰트로 되돌리기
}
void CDiagramButton::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CDiagramButton::Draw
	Description :	Draws the "control"
					
	Return :		void
	Parameters :	CDC* dc		-	CDC to draw to
					CRect rect	-	Total object rect (zoomed)
					
	Usage :			

   ============================================================*/
{
	CStdGrfx::drawframed3dBox( dc, rect );

	LOGFONT lf;
	CFont font;

	GetFont( lf );
	// MS Sans Serif will not scale below 8 pts.
	if( GetZoom() < 1 )
		lstrcpy( lf.lfFaceName, _T( "Arial" ) );

	font.CreateFontIndirect( &lf );

	dc->SelectObject( &font );

	dc->SetBkMode( TRANSPARENT );
	dc->DrawText( GetTitle(), rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );

	dc->SelectStockObject( ANSI_VAR_FONT );

}
/* Called when the dialog is loaded, in response to the WM_INITDIALOG message.
 */
BOOL CSubmitOrderDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// Create warning font and display text
	CFont* pFont = new CFont;
	CPaintDC dc(this);
    LOGFONT lf = { 0 };
	lf.lfHeight = -MulDiv(8, GetDeviceCaps(dc.GetSafeHdc(), LOGPIXELSY), 40);
	lf.lfWeight = FW_BOLD;
    strcpy_s(lf.lfFaceName, "Microsoft Sans Serif");
    pFont->CreateFontIndirect(&lf);
    GetDlgItem(IDC_WARNING)->SetFont(pFont);

	// Initialize the TTDropHandler event sink.
	m_pDropHandler = new CDropHandlerSink();	
	// Set this class to receive the XTAPI TTDropHandler events.
	m_pDropHandler->SetCallback(this);	
	// Register the application window to receive drag and drop. 
	m_pDropHandler->Obj()->raw_RegisterDropWindow((int)m_hWnd);

	m_OrderTypeCombo.SetCurSel(0);

	// Delete the font object
	delete pFont;
	pFont = NULL;
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
Exemple #12
0
void CConfigDlg::RenderSample()
{
    CFont font;
    CHARFORMAT2 cf;
    long s1,s2;

    font.CreateFontIndirect(&m_sDComCfgTmp.m_logfont);
    m_sampleText.SetFont(&font);

    memset(&cf, 0, sizeof(cf));
    cf.cbSize = sizeof(cf);
    cf.crTextColor = m_sDComCfgTmp.m_crFore;
    cf.crBackColor = m_sDComCfgTmp.m_crBack;
    cf.dwMask = CFM_COLOR | CFM_BACKCOLOR;

    m_sampleText.SetSel(0, -1);
    m_sampleText.ReplaceSel("Normal");
    m_sampleText.SetSel(0, -1);
    m_sampleText.SetSelectionCharFormat(cf);
    m_sampleText.GetSel(s1, s2);

    cf.crTextColor = SCROLLBUFF_MAKE_BOLD(m_sDComCfgTmp.m_crFore);

    m_sampleText.SetSel(s2, -1);
    m_sampleText.ReplaceSel(" Bold");
    m_sampleText.SetSel(s2, -1);
    m_sampleText.SetSelectionCharFormat(cf);
    m_sampleText.SetSel(-1, -1);

    m_sampleText.SetBackgroundColor(FALSE, m_sDComCfgTmp.m_crBack);
    font.DeleteObject();
}
Exemple #13
0
void CPageFormatDlg::OnBtnFont() 
{
	CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
	
#ifndef _WIN32_WCE
	LOGFONT lf;
	
	pMainFrame->SelectGrid();
	m_pGrid->GetFont()->GetLogFont(&lf);
	
	
	CFontDialog dlg(&lf);
	if (dlg.DoModal() == IDOK) 
	{
		dlg.GetCurrentFont(&lf);

		CFont Font;
		Font.CreateFontIndirect(&lf);
		

		m_pGrid->SetFont(&Font);
        m_pGrid->AutoSize();
		
		
		Font.DeleteObject();	
	}

#endif

}
Exemple #14
0
void CvMainView::PrintTitlePage(CDC* pDC, CPrintInfo* pInfo)
{
	// Prepare a font size for displaying the file name
	LOGFONT logFont;
	memset(&logFont, 0, sizeof(LOGFONT));
//	logFont.lfHeight = 75;  //  3/4th inch high in MM_LOENGLISH
							// (1/100th inch)
	logFont.lfHeight = 200; // 2cm
	CFont font;
	CFont* pOldFont = NULL;
	if (font.CreateFontIndirect(&logFont))
		pOldFont = pDC->SelectObject(&font);

	// Get the file name, to be displayed on title page
//	CString strPageTitle = GetDocument()->GetTitle();
	CString strPageTitle = _T("Ingres Visual Manager");

	// Display the file name 1 inch below top of the page,
	// centered horizontally
	pDC->SetTextAlign(TA_CENTER);
	pDC->TextOut(pInfo->m_rectDraw.right/2, -100, strPageTitle);

	if (pOldFont != NULL)
		pDC->SelectObject(pOldFont);
}
void CPageBase::OnPaint()
{
	CPaintDC dc(this); 

	//填充标题栏背景
	CRect rcWnd;
	GetClientRect(&rcWnd);	
	CRect rcTitle(1,1,rcWnd.right-1,rcWnd.top+25);
	dc.FillSolidRect(&rcTitle,RGB(46,64,94));

	//绘制标题
	if(m_pszTitle!=NULL)
	{
		CFont font;
		font.CreateFontIndirect(&m_lfBaseFont);
		CFont * pOldFont=dc.SelectObject(&font);
		int nOldBkMod=dc.SetBkMode(TRANSPARENT);
		DWORD dwOldTxtColor=dc.SetTextColor(RGB(255,255,255));

		CSize cz=dc.GetTextExtent(m_pszTitle);
		int nTitleL=4;
		int nTitleT=(24-cz.cy)/2+1;
		dc.TextOut(nTitleL,nTitleT,m_pszTitle,_tcslen(m_pszTitle));

		dc.SetTextColor(dwOldTxtColor);
		dc.SetBkMode(nOldBkMod);
		dc.SelectObject(pOldFont);
	}
}
Exemple #16
0
void CaImMenu::MeasureItem (LPMEASUREITEMSTRUCT lpMeasureItemStruct) {
	MENUITEMINFO iInfo;
	GetMenuItemInfo (lpMeasureItemStruct->CtlID, &iInfo);
	CaImMenuItem* pItem = (CaImMenuItem*)lpMeasureItemStruct->itemData;

	CFont fntDef;
	LOGFONT lfDef;
	CClientDC dc (0);
	CFont* pFont = (CFont *)dc.SelectStockObject (ANSI_VAR_FONT);
	if (pItem->CheckStyle (AMIS_DEFAULT)) {
		CFont* pFnt = dc.GetCurrentFont ();
		pFnt->GetLogFont (&lfDef);
		lfDef.lfWeight = FW_BOLD;
		fntDef.CreateFontIndirect (&lfDef);
		dc.SelectObject (&fntDef);
	}

	if (pItem->CheckStyle (AMIS_BAR))
		lpMeasureItemStruct->itemHeight = 4;
	else
		lpMeasureItemStruct->itemHeight = m_dwHeight;
	lpMeasureItemStruct->itemWidth = 25 + 8 + 8 + 2 + dc.GetTextExtent (pItem->GetText ()).cx;

	dc.SelectObject (pFont);
	if (pItem->CheckStyle (AMIS_DEFAULT))
		fntDef.DeleteObject ();
}
HBRUSH CDialogEpsGraph::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if (pWnd->GetDlgCtrlID() == IDC_STATIC_FOOTER)
	{
		pDC->SetTextColor(RGB(0, 255, 0));
		pDC->SetBkMode(TRANSPARENT);

		LOGFONT lf;
		memset(&lf,0,sizeof(LOGFONT));
		strcpy(lf.lfFaceName,"Courier New");
		lf.lfHeight = (long)16;
		lf.lfWeight = 400;
		CFont font; font.CreateFontIndirect(&lf);
		pDC->SelectObject(&font);


		static CBrush br(RGB(0,0,0));
		return br;

	}
	
	return hbr;
}
int CMLeakView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CView::OnCreate(lpCreateStruct) == -1)
        return -1;

    // TODO: Add your specialized creation code here

    LOGFONT lf;
    memset(&lf,0,sizeof(LOGFONT));

    lf.lfHeight = 50;
    lf.lfWeight=FW_NORMAL;
    lf.lfEscapement=0;
    lf.lfOrientation=0;
    lf.lfItalic=false;
    lf.lfUnderline = false;
    lf.lfStrikeOut = false;
    lf.lfCharSet=ANSI_CHARSET;
    lf.lfPitchAndFamily=34;  //Arial

    NFont.CreateFontIndirect(&lf);

#ifdef _DEBUG
    oldMemState.Checkpoint();
#endif

    return 0;
}
void CDataServerCenterView::OnInitialUpdate()
{
	CView::OnInitialUpdate();
	isMainUIDlg = 0;
	GetClientRect(&rc);

	m_btnEnterSystem.Create(L"进入\n系统",WS_CHILD|WS_VISIBLE,CRect(0,0,128,128),this,ID_BUTTON_ENTERSYSTEMMAINUI);
	CFont Font; //= m_btnEnterSystem.GetFont();
	LOGFONT LogFont;
	LogFont.lfWeight=0; //字体磅数=10
	LogFont.lfHeight=0;	 //字体高度(旋转后的字体宽度)=56
	LogFont.lfWidth=0;   //字体宽度(旋转后的字体高度)=20
	LogFont.lfUnderline=FALSE; //无下划线
	LogFont.lfStrikeOut=FALSE; //无删除线
	LogFont.lfItalic=FALSE; //非斜体
	//LogFont.lfCharSet=DEFAULT_CHARSET; //使用缺省字符集
	wcscpy(LogFont.lfFaceName,L"微软雅黑"); //字体名=@system L"楷体_GB2312"
	//LogFont.lfFaceName =L"@system";  //字体设置
	//pFont->Detach();
	//第四步的目的是将pFont里装有的HFONT解除关联,否则pFont无法调用紧接的Create函数。
	Font.CreateFontIndirect(&LogFont);
	m_btnEnterSystem.SetFont(&Font);
	//::SetTextColor(m_btnEnterSystem.GetDC()->m_hDC,RGB(255,0,0));
	//m_btnEnterSystem.GetDC()->SetTextColor(RGB(255,0,0));
	m_btnEnterSystem.SetColor(CButtonST::BTNST_COLOR_FG_OUT,RGB(3,48,139));
	m_btnEnterSystem.SetColor(CButtonST::BTNST_COLOR_FG_IN,RGB(255,0,0));

	HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON_ENTERSYSTEM); 
	m_btnEnterSystem.SetIcon(hIcon); 
	m_btnEnterSystem.DrawTransparent(TRUE);
	m_btnEnterSystem.SetTooltipText(L"进入系统主界面");
	m_btnEnterSystem.DrawBorder(FALSE);
}
void COTDKView::OnDraw(CDC* pDC)
{
	LOGFONT logFont;
	logFont.lfHeight=18;
	logFont.lfWidth = 0;
	logFont.lfEscapement = 0;
	logFont.lfOrientation = 0;
	logFont.lfWeight = FW_NORMAL;
	logFont.lfItalic = 0;
	logFont.lfUnderline = 0;
	logFont.lfStrikeOut = 0;
	logFont.lfCharSet = DEFAULT_CHARSET;
	logFont.lfQuality = PROOF_QUALITY;
	logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
	UINT position = 0;
	int i=0;
	strcpy(logFont.lfFaceName, "Times New Roman");
	CFont font;
	CPoint point;
	//
	font.CreateFontIndirect(&logFont);
	COTDKDoc* pDoc = GetDocument();
	CFont* oldFont = pDC->SelectObject(&font);
	point = pDC->GetCurrentPosition();  
	position += point.y; 
	for (i=0; i <= pDoc->GetcsaSize()-1; i++) {
		pDC->SetTextColor(pDoc->bbggrr.GetAt(i)); //0x00bbggrr
		pDC->TextOut(1,position,pDoc->GetcsaItem(i));
		position += logFont.lfHeight;
	}
	CView::OnDraw(pDC);
}
Exemple #21
0
bool FNT_HELPERS_API CloneWndFont(CWnd* ip_wnd, CFont* op_newFnt, LONG height, bool bold /*= false*/)
{
 if (!ip_wnd || !op_newFnt)
  return false;
 
 CFont* p_font = ip_wnd->GetFont();
 if (!p_font)
  return false;

 if (op_newFnt->m_hObject)
  op_newFnt->DeleteObject();

 // Create font for 96 DPI.
 LOGFONT lf;
 p_font->GetLogFont(&lf);

 // Set other LOGFONT values as appropriate.
 lf.lfHeight = -MulDiv(height, 96, 72);
 lf.lfWeight = bold ? FW_BOLD : FW_NORMAL;
 CFont tmpFont;
 VERIFY(tmpFont.CreateFontIndirect(&lf));

 // Scale the tmHeight; create target font.
 TEXTMETRIC tm;
 CDC *pDC = ip_wnd->GetDC();
 CFont* fontOld = pDC->SelectObject(&tmpFont);
 pDC->GetTextMetrics(&tm);
 pDC->SelectObject(fontOld);
 tmpFont.DeleteObject();
 ip_wnd->ReleaseDC(pDC);
 DPIAware da;
 lf.lfHeight = da.ScaleY(tm.tmHeight);
 op_newFnt->CreateFontIndirect(&lf);
 return true;
}
Exemple #22
0
int
mfc_edit_view::OnCreate(LPCREATESTRUCT lpcs)
{
  if (CCtrlView::OnCreate(lpcs) != 0)
    return -1;
  GetRichEditCtrl().LimitText(lMaxSize);
  GetRichEditCtrl().SetEventMask(ENM_SELCHANGE | ENM_CHANGE | ENM_SCROLL);
  VERIFY(GetRichEditCtrl().SetOLECallback(&m_xRichEditOleCallback));
  m_lpRichEditOle = GetRichEditCtrl().GetIRichEditOle();
  DragAcceptFiles(0);
  GetRichEditCtrl().SetOptions(ECOOP_OR, ECO_AUTOWORDSELECTION);

  if (!font_init) {
    HFONT f = (HFONT)GetStockObject(ANSI_FIXED_FONT);
        LOGFONT lf;
        if (::GetObject((HGDIOBJ)f, sizeof(LOGFONT), &lf)) {
      fixed_font.CreateFontIndirect(&lf);
    } else {
      return 1;
    }
    font_init = 1;
  }
  GetRichEditCtrl().SetFont(&fixed_font,0);

  WrapChanged();
  ASSERT(m_lpRichEditOle != NULL);
  return 0;
}
Exemple #23
0
/////////////////////////////////////////////////////////////////////////////
// Main UI function.
//    op = 0  ==> run common font dialog
//    op < 0  ==> font size smaller
//    op < 0  ==> font size bigger
//
// Returns zBOOL, whether changed or not, and CFont has new font.
//
zBOOL
ZFontUI::OnChangeFont( CFont& font, int op, CWnd *pWnd, DWORD dwFlags )
{
   ASSERT( font.m_hObject );
   if ( op == 0 )
   {
      // Run common font dialog
      LOGFONT logfont;
      font.GetLogFont( &logfont );
      CFontDialog dlg( &logfont, dwFlags, 0, pWnd );
      dlg.m_cf.nSizeMin = m_nFontPtSizeMin;
      dlg.m_cf.nSizeMax = m_nFontPtSizeMax;
      if ( dlg.DoModal( ) != IDOK )
         return( FALSE );

      // Change the font
      font.DeleteObject( );
      return( font.CreateFontIndirect( &logfont ) );
   }

   // Grow or shrink
   CWindowDC dc( 0 );                   // use screen DC
   int pts = GetFontPointSize( font, dc ); // get point size
   pts = GrowFontSize( pts, op );          // grow ( or shrink )
   if ( pts < m_nFontPtSizeMin || pts > m_nFontPtSizeMax )
      return( FALSE );

   return( SetFontPointSize( font, dc, pts ) );
}
/* Called when the dialog is loaded, in response to the WM_INITDIALOG message.
 */
BOOL CPriceUpdateManualDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// Create warning font and display text
	CFont* pFont = new CFont;
    LOGFONT lf = { 0 };
	CDC* dc = GetDC();
	HDC hdc = dc->GetSafeHdc();
	lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 40);
	lf.lfWeight = FW_BOLD;
    strcpy_s(lf.lfFaceName, "Microsoft Sans Serif");
    pFont->CreateFontIndirect(&lf);
    GetDlgItem(IDC_WARNING)->SetFont(pFont);

	// Set a template for contract specs
	m_ExchangeBox.SetWindowTextA(_T("CME"));
	m_ProductBox.SetWindowTextA(_T("ES"));
	m_ProdTypeBox.SetWindowTextA(_T("FUTURE"));
	m_ContractBox.SetWindowTextA(_T("Mar13"));

	// Delete the font object
	delete pFont;
	pFont = NULL;
	
	return TRUE; // return TRUE unless you set the focus to a control
}
Exemple #25
0
SIZE CMainFrame::GetLineDimentions(char *pLine, int nLen, CDC *pDC)
{
    SIZE size;
    SIZE sizeRet;
    CFont font;
    SDComCfg *pDComCfg;
    bool bRelease = false;
    if (pDC == NULL)
    {
        pDC = GetDC();
        bRelease = true;
    }
    pDC->SetMapMode(MM_TEXT);
    pDComCfg = GetConfig();
    font.CreateFontIndirect(&pDComCfg->m_logfont);
    pDC->SelectObject(font);
    pDC->GetOutputTextMetrics(&m_stFontMetrics);
    GetTextExtentPoint32(pDC->m_hDC, "!", 1, &size);
    sizeRet.cx = ((size.cx + m_stFontMetrics.tmOverhang) * nLen);
    sizeRet.cy = (m_stFontMetrics.tmHeight + m_stFontMetrics.tmExternalLeading);
    if (bRelease)
    {
        ReleaseDC(pDC);
    }
    font.DeleteObject();
    return sizeRet;
}
Exemple #26
0
/////////////////////////////////////////////////////////////////////////////
// Create font from info in the application profile.  Reads info in the form
// facename, ptsize, weight, italic
//
zBOOL
ZFontUI::GetProfileFont( zCPCHAR cpcKey,
                         zCPCHAR cpcVal,
                         CFont&  font,
                         CDC     *pDC )
{
   CWinApp *pApp = AfxGetApp( );
   ASSERT_VALID( pApp );
   CString zs = pApp->GetProfileString( cpcKey, cpcVal );
   if ( zs.IsEmpty( ) )
      return( FALSE );

   LOGFONT lf;
   zmemset( &lf, 0, sizeof( LOGFONT ) );
   lf.lfCharSet = DEFAULT_CHARSET;
   int bItalic;
   int nPtSize;

   // scanf is overkill, but I'm lazy
   if ( sscanf( (zCPCHAR) zs, "%[a-zA-Z ],%d,%d,%d",
                  lf.lfFaceName, &nPtSize, &lf.lfWeight, &bItalic ) != 4 )
   {
      return( FALSE );
   }

   lf.lfHeight = MulDiv( -nPtSize,  // convert ptsize to logical units
       ::GetDeviceCaps( pDC ? pDC->m_hDC : ::GetDC( 0 ), LOGPIXELSY ), 72 );

   lf.lfItalic = bItalic;     // because lf.lfItalic is a BYTE
   font.DeleteObject( );      // bye
   return( font.CreateFontIndirect( &lf ) );
}
Exemple #27
0
void CAutoPFAView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CScrollView::OnPrepareDC(pDC, pInfo);
	pDC->SetMapMode(MM_ANISOTROPIC);
	CPoint ptVpOrg(0, 0);
	ptVpOrg = -GetDeviceScrollPosition();
	pDC->SetViewportOrg(ptVpOrg);
	int xLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSX);
	int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
	pDC->SetWindowExt(xLogPixPerInch,yLogPixPerInch);
	pDC->SetViewportExt( (int)(xLogPixPerInch*m_Scale),
		                 (int)(yLogPixPerInch*m_Scale));
	m_xWindowExt = xLogPixPerInch;
	m_yWindowExt = yLogPixPerInch;
	m_xWindowOrg = 0;
	m_xViewOrg = ptVpOrg.x;
	m_yWindowOrg = 0;
	m_yViewOrg = ptVpOrg.y;
	m_xViewExt = xLogPixPerInch*m_Scale;
	m_yViewExt = yLogPixPerInch*m_Scale;

	CAutoPFADoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CFont Font;
	Font.CreateFontIndirect(&pDoc->m_workSpaceRef.GetFont());
	pDC->SelectObject(&Font);
    pDC->SetBkMode(TRANSPARENT);
	pDC->SetTextAlign(TA_CENTER);
}
//////////////////
// copy a font
//
static void CopyFont(CFont& dst, CFont& src)
{
	dst.DeleteObject();
	LOGFONT lf;
	VERIFY(src.GetLogFont(&lf));
	dst.CreateFontIndirect(&lf);
}
Exemple #29
0
void CMainWindow::OnPaint ()
{
	CRect rect;
	GetClientRect(&rect);


    CPaintDC dc (this);
	dc.SetViewportOrg(rect.Width()/2, rect.Height()/2);
	dc.SetBkMode(TRANSPARENT);

	for (int i = 0; i<300; i+=150)
	{
		LOGFONT lf;
		::ZeroMemory(&lf, sizeof(LOGFONT));
		lf.lfHeight = 160;
		lf.lfHeight = FW_BOLD;
		lf.lfEscapement = i;
		lf.lfOrientation = i;
		::lstrcpy(lf.lfFaceName, _T("Arial"));

		CFont font;
		font.CreateFontIndirect(&lf);

		CFont * pOldFont = dc.SelectObject(&font);
		dc.TextOut(0,0, CString(_T("M")));
		dc.SelectObject(pOldFont);
	}

}
Exemple #30
0
CSize CRollLabel::GetTextSize(LPCTSTR lpszText, CFont* pFont)
{
	CSize size = CSize(0,0);

	LOGFONT lf = {0};
	CFont font;

	if (!pFont || !pFont->GetSafeHandle())
	{
		::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
	}
	else
	{
		pFont->GetLogFont(&lf);
	}

	font.CreateFontIndirect(&lf);

	HDC hDC = ::GetDC(NULL);
	if (hDC)
	{
		CDC* pDC = CDC::FromHandle(hDC);
		if (pDC)
			size = pDC->GetTextExtent(lpszText);

		::ReleaseDC(NULL, hDC);
	}

	return size;
}