Drag Cursor

Postby Antonio Linares » Tue Jan 29, 2008 3:01 pm

Nageswararao,

The MouseMove() invoked method is the one from the window (or dialog or control) that starts the drag operation, as it captures the mouse.

So we should use WindowFromPoint() and oWndFromHwnd() as I explained, because the mouse may be out of the boundaries of the window (or dialog or control) that started the drag operation.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Tue Jan 29, 2008 5:49 pm

Understood. Thanks

Hope the following changes to Control.Prg may do:
Code: Select all  Expand view
if ::lDrag
   if ::lCaptured
      < ... existing code ... >
      // new code begin
      if oWndOver:hWnd != ( hOver := WindowFromPoint( nCol, nRow ) )
         // oWndOver is static variable
         oWndOver := oWndFromHWnd( hOver )
         if oWndOver:bDropOver == nil  // .and. oWndOver:bDropFiles == nil
            CursorNO()  // c-function
         else
            SetCursor( ::oDragCursor:hCursor )
         endif   
      endif
      // new code ends
   else
     < ... existing code ... ?
   endif

------------------
HB_FUNC( CURSORNO )
{
   hb_retnl( ( LONG ) SetCursor( LoadCursor( 0, IDC_NO ) ) );
}
------------------
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Wed Jan 30, 2008 6:57 am

Finally, with these modifications to MouseMove method of Control.Prg I am able to get what we wanted.

Declare module scope static variable hWndOver

Code: Select all  Expand view
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TControl

   local nOldRow, nOldCol
   local hOver, oWndOver, aPoint  // new locals

  < ......... keep the existing code .....>

   else
      if ::lMouseDown .and. ;
         ( Abs( nRow - ::nLastRow ) > 5 .or. Abs( nCol - ::nLastCol ) > 5 ) ;
         .and. ! Empty( ::oDragCursor )
//         SetCursor( ::oDragCursor:hCursor )     // original code commented out
         if ! lDragging
            ::DragBegin( nRow, nCol, nKeyFlags )
            // new code begin
            hWndOver = ::hWnd
            SetCursor( ::oDragCursor:hCursor )
            // new code end
         else
            if ValType( ::bMMoved ) == "B"
               Eval( ::bMMoved, nRow, nCol, nKeyFlags, .T. )
            endif
         endif

         // new code begin
         DEFAULT hWndOver := ::hWnd
         aPoint = { nRow, nCol }
         aPoint = ClientToScreen( ::hWnd, aPoint )

         hOver := WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] )

         if hOver != hWndOver
            hWndOver = hOver
            oWndOver = oWndFromHWnd( hOver )
            if oWndOver == nil .or. oWndOver:bDropOver == nil
               CursorNO()
            else
               SetCursor( ::oDragCursor:hCursor )
             endif
        endif
        // new code end

      else
         return Super:MouseMove( nRow, nCol, nKeyFlags )
      endif
   endif

return 0

//------------
// In this or some other module, preferably in Cursors.c
//

#pragma BEGINDUMP

#include "hbapi.h"
#include <windows.h>

HB_FUNC( CURSORNO )
{
   hb_retnl( ( LONG ) SetCursor( LoadCursor( 0, IDC_NO ) ) );
}

#pragma ENDDUMP


Mr Antonio may please see if this seems to be okay.
It is working for me, but I dont know if the code can be improved or can create any unexpected problems.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Wed Jan 30, 2008 9:44 am

Nageswararao,

You are getting better day by day :-)

Please email me your modified control.prg, thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Horizon and 72 guests