I have done lots of drag and dropping on VFP apps in the past. But tonight I seem unable to make OLE Drag and Drop drag an image from a browser into a VFP form.
First, I have read up on many of the posts in this forum, about dragging images. I even found Jim Booth's tutorial, one I read many many years ago and a few minutes ago. It did not help. So here are the tests.
1.- I can drag in an image from any Windows subdirectory into the image object.
2.- I cannot drag in an image from a browser.
I found out that oDataObject.GetFormat(13) is what the Browser returns and I accommodate for that. That format indicates UNICODE.
And this is how it comes in for one specific image, when I drag the image into a TextBox:
"fig.06x021ntbrentrap/segami/moc.spit-ket.www//
tth"
CONFUSED?
In reverse it reads ""... clearly I dragged one of your pictures in... but it does that for all images.
So, I can flip it and play with it all I like, but it still does not get me the image. If I was not exhausted from fighting it for the last 2 hours, I would not bother you, but maybe one of you has a bright idea on how to fetch this image from the Website and plant it into my Image object. Can I find this file in the cache? I thought that all files go into the Browser cache, but I cannot find it anywhere on my disks.
CODE IS BELOW________________________________________________________________
The image's OLEDragDrop:
The code in OLEDOver:
First, I have read up on many of the posts in this forum, about dragging images. I even found Jim Booth's tutorial, one I read many many years ago and a few minutes ago. It did not help. So here are the tests.
1.- I can drag in an image from any Windows subdirectory into the image object.
2.- I cannot drag in an image from a browser.
I found out that oDataObject.GetFormat(13) is what the Browser returns and I accommodate for that. That format indicates UNICODE.
And this is how it comes in for one specific image, when I drag the image into a TextBox:
"fig.06x021ntbrentrap/segami/moc.spit-ket.www//
CONFUSED?
In reverse it reads ""... clearly I dragged one of your pictures in... but it does that for all images.
So, I can flip it and play with it all I like, but it still does not get me the image. If I was not exhausted from fighting it for the last 2 hours, I would not bother you, but maybe one of you has a bright idea on how to fetch this image from the Website and plant it into my Image object. Can I find this file in the cache? I thought that all files go into the Browser cache, but I cannot find it anywhere on my disks.
CODE IS BELOW________________________________________________________________
The image's OLEDragDrop:
Code:
LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord
LOCAL aFiles[ 1 ], nFiles, i, cExt
DO CASE
CASE oDataObject.GetFormat( 15 )[b] OR [COLOR=#EF2929]oDataObject.GetFormat( 13 )[/color][/b]
* I can handle file data
* Get the file data into an array
IF oDataObject.GetData( 15, @aFiles )
* If we got any set the count
nFiles = alen( aFiles, 1 )
ELSE
* Set the count to 0
nFiles = 0
ENDIF
* Check each of the files
FOR i = 1 to nFiles
* Get the extension
cExt = Upper( JustExt( aFiles[ i ] ))
IF ( cExt == "BMP" ) or ( cExt == "JPG" ) or ( cExt == "GIF" )
* If it is a file we can handle
* Hide the label
*This.lblDropSpace.Visible = .F.
* Set the picture property
This.Picture = aFiles[ i ]
* Draw he container
*THIS.Draw
* Pause for a few seconds in case there was more than one file
INKEY(2,"H")
ENDIF
ENDFOR
* Set the copy only attribute
nEffect = 1
* stop the default action of this drag and drop
NODEFAULT
CASE oDataObject.GetFormat( "Private Format" ) && Private format
* I can handle "Private Format" data
* Hide the label
*This.lblDropSpace.Visible = .F.
* Set the picture property
This.Picture = oDataObject.GetData( "Private Format" )
* Set the copy attribute
nEffect = 1
* Draw the container
*THIS.Draw
* Stop the default action of the drag and drop event
NODEFAULT
ENDCASE
The code in OLEDOver:
Code:
LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord, nState
*ThisForm.Activate
ACTIVATE SCREEN
?oDataObject.GetFormat(1)
?oDataObject.GetFormat(2)
?oDataObject.GetFormat(7)
?oDataObject.GetFormat(13)
?oDataObject.GetFormat(15)
?oDataObject.GetFormat("OLE Variant Array")
?oDataObject.GetFormat("OLE Variant")
?oDataObject.GetFormat("VFP Source Object")
IF nState == 0 && Drag Enter
*-- We only need to check out the data format once upon enter
DO CASE
CASE oDataObject.GetFormat( "Private Format" )
* I can handle drops of "Private Format"
* Tell OLEDragDrop that I know how to handle this
This.OLEDropHasData = 1
* Tell OLEDragDrop that I want to copy this
This.OLEDropEffects = 1
CASE oDataObject.GetFormat( 15 ) && Files
* I can handle drops of files
This.OLEDropHasData = 1
This.OLEDropEffects = 1
CASE [COLOR=#EF2929][b]oDataObject.GetFormat( 13 )[/b][/color] && Unicode text format
* I can handle drops of files
This.OLEDropHasData = 1
This.OLEDropEffects = 1
ENDCASE
ENDIF