Thread: Clipboard Modifier

  1. #1
    Confused
    Join Date
    Nov 2002
    Location
    Warwick, UK
    Posts
    209

    Clipboard Modifier

    I'm currently coding a formatter for the clipboard : when it finds a certain thing on the clipboard, it will modify it, empty the clipboard, and put the new modified data onto the clipboard, ready for the user to paste elsewhere. However, I'm having the following troubles :

    1.
    Code:
    GetClipboardData(unsigned int uFormat);
    In this function, I'm using uFormat as CF_TEXT, to get my data as plain text. However, I'm not sure how to use it. When I have something on the clipboard and use this function, I try to use it using
    Code:
    cout << GetClipboardData(CF_TEXT);
    and get "0x0" out of it. I'm not sure I'm using it properly, but I can't think of another way.

    2.
    Code:
    SetClipboardData(unsigned int uFormat, HWND hData);
    I'm unsure about the variable HWND hData. I would like to insert plain text into the Clipboard, or perhaps from a .txt file, but have seen no working examples of this. Furthermore, many of these examples seem to use calls to GlobalAlloc, which I would prefer to avoid, if it is possible.


    So far, my code simply opens the Clipboard, gets data, prints it to screen, clears the Clipboard and sets new data which I should be able to see by hitting CTRL + V, but I'm not able to retrieve from the data ( I get "0x0" ), and I can't set the data.

    I've searched this board, I've been at MSDN, at CodeProject, etc., and cannot find the answer to my problem.

    Thanks for your help.
    Last edited by Korhedron; 01-02-2004 at 04:01 AM.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    http://msdn.microsoft.com/library/en...eClipboard.asp

    Look for the EditCopy and EditPaste samples.

  3. #3
    Confused
    Join Date
    Nov 2002
    Location
    Warwick, UK
    Posts
    209
    Thanks Anonytmouse, I've had a look at that... Truth is, it scares me Is there no simple way so copy plain text into the Clipboard ? I don't even understand the code under EditCopy and EditPaste at MSDN, and would have no idea what to do with it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. copying to clipboard
    By bballzone in forum Windows Programming
    Replies: 24
    Last Post: 09-30-2004, 03:24 PM
  2. const modifier
    By Vertex34 in forum C Programming
    Replies: 8
    Last Post: 09-27-2004, 07:22 PM
  3. Clipboard and Custom Types
    By McClamm in forum C# Programming
    Replies: 1
    Last Post: 09-16-2004, 04:43 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM