From: Stef M. <s.m...@ru...> - 2009-01-16 16:18:12
|
CL wrote: > Hi Shef > > Now I understand more about the problem you described. > > Actually vPython uses client windows coordinates in its mouse > management, but it has the assumption that it is the top-level window > when restoring the mouse cursor position after dragging. Somehow it > will cause a crash in some cases. I've fixed that portion and I am not > able to crash it any more. (May be I am not trying hard enough 8-) > > that's great news !! And I would love to try it, but the code below looks like C to me, and that's beyond my knowledge :-( cheers, Stef > In windisplay.cpp > > LRESULT > display::on_mouse( WPARAM wParam, LPARAM lParam) > ... > if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width > - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { > mouse.report_setcursor( view_width/2, view_height/2 ); > SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); > } > if (was_locked && !mouse.is_mouse_locked()) { > mouse.report_setcursor( old_x, old_y ); > SetCursorPos( view_x + old_x, view_y + old_y ); > } > ... > > > Both SetCursorPos call will move the mouse to an incorrect coordinate. > It is because WM_MOVE message is not sending to vPython any more after > it is reparented. (also, may be window_x and window_y shall be used > instead of view_x, view_y). > > Changing it to: > > if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width > - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { > mouse.report_setcursor( view_width/2, view_height/2 ); > //SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); > POINT pt; > pt.x = pt.y = 0; > ClientToScreen(widget_handle, &pt); > SetCursorPos( pt.x + view_width/2, pt.y + view_height/2 ); > } > if (was_locked && !mouse.is_mouse_locked()) { > mouse.report_setcursor( old_x, old_y ); > //SetCursorPos( view_x + old_x, view_y + old_y ); > POINT pt; > pt.x = pt.y = 0; > ClientToScreen(widget_handle, &pt); > SetCursorPos( pt.x + old_x, pt.y + old_y ); > } > > Now the mouse cursor is correctly positioned after dragging, no matter > if it has been reparented or not. Seems no more crashes now. > > CL > > > Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629. The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629. |