?
Solved

How to use ::TextOut with R2_XORPEN

Posted on 2001-07-18
6
Medium Priority
?
931 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:Meir Rivkin
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Accepted Solution

by:
Zoppo earned 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

830 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