Solved

Writing Vertical text

Posted on 1998-07-15
2
727 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

15 Experts available now in Live!

Get 1:1 Help Now