redrawing while mouse button is moving 
Author Message
 redrawing while mouse button is moving

Hello,
    I have a problem. I need to redraw a picture while mouse is moving over
a view.
1.    When the left button is pressed i hide the mouse cursor, i clip the
mouse movement and
i save mouse position.
2.    When the mouse is moved, i do some math operations and i restore mouse
position. Then
i invalidate the rect of the picture so it's repainted. I also change some
values in the document
and i uptade the view.
3.    When the left button is pressed i show the cursor again.

    The problem is that the picture is redraw, and the document is updated,
only at point 3.

This is the code:

//(class CTrazmodelView : public CFormView)

void CTrazmodelView::OnLButtonDown(UINT nFlags, CPoint point)
{
    if (!mov_pos)
    {
      mov_pos=TRUE;
      tpoint=point;
      ShowCursor(FALSE);
      CRect clip(pos); // <- pos is the rect of the picture
      ClientToScreen(&clip);
      ClipCursor(&clip);
    }
    else
    {
      mov_pos=FALSE;
      ShowCursor(TRUE);
      ClipCursor(NULL);
    }

Quote:
}

void CTrazmodelView::OnMouseMove(UINT nFlags, CPoint point)
{
    if (mov_pos)
    {
        // Some math operations and changes to the document
        // Updating some edit boxes
         UpdateData(FALSE);
         // Invalidating so the picture is redraw (nothing is done)
         InvalidateRect(&pos);
         // Sending mouse cursor to original position
         point=tpoint;
         ClientToScreen(&point);
         SetCursorPos(point.x,point.y);
    }
  CFormView::OnMouseMove(nFlags, point);

Quote:
}

Thanks in advance for your help.


Sat, 01 May 2004 05:07:03 GMT  
 redrawing while mouse button is moving


Quote:
> Hello,
>     I have a problem. I need to redraw a picture while mouse is moving
over
> a view.
...
>          // Invalidating so the picture is redraw (nothing is done)
>          InvalidateRect(&pos);

InvalidateRect only marks the rectangle as invalid. It will only be drawn
when all other messages in the message queue have been processed. If you
want do update your window immediately, you have to tell windows to do so by
calling UpdateWindow after InvalidateRect has been called.

Regards
    Heinz



Sat, 01 May 2004 17:54:51 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC++ move button by mouse in runtime

2. Handle mouse being moved over a dialog button?

3. trap mouse move event on a button.

4. Why am I getting Mouse Move Event with every Mouse Click event?

5. how to get mouse messages for 6 button mouse

6. Button colour & Detecting mouse over button

7. [Fwd: Right mouse button and depressed button]

8. Holding the mouse button down and moving the mouse using code;

9. i want to move button on the window wheneven i Left click mouse, movemouse and mouse up

10. Q on both PostMessage and Redrawing a Button.

11. Move the mouse cursor by keyboard.

12. mouse_event for mouse move is not working properly.

 

 
Powered by phpBB® Forum Software