Simple Clipboard Class

This simple class gives you a group of three static functions that give you the power to use the clipboard for text. You can now implement cut, copy, and paste in your text-based application with ease, without worrying about the little details of clipboard work. These functions are all static, meaning you don't need to actually instantiate the class to use them.

There are three functions available:

CClipboard::SetText()
   This function puts text on the clipboard.

CClipboard::GetText()
   This function retrieves text from the clipboard.

CClipboard::GetTextLength()
   This function retrieves the length of the text on the clipboard.

If any of these functions return FALSE, then there was an error during the clipboard operation; otherwise, the operation was successful. In the future, I'd like to expand this into a more robust clipboard control class, perhaps using some of the other code that exists here on Codeguru. If anyone would like to take a stab at that before I do, please send your results back up when you have something!

Here is an example of how this class might be used:


#include "Clipboard.h"

         :
         :
         :

        // Write text to the clipboard
        char pastebuf[256];
        strcpy (pastebuf, "Put this on the clipboard.");
        CClipboard::SetText(strText);

         :
         :
         :

        // Retrieve text from the clipboard
        char copybuf[256];
        CClipboard::GetText(copybuf, 256);



Download demo project - 13 KB

Download source - 3 KB



Comments

  • guys opinion on belly button rings

    Posted by vandelaydessign.com on 12/12/2012 01:47pm

    By WebOsPublisher Free icons in ico format. Desktop icons - aquarium,cats,birds,nature,blanks,computer,flags,road signs,chips,christmas,erotic,sexy icons Free Windows icons, desktop icons, clip art Your name: Your e-mail: Stock Icons Toolbar Icons Business Icons Toolbar Icons Windows 7 Icons Free Icon Editor Medical Icons Icon Editor Find Icons Toons Icons for Children - collected by Icon News Hercules Icon Pack - collected by Iconok.Net Simpson's Pack 1 - collected by Spring Field Simpson's Pack 2 - collected by Spring Field Home | Products | Download | Order | Icons | Support Copyright © 2005-2012 Icon Empire. All rights reserved. Tweet Icon Craft is our pick. This icon maker allows you to design and edit all kinds of graphics required in the software development cycle, including icons, static and animated cursors and interface elements - all these kinds of graphics can now be designed in a single application. More info Icon Processor is an icon converter. It creates icons from your images. It is possible to convert 256-color icons into True Color icons and XP icons. More info ICL-Icon Extractor will scan your files, archives, folders and all local disks for icons. It can download icons from the Internet and customize Windows icons. More info Perfect Icon creates icons from any graphic file (PNG, JPEG, BMP, TIFF, WMF and more) in just seconds. Create stylish icons for Windows XP. Easily replace, colorize and save icons that Windows uses to display standard objects, folders and files. More info Pixel Editor is a program to create and edit images for websites or mobile devices. An array of tools to work with pictures and simplicity of use make this product ideal for newbies and graphic design professionals alike. More info

    Reply
  • GetTextLength() can't be used

    Posted by Legacy on 04/18/2002 12:00am

    Originally posted by: lake

       in the GetTextLength() ,
    
    

    nSize = GlobalSize(hGlobal) is used to show memery size,it usual > = Text Length ;

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • What does it take to win? According to Jack Welch, winning in business is great because when companies win, people thrive and grow. However, it goes without saying that you have to win the right way -- cleanly and by the rules. Even the most talented businessperson with the best intentions will get nowhere unless he or she knows how to win in today's complex business world. Read this book summary to learn not only the strategies of winning, but also the value that those strategies bring to your professional …

  • Cloud computing isn't new, but it's still a hot topic in technology circles. Moving to the cloud has done great things for many businesses. When it comes to handling a basic business necessity, cloud computing has brought many improvements to overall business continuity. Using the cloud for DR makes a lot of sense for many, but it's not exactly the most simple concept. Read this eBook to find answers to all the key questions IT professionals have about cloud-based disaster recovery, and helpful info around the …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date