
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/