vertical text not drawn at correct location
From: Ian (ibnospam_at_yahoo.com)
Date: 01/03/05
- Next message: Neelesh K J Jain: "Re: Beep Sound while executing the application"
- Previous message: Vivek Nair: "Re: Checking path validity"
- Next in thread: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Reply: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 3 Jan 2005 00:49:51 -0500
The code below illustrates the problem I am having. A rectangle is drawn in
the center of the display. Text is suppose to be drawn at a 270 degree
angle and centered in the middle of the rectangle. Instead, the text is
always drawn to the far to the left of the rectangle. If I change text
escapement to 0 degrees then the text is correctly centered. Can someone
suggest what mistake I am making? Thanks in advance.
Ian
CMyView::OnDraw( CDC *pDC )
{
// create font
CFont oFont;
LOGFONT oLF;
memset( &oLF, 0, sizeof(oLF) );
oLF.lfHeight = 25;
oLF.lfOrientation = 2700; // 270 degrees
oLF.lfEscapement = 2700;
VERIFY( oFont.CreateFontIndirect( &oLF ) );
CFont *pOldFont = pDC->SelectObject( &oFont );
ASSERT( pOldFont );
// set drawing rectangle
CRect oCR;
GetClientRect( &oCR );
CRect oR(
oCR.CenterPoint().x-30, oCR.top,
oCR.CenterPoint().x+30, oCR.bottom
);
pDC->DPtoLP( &oR );
// draw rectangle
CBrush oBrush( RGB(0,0,0) );
pDC->FrameRect( &oR, &oBrush );
// draw text
pDC->SetTextColor( RGB(0,0,0) );
UINT uFormat = DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOCLIP;
pDC->DrawTextEx( _T("sample text"), &oR, uFormat, NULL );
// clean up
pDC->SelectObject( pOldFont );
}
- Next message: Neelesh K J Jain: "Re: Beep Sound while executing the application"
- Previous message: Vivek Nair: "Re: Checking path validity"
- Next in thread: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Reply: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|