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

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • Email is the most common communication vehicle used by organizations of all shapes and sizes. Among the billions of email messages sent every day are sensitive information, critical requests, and other essential business data. IT staff bear the burden of ensuring the confidentiality, integrity, and availability of the information contained within the communication. This white paper explores the email security landscape, an assessment of the threats organizations face,  and the building blocks of an effective …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds