I am encountering and issue where drawing a control using both Direct3D and .Net Framework Graphics causes conflict.
Strangely enough this only occurs with Windows Vista. Windows XP works fine. Pleaes see the attached screen shots.
screen shots
This is the execution process:
MouseMove calls Invalidate() on the control.
Paint event is called.
Inside MyOnPaint(), I
1) Render 3D scene using native Direct3D, using the HWND from the control.
2) Draw a selection rectangle using Graphics::DrawRectangle()
Any Graphics::Draw functions overlay the Direct3D scene with visible bounding rectangles and trails.
The only way I can get the image to look correct is surround the Graphics::DrawRectangle with:
Point screenPoint = win->PointToScreen(Point(0,0));
graphics->CopyFromScreen(screenPoint.X, screenPoint.Y, 0,0, win->Size);
graphics->DrawRectangle(pen, rectangle);
graphics->Flush(Drawing::Drawing2D::FlushIntention::Sync);
It appears the GDI or Graphics code buffers the draw commands and applies them at some point.
This flush and sync code seems to synchronize them. The Graphics functions still leave white bounding boxes.
Another alternative for me is to render the selection rectangle with
ControlPaint::DrawReversibleFrame(rectangle, Color::Transparent, FrameStyle::Dashed);
However I still need to flush and sync which drops the effective frame rate from say 200fps to 15fps.