Solved

Writing Vertical text

Posted on 1998-07-15
2
739 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now