how to draw text vertical 
Author Message
 how to draw text vertical

I want to draw text vertically  in CView::OnDraw,
How to realize it use CDC::DrawText or other WinApi?
for example:
    I
    w
    a
    n
    t
    t
    o




Wed, 14 Nov 2001 03:00:00 GMT  
 how to draw text vertical
Hi,

Quote:
>I want to draw text vertically  in CView::OnDraw,
>How to realize it use CDC::DrawText or other WinApi?
>for example:
>    I
>    w
>    a
>    n
>    t
>    t
>    o

if there isn't a flag for drawtext (i'm not sure, without looking)
you can set the drawing alignment for the font, in the font's structure.

This means your font needs constructing indirectly, or otherwise.
I reccommend you do this when your window becomes live.

So that you can cache it for the life of your CWnd derived object.
This way you don't slow the OnDraw down having to rebuild the font each
time.

Hope this helps,

Let me know,

Ian

remove nospam- for direct replies.



Wed, 14 Nov 2001 03:00:00 GMT  
 how to draw text vertical

Quote:

>I want to draw text vertically  in CView::OnDraw,
>How to realize it use CDC::DrawText or other WinApi?
>for example:
>    I
>    w
>    a
>    n
>    t
>    t
>    o

     If that's really the way you want the text displayed--with each character
still displayed vertically, but with the text flowing top-to-bottom instead
of left-to-right--then I don't believe that there's any API routine that will
do that for you on the fly.  You'll need to write your own routine that
takes the string you want to display, modifies that string to put each
character to be displayed on a separate line (so "I want to" becomes
"I\r\n \r\nw\r\na\r\nn\r\nt\r\n \r\nt\r\no"), and calls DrawTextEx to display
that modified string.
     If you want the characters to be rotated 90 degrees as well--in other
words, if you want the string to look normal if you rotate your head by 90
degrees to read it--then you do that when you create the font.  For example,
this routine takes whatever font you give it, and returns a font with the same
typeface/size/other info, but that will display text that's rotated by 90
degrees:

CFont * MakeRotatedFont(CFont * pSourceFont)
{
    LOGFONT log;
    if (!pSourceFont->GetLogFont(&log))
        return NULL;
    log.lfEscapement = 900; // rotation, in tenths of degrees
    log.lfOrientation = 900; // same thing
    CFont * pFontToReturn = new CFont();
    if (pFontToReturn) {
        if (!(pFontToReturn->CreateFontIndirect(&log))) {
            delete pFontToReturn;
            return NULL;
        }
    }
    return pFontToReturn;

Quote:
}  

     Now, when you want to display top-to-bottom text, you would use this
rotated font.

     The normal response to this would be "If you expect others to take the
time to answer your question, you can take the time to read the answer here."
But I'm a soft touch sometimes. :)
--
\o\ If you're interested in books and stories with transformation themes, \o\
/o/ please have a look at <URL:http://www.halcyon.com/phaedrus>. Thanks!  /o/
\o\   FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT   \o\
/o/              a cmn++++$ d e++ f+++ h- i++wf p-- sm#                   /o/



Wed, 14 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Drawing text vertical

2. vertical text drawing on CDC

3. vertical text drawing

4. Draw Text Vertical

5. Drawing vertical text

6. Drawing vertical text...how

7. Can't draw vertical text

8. Drawing Text vertical

9. Q: How can I draw vertical text ?

10. Drawing Text with Vertical Orientation

11. Drawing Vertical Text

12. Tab Control Vertical Drawing problem

 

 
Powered by phpBB® Forum Software