Page 1 of 2

Drag Cursor

Posted: Mon Jan 28, 2008 3:07 am
by nageswaragunupudi
In many other applications we see that when a drag cursor is moved over a window ( or control ) that does not accept the drop, the cursor changes as circle with a line inside. The user knows that this control does not accept the drop. Only the window ( control ) which accepts the drop shows the drag cursor in its original shape.

In the programs we develop with FW, the drag cursor looks the same even when it is moved over windows ( controls ) which do not accept drop. ( bDropOver data is nil ).

Is it possible for the Window class's method MouseMove examines the cursor, and if it is a drag cursor originating from some other control, and if the window's bDropOver is nil, to change the shape of cursor to the Circle with Dash cursor ?

Posted: Tue Jan 29, 2008 12:50 am
by James Bott
I would like to know how to do that too.

James

Posted: Tue Jan 29, 2008 9:10 am
by Antonio Linares
We could control that behavior from the MouseMove() method.

We need to check the object that it is below the mouse, and if it is a FWH object, and then check its bDropOver codeblock contents.

Posted: Tue Jan 29, 2008 9:12 am
by Antonio Linares
To locate the control that it is under the mouse we can use WindowFromPoint()

To check if it is a FWH object, we can use:

Code: Select all

hWndCtl = WindowFromPoint( nRow, nCol )

if oWndFromHwnd( hWndCtl ) != nil .and. oWndFromHwnd( hWndCtl ):bDragOver != nil
   SetCursor( ... )
else
   SetCursor( ... )
endif
We could modify METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TControl if we want to turn it a standard behavior

Posted: Tue Jan 29, 2008 9:13 am
by nageswaragunupudi
Yes it is not simple. That is why we need Mr Antonio. He only can make difficult things easy for us.
:)

Posted: Tue Jan 29, 2008 9:19 am
by James Bott
I'm thinking that there must be a Windows API for this since other programs (like Windows Explorer) can communicate with other programs when dragging the cusor because it changes depending on which program the drag cursor is over. When I dragged it over one program it changed to a link icon, and then over another program and it changed to a black circle containing a slash.

James

Posted: Tue Jan 29, 2008 9:19 am
by nageswaragunupudi
Isn't the change in the shape of drag cursor a native behaviour of windows? Dont think all windows are programmed to change the shape. Just a thought.

Posted: Tue Jan 29, 2008 9:22 am
by Antonio Linares
James, Nageswararao,

FWH does not use the standard Windows API for such conversation. We did it that way to have full control on it (as we may need to drop "non standard" Windows contents, as Harbour objects, codeblocks, etc.).

But, on the other hand, we can't drop on non FWH apps cause that :-(

Maybe we should combine both methods

Posted: Tue Jan 29, 2008 9:24 am
by James Bott
NageswaraRao,

>Isn't the change in the shape of drag cursor a native behaviour of windows? Dont think all windows are programmed to change the shape.

I'm not sure what you mean?

I dragged a file from Windows Explorer over IE (FiveWin Forum) and it changed to a link icon, then over an email monitoring program and it changed to the circle/slash. The first two are Microsft programs, but the last one isn't.

James

Posted: Tue Jan 29, 2008 9:26 am
by James Bott
Antonio,

>But, on the other hand, we can't drop on non FWH apps cause that.

I don't understand. We can't because of what? It would be useful if we could drop on non FWH apps.

James

Posted: Tue Jan 29, 2008 9:26 am
by nageswaragunupudi
Mr. James

I meant the same thing as you. I didn't explain it well. That's all
I agree with your earlier post.

Posted: Tue Jan 29, 2008 9:28 am
by James Bott
Antonio,

Opps. I misread your previous message. I thought you said you WERE using the Windows API, not that you weren't using it.

Now I understand.

James

Posted: Tue Jan 29, 2008 9:30 am
by nageswaragunupudi
Mr Antonio

We agree with you that it is FW's own implementation. Now we need further improvisation, whenever you find time. No hurry.

In our own applications we need to make clear to the user where he can drop and where can not.

Posted: Tue Jan 29, 2008 9:37 am
by James Bott
Yes, I am not in a hurry either. Drag & drop is nice to have, but not a requirement. Lots of users never even discover it.

I did build a prototype app that makes use of D&D and it seems to be quite useful to me. But, I know how to use it, so I know where I can drop and where I can't. So, visual "hinting" would be a nice addition.

James

Posted: Tue Jan 29, 2008 12:42 pm
by nageswaragunupudi
Mr Antonio

Here is a suggestion.

At the outset, when the first window is created a NoDropCursor is created either as static variable or class variable in the Window.prg. At the end of the application this cursor is destroyed. Assuming this is done, I suggest the following modification to the MoveMove method of Window.Prg

Code: Select all

METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TWindow

/*
   // original code

   if ::oCursor != nil
      SetCursor( ::oCursor:hCursor )
   else
      CursorArrow()
   endif
*/


   // Proposed Code

   if uDropInto != nil .and. ::bDropOver == nil .and. ::bDropFiles == nil
      SetCursor( oNoDropCursor:hCusor )
   elseif ::oCursor != nil
      SetCursor( ::oCursor:hCursor )
   else
      CursorArrow()
   endif
Please review.