tags:

views:

300

answers:

1

hi,

I am creating a User Control in C#.Net 2.0. I have to apply drag and Drop Images in between these controls. I have done drag and drop effect.

But the problem is that i have to show the control movement while mouse dragging. For that i am drawing a rectangle on screen with the help of ControlDraw.DrawReversibleFrame()

Problem is that while drawing with mouse move event Rectangle is drawn over whole screen and because no repaint on screen it exist on screen.

So please can anybody tell me either how to clear drawn graphics or how to force to redraw screen.

+1  A: 

You must draw the 'reversable' frame in the same position as previously to reverse it, before drawing the next frame in the new position.

The pseudo-code is:

bool prev_rev_frame = false;
Rect prev_rev_rect;

...

void on_mouse_move() {
  if(prev_rev_frame)
    Control.drawReversableFrame(prev_rev_rect);
  Rect new_rev_rect = ....
  Control.drawReversableFrame(new_rev_rect);
  prev_rev_frame = true;
  prev_rev_rect = new_rev_rect;
}

But in general, I recommend changing the mouse cursor to a drag-drop icon or a thumbnail of the image would be far more appropriate.

Will
thanks Will,ControlPaint.DrawReversibleFrame() - It draws a frame on screen with reverse color than its background.Here i have no issue.I can change the mouse cursor but is not my requirement.Requirement is to show the user control is dragging.thanks
prashant