Initial
This commit is contained in:
53
mdiwin/FONT.CPP
Normal file
53
mdiwin/FONT.CPP
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <string.h>
|
||||
#include <mdiwin/font.hpp>
|
||||
|
||||
Font::Font(HWND hWnd,int nWidth,int nHeight)
|
||||
: mhWnd(hWnd), mhdc(::GetDC(hWnd))
|
||||
{
|
||||
int nEscape=0;
|
||||
int nOrient=0;
|
||||
int nWeight=FW_ULTRALIGHT;
|
||||
BYTE nItalic=0;
|
||||
BYTE nUnderline=0;
|
||||
BYTE nStrikeOut=0;
|
||||
BYTE nCharSet=ANSI_CHARSET;
|
||||
BYTE nOutputPrecision=OUT_CHARACTER_PRECIS;
|
||||
BYTE nClipPrecision=CLIP_DEFAULT_PRECIS;
|
||||
BYTE nQuality=PROOF_QUALITY;
|
||||
BYTE nPitchAndFamily=DEFAULT_PITCH;
|
||||
LPCSTR lpszFace="MS Serif";
|
||||
|
||||
mhFont=::CreateFont(nHeight,nWidth,nEscape,nOrient,nWeight,nItalic,
|
||||
nUnderline,nStrikeOut,nCharSet,nOutputPrecision,
|
||||
nClipPrecision,nQuality,nPitchAndFamily,lpszFace);
|
||||
}
|
||||
|
||||
Font::~Font()
|
||||
{
|
||||
::DeleteObject(mhFont);
|
||||
::ReleaseDC(mhWnd,mhdc);
|
||||
}
|
||||
|
||||
void Font::DrawText(int xStart,int yStart,const char *lpStr)const
|
||||
{
|
||||
HFONT hOldFont;
|
||||
|
||||
hOldFont=(HFONT)::SelectObject(mhdc,mhFont);
|
||||
::TextOut(mhdc,xStart,yStart,(LPSTR)lpStr,::strlen(lpStr));
|
||||
::SelectObject(mhdc,hOldFont);
|
||||
}
|
||||
|
||||
void Font::DrawText(int xStart,int yStart,const char *lpStr,COLORREF bkColor,COLORREF textColor)const
|
||||
{
|
||||
HFONT hOldFont;
|
||||
COLORREF oldBkColor;
|
||||
COLORREF oldTextColor;
|
||||
|
||||
hOldFont=(HFONT)::SelectObject(mhdc,mhFont);
|
||||
oldBkColor=::SetBkColor(mhdc,bkColor);
|
||||
oldTextColor=::SetTextColor(mhdc,textColor);
|
||||
::TextOut(mhdc,xStart,yStart,(LPSTR)lpStr,::strlen(lpStr));
|
||||
::SetBkColor(mhdc,oldBkColor);
|
||||
::SetTextColor(mhdc,oldTextColor);
|
||||
::SelectObject(mhdc,hOldFont);
|
||||
}
|
||||
Reference in New Issue
Block a user