Solved

How to use ::TextOut with R2_XORPEN

Posted on 2001-07-18
6
893 Views
Last Modified: 2013-11-20
I use R2_XORPEN for various quick drawing functions, such  as rubber-banding mouses, etc. (i.e., in OnMouseMove, I redraw old position to erase, them draw new position).

I've tried using the same method with text output. For example, to have coordinates text follow the mouse. But ::TextOut doesn't seem to honor the raster op, even when I specify a raster font.

Anyone have a suggestion?

Thanks, W. N. Dickie
0
Comment
Question by:wndickie
  • 3
  • 2
6 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 6295371
try using DrawText() instead....

good luck
0
 

Author Comment

by:wndickie
ID: 6295531
Thanks for the suggestion, but DrawText() doesn't seem to make any difference.
0
 

Author Comment

by:wndickie
ID: 6295559
Thanks for the suggestion, but DrawText() doesn't seem to make any difference.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 6297147
Hi wndickie,

AFAIK no text-output function works with R2_XORPEN in windows. I once implemented this
workaround, maybe you can use it too:

void
OutputText( CDC* pDc, int x, int y, CString& text )
{
 int currMode = pDC->GetROP2();
 COLORREF color = pDC->GetTextColor();

 if ( R2_XORPEN == currMode )
 {
  if ( m_pDc->BeginPath() )
  {
   m_pDc->TextOut( x, y, text );
   if ( m_pDc->EndPath() )
   {
    CBrush brush( color );
    CBrush* pOldBrush = pDC->SelectObject( &brush );
    m_pDc->FillPath();
    pDC->SelectObject( pOldBrush );
   }
  }
 }
 else
 {
  m_pDc->TextOut( x, y, text );
 }
}

This function assumes that any other attributes (colors, fonts, R2-modes) are set before
the function is called. In my application this works for both Win9x/ME and WinNT4/2000.

hope that helps,

ZOPPO
0
 

Author Comment

by:wndickie
ID: 6298683
Works perfectly! Exactly what I was looking for.

Thank's!
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 6298701
you're very welcome ... I'm glad that I could help you,

regards,

ZOPPO
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.

856 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