|
-
Aug 29th, 2005, 01:16 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)
Hello,
I need to tell what type of data is in the clipboard.
Example: If it is text, a pic, or a file.
Is there any way to figure this out?
Thank you and have a great day!
Stilekid007
 Originally Posted by stilekid007
-
Aug 29th, 2005, 01:18 PM
#2
Re: How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)
You might have to add to this, but it should get you started.
VB Code:
Private Sub mnuEdit_Click ()
' Click event for the Edit menu.
mnuCut.Enabled = True
mnuCopy.Enabled = True
mnuPaste.Enabled = False
If TypeOf Screen.ActiveControl Is TextBox Then
If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
If Clipboard.GetFormat(vbCFBitmap) Then mnuPaste.Enabled = True
Else
' Can't cut or copy from the other types
' of controls.
mnuCut.Enabled = False
mnuCopy.Enabled = False
End If
End Sub
Note You might also want to check for other data formats with the constants vbCFPalette, vbCFDIB, and vbCFMetafile. If you want to replace a picture’s palette using Clipboard operations, you should request vbCFBitmap rather than vbCFDIB from the Clipboard. See "Working with 256 Colors" later in this chapter for more information on working with the color palette.
-
Aug 29th, 2005, 01:50 PM
#3
Thread Starter
Hyperactive Member
Re: How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)
Hmm - I don't see how that code would tell me if there is text in the clipboard or a bitmap pic...
But this code works for me now:
VB Code:
If Clipboard.GetFormat(vbCFText) Then 'Cipboard data type is Text
If Clipboard.GetFormat(vbCFBitmap) Then 'Clipboard data type is Bitmap Pic
If Clipboard.GetFormat(vbCFDIB) Or (vbCFPalette) Then 'Clipboard data type is a File
Thank you for your help sir!
Stilekid007
Last edited by stilekid007; Aug 29th, 2005 at 01:55 PM.
 Originally Posted by stilekid007
-
Aug 29th, 2005, 02:05 PM
#4
Re: How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)
This statement wasn't right:
VB Code:
If Clipboard.GetFormat(vbCFDIB) Or [COLOR=Red]Clipboard.GetFormat[/COLOR](vbCFPalette) Then 'Clipboard data type is a File
-
Aug 29th, 2005, 02:09 PM
#5
Thread Starter
Hyperactive Member
Re: How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)
Yea I think it is supposed to look like this:
VB Code:
If Clipboard.GetFormat(vbCFDIB) Or (vbCFPalette) Then 'Clipboard data type is a File
Instead of like this:
VB Code:
If Clipboard.GetFormat(vbCFDIB) Or Clipboard.GetFormat(vbCFPalette) Then 'Clipboard data type is a File
Stilekid007
 Originally Posted by stilekid007
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
|