Simple text output to the clipboard

This is a discussion on Simple text output to the clipboard within the Windows Programming forums, part of the Platform Specific Boards category; I have searched for 'clipboard' on this site but everything I have read is a bit complicated for me (still ...

  1. #1
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163

    Question Simple text output to the clipboard

    I have searched for 'clipboard' on this site but everything I have read is a bit complicated for me (still a newbie).

    I have a C++ program that outputs text data to the screen (in it's own little window) to which I then manually copy the data, via the clipboard, to several other programs.
    Now I realise that I should be able to write the data straight to the clipboard which would speed things up immensely; note that I don't want to read the data from the clipboard via C++.
    My site to register for all my other websites!
    'Clifton Bazaar'

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    I would guess that 99.9% of the time, the code to do this is not portable. Therefore, you first need to tell us your OS. We could assume some OS, but the way to do it in that OS might vary greatly between versions (i.e. Windows). So if you were using Windows, the first thing I would do is (obviously) search. You say you've searched this site, but I would search a larger/general search engine, i.e. Google. Something like "c++ windows write clipboard" and I would be quite certain you will come up with something useful.

    Anyway, I dont have time to contribute further, but just giving you a little boost, and if nothing else, you tell us your OS which is required.

  3. #3
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    OS is windows XP.

    Searching google as I write this
    My site to register for all my other websites!
    'Clifton Bazaar'

  4. #4
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    I've been spending most of the day trying to get this and so far I have this

    Code:
      OpenClipboard(NULL);
      SetClipboardData(CF_TEXT, "Hello World");
      CloseClipboard();
    after reading the MSDN library it tells me that SetClipboardData doesn't work if I pass a NULL value to OpenClipboard.

    What change could I make to this code to make it work? I am still trying to search via google for the answer but I'm stuck at the moment
    My site to register for all my other websites!
    'Clifton Bazaar'

  5. #5
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    Thanks for that
    My site to register for all my other websites!
    'Clifton Bazaar'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. coloured text output
    By surdy in forum Linux Programming
    Replies: 4
    Last Post: 03-29-2004, 05:46 PM
  2. Outputting to a File Modified Text
    By alpha in forum C++ Programming
    Replies: 8
    Last Post: 11-24-2003, 08:39 PM
  3. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 10:45 PM
  4. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 04:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21