[vtkusers] Drawing 2d crosshair cursor (Win32)

Ted Christiansen ted at caept.com
Tue Sep 3 13:06:06 EDT 2002


Hello,

Anyone have any code for drawing a 2d crosshair cursor, i.e. vertical
and horiztonal line where the intersection is the current mousepointer
position?  I tried using the CDC during the mousemove event which worked
but the lines disappear when you stop moving the mouse:

  // erase previously drawn crosshairs
  Invalidate();

  pOldPen = pDC->SelectObject(&Pen);

  // draw crosshairs
  GetClientRect(&viewrect);
  coords.x = point.x;
  coords.y = viewrect.top;
  pDC->MoveTo(coords);
  coords.y = viewrect.bottom;
  pDC->LineTo(coords);

  // restore old pen
  pDC->SelectObject(pOldPen);

Ted






More information about the vtkusers mailing list