Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Writing Vertical text

Posted on 1998-07-15
2
Medium Priority
?
801 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 200 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

688 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