Solved

CRichEditCtrl problem

Posted on 1998-07-24
3
217 Views
Last Modified: 2013-11-20
void CGText::DrawText(CDC *pDC)
{
      CRect rect, r;
      FORMATRANGE fr;
      rect = m_position;
      rect.NormalizeRect();
      r = rect;
      r.DeflateRect(1, 1);
      pDC->FillSolidRect(r, m_logbrush.lbColor);
      CPoint oldOrg = pDC->SetWindowOrg(rect.left, rect.top);
// 30 - the magic number
      rect.top = (rect.top + 1) * 30;
      rect.left = (rect.left + 1) * 30;
      rect.bottom = (m_position.Height() - 3) * 15 + rect.top;
      rect.right = (m_position.Width() - 3) * 15 + rect.left;

      fr.hdc = pDC->m_hDC;
      fr.hdcTarget = pDC->m_hDC;
      fr.rc = rect;
      fr.rcPage = rect;
      fr.chrg.cpMin = 0;
      fr.chrg.cpMax = -1;
      
      m_pHyper->FormatRange(&fr);
      pDC->SetWindowOrg(oldOrg);
}
 I am trying to display CRichEditCtrl in my view class.
The function above is member of class that represent the text in the document. The "magic number" 30 is realy magic, if I change it text will not move correctly on screen. Online help says that rect shoud be in TWIPS, but I can't convert it. pDC have MM_ANISOTROPIC. Please help.

Windows NT 4.0 Workstation; Visual C++ 5.0
0
Comment
Question by:cyrilbdt
  • 2
3 Comments
 
LVL 2

Author Comment

by:cyrilbdt
ID: 1319695
Edited text of question
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 400 total points
ID: 1319696
There are 1440 twips to a logical inch. You can also use CDC::DPtoLP to convert your device points in to logical points, then do a little math to convert logical points into twips.


0
 
LVL 2

Author Comment

by:cyrilbdt
ID: 1319697
m_position is in logical coordinates and DPtoLP will not work
(I tried it)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

16 Experts available now in Live!

Get 1:1 Help Now