FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Drag Cursor
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Drag Cursor
Posted: Tue Jan 29, 2008 03: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Drag Cursor
Posted: Tue Jan 29, 2008 05:49 PM
Understood. Thanks

Hope the following changes to Control.Prg may do:
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Drag Cursor
Posted: Wed Jan 30, 2008 06: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

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Drag Cursor
Posted: Wed Jan 30, 2008 09: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

Continue the discussion