?
Solved

How to use ::TextOut with R2_XORPEN

Posted on 2001-07-18
6
Medium Priority
?
910 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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