|
// MyCell - version 1.0
// Written by Yanxueming <yanxm2003@hotmail.com>
// Copyright (C) 2006-2007
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
#pragma once
//#include "StyleDesc.h"
namespace mycell{
struct CellFontSetup
{
CDCHandle dc;
HFONT hOldFont,hNewFont_;
COLORREF oldTextColor;
CellFontSetup(HDC hDC,const LOGFONT* pLogFont,COLORREF clrFont)
:dc(hDC),hOldFont(NULL)
{
int mode=SetMapMode(hDC,MM_TEXT);
LONG lfHeight=0;
if(pLogFont){
lfHeight=pLogFont->lfHeight;
if(MM_TEXT==GetMapMode(hDC))
((LOGFONT*)pLogFont)->lfHeight=-MulDiv(pLogFont->lfHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);
hNewFont_=CreateFontIndirect(pLogFont);
if(hNewFont_){
oldTextColor=dc.SetTextColor(clrFont);
hOldFont=dc.SelectFont(hNewFont_);
}
}
if(mode)
SetMapMode(hDC,mode);
if(pLogFont)
((LOGFONT*)pLogFont)->lfHeight=lfHeight;
}
~CellFontSetup()
{
if(hOldFont){
dc.SelectFont(hOldFont);
dc.SetTextColor(oldTextColor);
}
if(hNewFont_)
DeleteObject(hNewFont_);
}
};
}//namespace mycell
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.