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
Printable View
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
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
Quote:
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.
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
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
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