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

  • When it comes to desktops – physical or virtual – it's all about the applications. Cloud-hosted virtual desktops are growing fast because you get local data center-class security and 24x7 access with the complete personalization and flexibility of your own desktop. Organizations make five common mistakes when it comes to planning and implementing their application management strategy. This eBook tells you what they are and how to avoid them, and offers real-life case studies on customers who didn't …

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds