|
-
Jul 1st, 2001, 02:47 AM
#1
Thread Starter
Lively Member
why isn't this code working?
VB Code:
Private Sub Picture1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFBitmap) Then Picture1.Picture = LoadPicture(Data.Files(1))
End Sub
now it should display the file in Picture1.Picture but it doesn't what is up??
-
Jul 1st, 2001, 08:16 AM
#2
Is Data.GetFormat(vbCFBitmap) True?
-
Jul 1st, 2001, 08:19 AM
#3
BTW I had never seen the GetFormat method before and I just looked in up in MSDN. It seems to only apply to the Clipboard object.
-
Jul 1st, 2001, 05:29 PM
#4
Thread Starter
Lively Member
not working maybe i'm doing it wrong
VB Code:
Private Sub Picture1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Is Data.GetFormat(vbcfbitmap) True
Picture1.Picture = LoadPicture(Data.Files(1))
End Sub
I get syntax error
-
Jul 1st, 2001, 05:44 PM
#5
Lively Member
The reason why you get a syntax-error is because you can't write
Code:
Is Data.GetFormat(vbcfbitmap) True
There are no such thing as "Is" in Visual Basic...
And as MartinLiss wrote, the GetFormat-method only applies to the Clipboard-object.
-
Jul 1st, 2001, 05:49 PM
#6
Thread Starter
Lively Member
how do I fix my problem then?
-
Jul 1st, 2001, 06:09 PM
#7
Are you trying to drag an image or an image file?
Also, make sure you set the OLEDropMode property for the picturebox to Manual or Automatic.
GetFormat does not only work with the Clipboard Object. It also works for the DataObject object.
-
Jul 1st, 2001, 06:11 PM
#8
Thread Starter
Lively Member
yeah it is set on automatic and I am trying to drag an image file
-
Jul 1st, 2001, 06:22 PM
#9
Set it to manual and put this code in (Notice how similar to your code this is. You only missed one thing ):
VB Code:
Private Sub Picture1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFFiles) Then
'Ignore errors because a bad file can be dragged.
On Error Resume Next
Picture1.Picture = LoadPicture(Data.Files(1))
End If
End Sub
-
Jul 1st, 2001, 06:27 PM
#10
Thread Starter
Lively Member
-
Jul 1st, 2001, 06:28 PM
#11
Frenzied Member
There are no such thing as "Is" in Visual Basic...
There Sure IS.. Try
If Data1 IS Nothing Then Exit Sub
-
Jul 1st, 2001, 06:35 PM
#12
Fanatic Member
"Is" is a keyword in VB, but it's not used in that manner.
Code:
If TypeOf(objBlah) Is TextBox Then MsgBox "It's a textbox"
.GetFormat and .GetData apply to both the Clipboard and DataObject. I've never used this OLEDrag??? stuff before,
but this may be the way to get it. This method works for pasting bitmaps from the clipboard, but I don't know how to
actually test out the OLE event.
Code:
'Inside your OLEDragDrop event...
If Data.GetFormat(vbCFBitmap) Then picOut.Picture = Data.GetData(vbCFBitmap)
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Jul 1st, 2001, 06:37 PM
#13
Fanatic Member
Well I see someone else said it already. I've been watching tv and stopped writing the post
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|