answersLogoWhite

0


Best Answer

Copy/paste is facilitated by the operating system clipboard. This answer discusses the Windows operating system clipboard only. For other operating systems, consult the application programming interface (API) documentation related to that operating system.

Except for registering clipboard formats, individual windows perform most clipboard operations. A window procedure transfers information to or from the clipboard in response to the WM_COMMAND message.

The four conventional copy/paste commands are:

  • Cut : places a copy of the current selection on the clipboard and deletes the selection from the document. The previous clipboard content is destroyed.
  • Copy : command places a copy of the current selection on the clipboard. The previous clipboard content is destroyed.
  • Paste : replaces the current selection with the clipboard content. The clipboard content remains unchanged.
  • Delete : deletes the current selection from the document. The clipboard content remains unchanged.

These commands are conventionally provided via the window's context-sensitive Edit command menu, however they should also be mapped to the conventional keyboard accelerators: CTRL+X (cut), CTRL+C (copy), CTRL+V (paste) and DEL (delete).

[The Print Screen accelerator is usually mapped to the shell program (explorer.exe, by default). This accelerator is typically used to take a snapshot of the current desktop (ALT+Print Screen takes a snapshot of the active window). The snapshot (a 1:1 bitmap image) is copied to the clipboard, replacing the current clipboard content.]

The clipboard owner is the window associated with the current information on the clipboard. A window becomes the owner when it places information on the clipboard -- specifically, when it invokes the EmptyClipboard function. The window remains the owner until the window is closed or another window empties the clipboard.

The EmptyClipboard function posts a WM_DESTROYCLIPBOARD message to the current clipboard owner and assigns ownership to the current window. Upon receiving a WM_DESTROYCLIPBOARD message, a clipboard owner must release all resources associated with the information it owns.

Once the clipboard is emptied, the new owner may place new information upon the clipboard. Information can be stored in one or more supported formats, including user-defined formats. The standard formats are:

CONSTANT (value): Description

CF_TEXT (1): Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.

CF_BITMAP (2): A handle to a bitmap (HBITMAP).

CF_METAFILEPICT (3): Handle to a metafile picture format as defined by the METAFILEPICT structure. When passing a CF_METAFILEPICT handle by means of DDE, the application responsible for deleting hMem should also free the metafile referred to by the CF_METAFILEPICT handle.

CF_SYLK (4): Microsoft Symbolic Link (SYLK) format.

CF_DIF (5): Software Arts' Data Interchange Format.

CF_TIFF (6): Tagged-image file format.

CF_OEMTEXT (7): Text format containing characters in the OEM character set. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.

CF_DIB (8): A memory object containing a BITMAPINFO structure followed by the bitmap bits.

CF_PALETTE (9): Handle to a colour palette. Whenever an application places data in the clipboard that depends on or assumes a colour palette, it should place the palette on the clipboard as well. If the clipboard contains data in the CF_PALETTE(logical colour palette) format, the application should use the SelectPalette and RealizePalette functions to realise (compare) any other data in the clipboard against that logical palette. When displaying clipboard data, the clipboard always uses as its current palette any object on the clipboard that is in the CF_PALETTE format.

CF_PENDATA (10): Data for the pen extensions to the Microsoft Windows for Pen Computing.

CF_RIFF (11): Represents audio data more complex than can be represented in a CF_WAVE standard wave format.

CF_WAVE (12): Represents audio data in one of the standard wave formats, such as 11 kHz or 22 kHz

PCM.

CF_ENHMETAFILE (14): A handle to an enhanced metafile (HENHMETAFILE).

CF_UNICODETEXT (13): Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.

CF_HDROP (15): A handle to type HDROP that identifies a list of files. An application can retrieve information about the files by passing the handle to the DragQueryFilefunction.

CF_LOCALE (16): The data is a handle to the locale identifier associated with text in the clipboard. When you close the clipboard, if it contains CF_TEXT data but no CF_LOCALE data, the system automatically sets the CF_LOCALE format to the current input language. You can use the CF_LOCALE format to associate a different locale with the clipboard text. An application that pastes text from the clipboard can retrieve this format to determine which character set was used to generate the text. Note that the clipboard does not support plain text in multiple character sets. To achieve this, use a formatted text data type such as RTF instead. The system uses the code page associated with CF_LOCALE to implicitly convert from CF_TEXT to CF_UNICODETEXT. Therefore, the correct code page table is used for the conversion.

CF_DIBV5 (17): A memory object containing a BITMAPV5HEADER structure followed by the bitmap colour space information and the bitmap bits.

CF_OWNERDISPLAY (0x0080): Owner-display format. The clipboard owner must display and update the clipboard viewer window, and receive the WM_ASKCBFORMATNAME, WM_HSCROLLCLIPBOARD, WM_PAINTCLIPBOARD, WM_SIZECLIPBOARD, and WM_VSCROLLCLIPBOARD messages. The hMem parameter must be NULL.

CF_DSPTEXT (0x0081): Text display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in text format in lieu of the privately formatted data.

CF_DSPBITMAP (0x0082): Bitmap display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in bitmap format in lieu of the privately formatted data.

CF_DSPMETAFILEPICT (0x0083): Metafile-picture display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in metafile-picture format in lieu of the privately formatted data.

CF_DSPENHMETAFILE (0x008E): Enhanced metafile display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in enhanced metafile format in lieu of the privately formatted data.

CF_PRIVATEFIRST (0x0200): Start of a range of integer values for private clipboard formats. The range ends with CF_PRIVATELAST. Handles associated with private clipboard formats are not freed automatically; the clipboard owner must free such handles, typically in response to the WM_DESTROYCLIPBOARD message.

CF_PRIVATELAST (0x02FF): See CF_PRIVATEFIRST.

CF_GDIOBJFIRST (0x0300): Start of a range of integer values for application-defined GDI object clipboard formats. The end of the range is CF_GDIOBJLAST. Handles associated with clipboard formats in this range are not automatically deleted using the GlobalFree function when the clipboard is emptied. Also, when using values in this range, the hMem parameter is not a handle to a GDI object, but is a handle allocated by the GlobalAlloc function with the GMEM_MOVEABLE flag.

CF_GDIOBJLAST (0x03FF): See CF_GDIOBJFIRST.

For more information, consult the Windows Dev Centre. Search for "Clipboard".

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you use copy-paste in c and c plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you program games with c plus plus?

Yes, you can program games with C++.


How do you convert from assembly to binary in c plus plus?

Use inline assembly instructions. Then compile your C++ program to produce the machine code.


Do you need Microsoft c plus plus redistributable?

If you use microsoft's "Visual C++ Compiler" whoever is going to use your program needs the redistributable installed.


Can you use C plus plus with Excel spreadsheets?

This question is irrelative because C++ is a language and Excel is a software. The thing is that we can't use C++ with Excel, but we can write a program like excel in C++.


How to restart c plus plus program?

Exit the program and relaunch it.


C program to print numbers 1 to n?

how do we use loops in c plus plus programing and what are basic differences between do,for and while loop


Lint is a compiler b a interactive debugger c a cinterpreter d a tool for analysing c plus plus program?

d a tool for analysing c plus plus program


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


Where did C plus plus program come from?

C++ is an extension of C, and was invented by Bjarne Stroustrup.


How do you install curses header file in fedora Linux in order to use getch function in a c an c plus plus program?

dnf install ncurses-devel


What is the only function all C plus plus programs must contain?

Every C plus plus program that is a main program must have the function 'main'.


Can you rewrite a cuda file in c c plus plus language?

Yes, you can rewrite a cuda program originally written in c in c plus plus.