CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    1,798

    Controlling vertical text using GDI+

    GDI+ provides for the output of vertical text, as shown by the following code. (CChart is an MFC class derived from CStatic)

    Code:
    void CChart::DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
    {
       Graphics graphics(hdc);
    
       // Initialize arguments.
       	FontFamily fontFamily(L"Arial");
    	Font myFont(&fontFamily, 18, FontStyleBold, UnitPixel);
    
    	StringFormat format;
    	format.SetFormatFlags(StringFormatFlagsDirectionVertical|StringFormatFlagsDirectionRightToLeft);
    	SolidBrush blackBrush(Color(255, 0, 0, 0));
    
    	// Draw string.
    	graphics.DrawString(string, 11, &myFont, layoutRect, &format, &blackBrush);
    
    	// Draw layoutRect.
    	//graphics.DrawRectangle(&Pen(Color::Black, 3), layoutRect);
    
    }// DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
    Now, while this code works, the vertical text is always written from top to bottom (unable to render here). I would prefer the vertical text to be rendered from bottom to top, that is, what is conventionally left to right reading becomes bottom to top. IMHO, it just looks better.

    The format flags I have tried here have no effect. Does anyone know how to render vertical text to read bottom to top using GDI+ ?

    mpliam

  2. #2
    Join Date
    Oct 2005
    Posts
    230

    Re: Controlling vertical text using GDI+

    I may be misunderstanding your question (its late here an im tied )

    If your talking about the actual output why not just reverse the string and then pass that to the same vertical text function..?

    HTH
    Learning somthing new every day!

  3. #3
    Join Date
    May 2002
    Posts
    1,798

    Re: Controlling vertical text using GDI+

    Thankyou for your response.

    Good idea. I should have mentioned that I had tried that. It doesnt work. It produces the the reverse string from the top down, so that the letters are backwards, but the output is still top down. If you try it with the code I've provided, you will see what I mean.

    I have seen GDI output with vertical text printed 'bottom-up' (I can't think of a better way to describe it), so I am certain that it can be accomplished, but I cannot locate the code.
    mpliam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured