Solved

CRichEditCtrl problem

Posted on 1998-07-24
3
220 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

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: 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…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

948 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

19 Experts available now in Live!

Get 1:1 Help Now