Solved

Writing Vertical text

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

778 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