CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Location
    Minneapolis, Minnesota
    Posts
    33

    MFC Printing from Bottom to Top (vertically) how to?

    I'm looking to use MFC's DrawText or other API to print text on the left side of a graph vertically from bottom to top (90 degrees turn). I'm finding little help for it on the web. This can be done in .NET 2.0, but haven't found a way in MFC C++. Any help?

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: MFC Printing from Bottom to Top (vertically) how to?

    Before drawing the text, select in the device context a font with desired "escapement".
    Here is an example:
    Code:
    void CMyCoolView::OnDraw(CDC* pDC)
    {
       // ...
       CFont font;
       LONG lfHeight = -::MulDiv(14, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);
       LONG lfEscapement = 900;
       font.CreateFont(lfHeight,
                       0, 
                       lfEscapement,  // Escapement 
                       0,             // Orientation
                       FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 
                       OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                       FF_ROMAN|DEFAULT_PITCH, _T("Times New Roman"));
    
       CFont* pOldFont = pDC->SelectObject(&font);
       pDC->TextOut(50, 150, CString(_T("Baba Safta")));
       pDC->SelectObject(pOldFont);
    }
    Fore more info about font escapement and orientation take a look at LOGFONT strucure documentation in MSDN.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Dec 2006
    Location
    Minneapolis, Minnesota
    Posts
    33

    Re: MFC Printing from Bottom to Top (vertically) how to?

    Great posting. This worked well. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured