Solved

How to use ::TextOut with R2_XORPEN

Posted on 2001-07-18
6
871 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 30

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 30

Expert Comment

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

regards,

ZOPPO
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

23 Experts available now in Live!

Get 1:1 Help Now