Clipboard help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Clipboard help

I am trying to read data from the clipboard. I want to be able to read it in ANY format. I have basicly figured out how to do that, but I am haveing some problems. I am useing GlobalSize() to get the size of the memory block allocated for the clipboard. This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be. Any ideas of why this would be happening or a better way to get the size of the memory block allocated to the clipboard?

I am writing this useing C and the Platform SDK.

Thanks.

Jon
AIM: compumatrix123
ICQ: 58634849
http://www.compumatrix.com


Comments

  • SunlightSunlight Posts: 186Member
    : This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be.

    Have you tried dumping the data (to a file, for example) to see what it is? Files copied from Windows Explorer are not stored as content, but merely their filename (and half a dozen OLE drag-drop formats).
    --
    [italic][blue]Sunlight[/blue][/italic]


  • compumatrixcompumatrix Posts: 3Member
    : : This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be.
    :
    : Have you tried dumping the data (to a file, for example) to see what it is? Files copied from Windows Explorer are not stored as content, but merely their filename (and half a dozen OLE drag-drop formats).
    : --
    : [italic][blue]Sunlight[/blue][/italic]
    :
    :

    I realize that the actual file is not copied to the clipboard. The GlobalSize function returns 32 for the size of clipboard items that are copied from windows explorer. I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete. I know that it is not complete because I used the clipboard viewer to save the clipboard to a .clp file, and then used a hex editor to search the .clp file for the values that were at the beginning of the file that I dumped from my program. I searched the .clp file for these values and found them after what I assume is the header to the .clp file, but there is more data after the 32 bytes that my program reads. The data after those 32 bytes contains the file path and name. This is why I assume it is a problem in reading size of the clipboard memory.

    The program that I am writing is supposed to be able to copy the contents of the clipboard and put them back on the clipboard, and it works fine with other clipboard data. I think it would work fine for th "files" copied from windows explorer also if I could read all the data.

    The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...



    Jon [email protected]
    AIM: compumatrix123
    ICQ: 58634849
    http://www.compumatrix.com



  • SunlightSunlight Posts: 186Member
    : I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete.

    Which format are you reading? You pass a clipboard format to GetClipboardData; the shell puts eight of them on there, which you can enumerate using EnumClipboardFormats.

    : The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...

    ClipBook (which I think is now the standard Clipboard Viewer) allows you to do just this, as does Office 2000.
    --
    [italic][blue]Sunlight[/blue][/italic]


  • compumatrixcompumatrix Posts: 3Member
    : : I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete.
    :
    : Which format are you reading? You pass a clipboard format to GetClipboardData; the shell puts eight of them on there, which you can enumerate using EnumClipboardFormats.
    :
    : : The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...
    :
    : ClipBook (which I think is now the standard Clipboard Viewer) allows you to do just this, as does Office 2000.
    : --
    : [italic][blue]Sunlight[/blue][/italic]
    :
    :

    I was reading/writing it in the first format that I got from EnumClipboardFormats() (I believe it was the DataObject format), that could be the problem I suppose, I think I will try reading/writing it in other formats... and see how that works


    Jon [email protected]
    AIM: compumatrix123
    ICQ: 58634849
    http://www.compumatrix.com



  • opcodeopcode Posts: 2Member
    Here is an article describing how to use Windows clipboard.
    [link=http://www.frostcode.info/common-articles/write-to-windows-clipboard.html]Using Windows Clipboard[/link]
Sign In or Register to comment.