Solved

Writing Vertical text

Posted on 1998-07-15
2
783 Views
Last Modified: 2013-11-20
How do I write text vertically in a window ???
Writing text horizontally is easily done with
CDC::TextOut  or  CDC::DrawText .
0
Comment
Question by:abraham01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
ID: 1319212
You can rotate TrueType fonts at any angle. This is useful for labeling charts and other illustrations. Pls refer to online help at:
Platform, SDK, and DDK Documentation -> Platform SDK -> Graphics and Multimedia Services -> 2-D Graphics -> Fonts and Text -> Using the Font and Text-output functions -> Rotating lines of text
Also pls check this function: CreateFont.
0
 

Author Comment

by:abraham01
ID: 1319213
Answer is right. I had to do little modifications to make
it MFC-style. THANK YOU VERY MUCH.
The modified code fragment follows :
...
...
void CProgView::OnDraw(CDC* pDC)
{
      CProgDoc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);

      // TODO: add draw code for native data here
.
.
RECT rc;
int angle;
CFont hfnt;
LPSTR lpszRotate = "Text to be rotated";
 
/* Allocate memory for a LOGFONT structure. */
 
PLOGFONT plf = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT));
 
 
/* Specify a font typeface name and weight. */
 
lstrcpy(plf->lfFaceName, "Arial");
plf->lfWeight = FW_NORMAL;
 
/* Retrieve the client-rectangle dimensions. */
//GetClientRect(hwnd, &rc);
rc.left = 0;
rc.top = 0;
rc.right = 300;
rc.bottom = 300;
 
/*
 * Set the background mode to transparent for the
 * text-output operation.
 */
 
pDC->SetBkMode(TRANSPARENT);
 
/*
 * Draw the string 36 times, rotating 10 degrees
 * counter-clockwise each time.
 */
 
angle = 2700;
{
    plf->lfEscapement = angle;
    hfnt.CreateFontIndirect(plf);
    CFont * hfntPrev = pDC->SelectObject(&hfnt);
    pDC->TextOut(100, 100,
        lpszRotate, lstrlen(lpszRotate));
    pDC->SelectObject(hfntPrev);
    hfnt.DeleteObject();
}
 
/* Reset the background mode to its default. */
 
pDC->SetBkMode(OPAQUE);
 
/* Free the memory allocated for the LOGFONT structure. */
 
LocalFree((LOCALHANDLE) plf);
 
 ....
 ....
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question