Solved

How to use ::TextOut with R2_XORPEN

Posted on 2001-07-18
6
879 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
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.

 
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

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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 124
Generic progress indicator 6 113
difference between String.subString() and String.subSequence() 6 177
Line meaning 9 82
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

867 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

22 Experts available now in Live!

Get 1:1 Help Now