May 11, 2024, 12:27:55 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Drag in CControl?

Started by Allan, June 29, 2009, 07:36:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Allan

I have been trying to start Drag and Drop in a Custom Control which is based on the code from marquee.

Everything is working OK except in the Mouse Move area of the Control

It just does not actiave the drag and drop Cursor.

Maybe Drag and Drop cannot go in a C/Control???

Here is the message handler

SUB ImageHandler
POINTER _pWin
UINT _hImg
Select @MESSAGE
CASE @IDLBUTTONDN
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
IF(#<IMGWINDOW>_pWin.style = D_SRC)
#<IMGWINDOW>_pWin.dragstart = 0
ENDIF
CASE @IDMOUSEMOVE
if @QUAL & 1
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
IF(#<IMGWINDOW>_pWin.style = D_SRC)
#<IMGWINDOW>_pWin.dragstart += 1
IF #<IMGWINDOW>_pWin.dragstart = 3
_hImg = #<IMGWINDOW>_pWin.hBmp
' -----------------------------------------------------------------------------------------
StartDragDrop(#<WINDOW>@hitwindow.hwnd,CF_BITMAP,&_hImg,LEN(_hImg),DROPEFFECT_MOVE)
' -----------------------------------------------------------------------------------------
#<IMGWINDOW>_pWin.dragstart = 0
ENDIF
ENDIF
ENDIF
CASE @IDDRAGFEEDBACK
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
IF(#<IMGWINDOW>_pWin.style = D_SRC) THEN return FALSE
case WM_NCDESTROY
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
if(_pWin)
_RemoveProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
delete _pWin
endif
Case @IDPAINT
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
int l,t,w,h
GetClientSize #<WINDOW>@hitwindow,l,t,w,h
_hImg = #<IMGWINDOW>_pWin.hBmp
if _hImg
ShowImage(#<WINDOW>@hitwindow,_hImg,@IMGSCALABLE,0,0,w,h,SRCCOPY)
ENDIF
ENDSELECT
RETURN
ENDSUB


Or maybe I have not done it correct for C/Control.  It works fine in an ordinary window - the cursor changes to the CIRCLE with the Line through BUT here in the control it just remains as an ordinary cursor???

Can it be done?



Ionic Wind Support Team

Allan,
verify that the code is getting called by spinkling some debugprint statements.

debugprint("Starting Drag Drop")
StartDragDrop(...

Then run it in the debugger. 

Paul.
Ionic Wind Support Team

Allan

June 29, 2009, 09:58:55 PM #2 Last Edit: June 29, 2009, 10:18:04 PM by Allan
I have been using debugprint all the way through the development to confirm settings and it has proved OK until the StartDragDrop.

Here is the Debugprint after trying the Drag and image.

QuoteStarting debug session...
Loading DLL: ntdll.dll
Loading DLL: C:\WINDOWS\system32\kernel32.dll
Loading DLL: C:\WINDOWS\system32\USER32.DLL
Loading DLL: C:\WINDOWS\system32\GDI32.dll
Loading DLL: C:\WINDOWS\system32\OLE32.DLL
Loading DLL: C:\WINDOWS\system32\ADVAPI32.dll
Loading DLL: C:\WINDOWS\system32\RPCRT4.dll
Loading DLL: C:\WINDOWS\system32\Secur32.dll
Loading DLL: C:\WINDOWS\system32\msvcrt.dll
Loading DLL: C:\WINDOWS\system32\COMCTL32.DLL
Loading DLL: C:\WINDOWS\system32\OLEPRO32.DLL
Loading DLL: C:\WINDOWS\system32\OLEAUT32.dll
Loading DLL: C:\WINDOWS\system32\CRTDLL.DLL
Loading DLL: C:\WINDOWS\system32\uxtheme.dll
Loading DLL: C:\WINDOWS\system32\asycfilt.dll
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
Starting StartDragDrop ...
After StartDragDrop and b4 setting dragstart = 0 -  3
The program 'D:\My EBasic Workplace\Image Control D and D\ImageDD.exe' exited with code: 0


This is the code where the debugprints are placed for the above.

CASE @IDMOUSEMOVE
if @QUAL & 1
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
IF(#<IMGWINDOW>_pWin.style = D_SRC)
#<IMGWINDOW>_pWin.dragstart += 1
IF #<IMGWINDOW>_pWin.dragstart = 3
_hImg = #<IMGWINDOW>_pWin.hBmp
DEBUGPRINT "Starting StartDragDrop ..."
' -----------------------------------------------------------------------------------------
StartDragDrop(#<WINDOW>@hitwindow.hwnd,CF_BITMAP,&_hImg,LEN(_hImg),DROPEFFECT_MOVE)
' -----------------------------------------------------------------------------------------
DEBUGPRINT "After StartDragDrop and b4 setting dragstart = 0 - " + STR$(#<IMGWINDOW>_pWin.dragstart)
#<IMGWINDOW>_pWin.dragstart = 0
ENDIF
ENDIF
ENDIF


The debugprint is showing that it has entered into the placve wher StartDragDrop is and the second debugprint shows that it has passed the StartDragDrop Function and has obtained the required 3 for the dragstart count.

The cursor is not changing as I drag over the Image in the control/window.

EDIT

I aslos put a debugprint in the feedback to see if it was receiving any data.

CASE @IDDRAGFEEDBACK
DEBUGPRINT "IDRAGFEEDBACK = " + STR$(@LPARAM)
_pWin = _GetProp(#<WINDOW>@hitwindow.hwnd,"IMGWINDOW")
IF(#<IMGWINDOW>_pWin.style = D_SRC) THEN return FALSE


The Debugprint was not printing anything out at all whereas in a normal window it would return a  0  until it was over a window that could receive the drop and then it changes to 2. 

Nothing coming back in this event at all in the CControl.

Allan

Ionic Wind Support Team

Have you registered a drop target anywhere in the program?  Or are you trying to drag and drop to a different program? 

If it is the latter then you'll probably need to call OleInitialize in the source program:

declare import,OleUninitialize()
OleInitialize()

Paul.

Ionic Wind Support Team

Allan

No I have not done that as yet. It was the next thing to do.

Will get back to you after doing so.

Allan




Allan

OK Paul that was the problem!

Now with a Registered Drop Target the CURSOR starts correctly in the StartDragDrop function.

Thank you for your help.

Allan


Ionic Wind Support Team

Glad I could help.  It was actually the last thing I could think of since registering the window as a drop target calls OleInitialize, and drag and drop doesn't work without OLE.

Paul.
Ionic Wind Support Team