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

  • According to a 2014 Javelin Strategy & Research Study, there is a new victim of fraud every two seconds – and that's just in the U.S. With identity theft and consumer fraud rising, and more frequent and sizable data breaches in the news, financial institutions need to work harder than ever to protect their customers and their business. Download this white paper to learn how you can use multi-channel communications to minimize the costs of fraud while also increasing customer loyalty.

  • As virtualization becomes the norm throughout organizations of nearly all sizes, and as more organizations look to private cloud solutions, IT decision makers are increasingly in need of ways to keep storage costs and complexity under control in the face of often-runaway virtual machine (VM) sprawl. Application-aware storage is designed to help achieve these important goals. Read this white paper to learn how application-aware storage allows you to gain VM-level visibility into application performance and …

Most Popular Programming Stories

More for Developers

RSS Feeds

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