Re: vertical text not drawn at correct location

From: Ian (ibnospam_at_yahoo.com)
Date: 01/03/05


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 );
>> }
>>
>>
>>
>
>



Relevant Pages

  • Re: vertical text not drawn at correct location
    ... Your 'oFont' object gets destroyed once the function exits. ... "Ian" wrote in message ... Text is suppose to be drawn at a 270 degree ... > angle and centered in the middle of the rectangle. ...
    (microsoft.public.vc.mfc)
  • Re: Printing the whole whole printable area
    ... your rectangle are being drawn just outside of the printable area. ... need to inset the right and bottom by a pixel to get the line into the ... But at the very least, you need to understand that if you try to draw a rectangle that is the same exact width and height as what you believe to be the valid area for drawing, the right and bottom edges will not be drawn. ... For the record, the following code, when I use it with the Office Document Image Writer print driver, it prints a frame exactly the way you want: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Draw a path with a Pen which has a width of 2?
    ... For a circle or rectangle, your drawn area will be larger than the geometry ... > The border can also have different shapes such as Round, Circle, ... When I use a width of 2, the path is not drawn correctly. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Create an object surface using GDI+
    ... You didn't look closely enough at the sample code. ... in the onclick event or any of the ... that the object should contain when drawn. ... > user has clicked not just based in rectangles, like here, but on rectangle ...
    (microsoft.public.dotnet.framework.windowsforms)
  • vertical text not drawn at correct location
    ... the center of the display. ... Text is suppose to be drawn at a 270 degree ... angle and centered in the middle of the rectangle. ... CRect oCR; ...
    (microsoft.public.vc.mfc)