How to draw a Line with XOR, OR, AND Raster Operation ?

  • Thread starter TECHNIMEX Vietnam
  • Start date
T

TECHNIMEX Vietnam

In VB6, I use DrawMode to indicate the XOR when need to draw a XOR line
against the background image. But in .NET CF, they said that I must use
interop !?

I don't want to relate to GDI more.

Could you tell me a sample to draw a XOR line using CF (for my smartphone) ?

Thank you
 
M

Mike Dimmick

I realise this is something of a philosophical answer:

http://www.interact-sw.co.uk/graphics/xorconsideredharmful/

The approach to take with CF is simply to paint what should be there, then
the rubber-band selection rectangle. GDI+ and the System.Drawing API don't
offer different raster modes for drawing, either on CF or on the desktop
framework.

If you still want to go with XOR, you'll need to get hold of the control's
window handle
(http://wiki.opennetcf.org/ow.asp?CompactFrameworkFAQ/GettingAControlHandle)
then get a device context for the control's drawing surface using GetDC
(http://www.pinvoke.net/default.aspx/user32.GetDC, change DllImport to
"coredll.dll"). Then call SetROP2
(http://www.pinvoke.net/default.aspx/gdi32.SetROP2) with R2_XORPEN, call
Rectangle (http://www.pinvoke.net/default.aspx/gdi32.Rectangle) to draw,
SetROP2 again to set back to what the first call returned, then ReleaseDC.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top