Re: vertical text not drawn at correct location
From: Ian (ibnospam_at_yahoo.com)
Date: 01/03/05
- Next message: Olaf van der Spek: "XP-style CFileDialog in VC6?"
- Previous message: Webster: "Can I trap all errors in a MFC MDI application?"
- In reply to: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 3 Jan 2005 17:42:06 -0500
Hello Check,
Thank you. Your suggestions works in the sample code but not my
application. I'll put on the coffee and donuts and try to work through this
tonight. Thanks again.
Ian
"CheckAbdoul" <checkabdoul at mvps dot org> wrote in message
news:%23mKd%23Sc8EHA.2788@TK2MSFTNGP15.phx.gbl...
> Your 'oFont' object gets destroyed once the function exits. Make
> 'oFont'
> a member variable of your 'CMyView' class.
>
> --
> Cheers
> Check Abdoul [VC++ MVP]
> -----------------------------------
>
> "Ian" <ibnospam@yahoo.com> wrote in message
> news:725Cd.7945$7z.535168@weber.videotron.net...
>> 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: Olaf van der Spek: "XP-style CFileDialog in VC6?"
- Previous message: Webster: "Can I trap all errors in a MFC MDI application?"
- In reply to: CheckAbdoul: "Re: vertical text not drawn at correct location"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|