Results 1 to 5 of 5

Thread: [RESOLVED] How do I tell what type of data is in the clipboard? (i.e. Text, Pic, File)

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Resolved [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
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. Private Sub mnuEdit_Click ()
    2. ' Click event for the Edit menu.
    3.    mnuCut.Enabled = True
    4.    mnuCopy.Enabled = True
    5.    mnuPaste.Enabled = False
    6.    If TypeOf Screen.ActiveControl Is TextBox Then
    7.       If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
    8.    ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    9.       If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
    10.    ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    11.       If Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = True
    12.    ElseIf TypeOf Screen.ActiveControl Is PictureBox _
    13.          Then
    14.       If Clipboard.GetFormat(vbCFBitmap) Then mnuPaste.Enabled = True
    15.    Else
    16.       ' Can't cut or copy from the other types
    17.       '   of controls.
    18.       mnuCut.Enabled = False
    19.       mnuCopy.Enabled = False
    20.    End If
    21. 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.

  3. #3

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    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:
    1. If Clipboard.GetFormat(vbCFText) Then 'Cipboard data type is Text
    2.   If Clipboard.GetFormat(vbCFBitmap) Then 'Clipboard data type is Bitmap Pic
    3.       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.
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. If Clipboard.GetFormat(vbCFDIB) Or [COLOR=Red]Clipboard.GetFormat[/COLOR](vbCFPalette) Then 'Clipboard data type is a File

  5. #5

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    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:
    1. If Clipboard.GetFormat(vbCFDIB) Or (vbCFPalette) Then 'Clipboard data type is a File

    Instead of like this:
    VB Code:
    1. If Clipboard.GetFormat(vbCFDIB) Or Clipboard.GetFormat(vbCFPalette) Then 'Clipboard data type is a File

    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width