Jump to content

WinSetClipbrdData

From EDM2
Revision as of 23:19, 10 December 2023 by Martini (talk | contribs) (Parameters)

This call puts data into the clipboard.

Syntax

WinSetClipbrdData(hab, ulh, ulfmt, flFmtInfo)

Parameters

hab (HAB) - input
Anchor-block handle.
ulh (ULONG) - input
General handle to the data object being set into the clipboard.
If NULLHANDLE, a WM_RENDERFMT message is sent to the clipboard-owner window to render the format when WinQueryClipbrdData is called with the specified format.
Once the data has been set into the clipboard, this handle can no longer be used by the application.
If CFI_POINTER is specified, this parameter contains a pointer to memory. The memory must have been allocated as unnamed and shareable, by DosAllocSharedMem with the OBJ_GIVEABLE attribute.
ulfmt (ULONG) - input
Clipboard format of the data object referenced by ulh.
The standard clipboard formats are shown in the following list. In addition to these predefined formats, any format value registered through the standard system atom manager displays this format in preference to privately-formatted data.
CF_TEXT
Text format. Each line ends with a carriage-return/line-feed combination. Tab characters separate fields within a line. A NULL character signals the end of the data.
CF_DSPTEXT
Text display format associated with private format.
CF_BITMAP
Bit map.
CF_DSPBITMAP
Bit-map display format associated with private format.
CF_METAFILE
Metafile.
CF_DSPMETAFILE
Metafile display format associated with private format.
CF_PALETTE
Palette.
flFmtInfo (ULONG) - input
Information.
Information about the type of data referenced by the ulh parameter.
Memory Model
One and only one of CFI_POINTER and CFI_HANDLE must be specified, unless CFI_OWNERDISPLAY is also specified.
CFI_POINTER
The ulh parameter is a flat pointer to the object.
When this memory model is specified, the system:
saves the address (accessing it from the shell process), so that if the setting application terminates normally or abnormally, the data is still available.
frees the memory from the setting process, so that the setting application may no longer use it. CFI_POINTER must be specified if the ulfmt parameter is CF_TEXT or CF_DSPTEXT.
CFI_HANDLE
The ulh parameter is the handle to a metafile or bit map.
This must be specified if the ulfmt parameter is CF_BITMAP, CF_DSPBITMAP, CF_METAFILE or CF_DSPMETAFILE.
Usage Flags
CFI_OWNERFREE
Handle is not freed by WinEmptyClipbrd. The application must free the data if necessary. CFI_OWNERDISPLAY
This flag indicates that the format is drawn by the clipboard owner in the clipboard viewer window by means of the WM_PAINTCLIPBOARD message. The ulh parameter should be NULL. The values may be combined with bit-wise OR. Any number of the usage flags may be specified, but only one of the memory models.

Returns

rc (BOOL) - returns
Data-placed indicator.
Indicates whether data is placed into clipboard by this call:
TRUE
Data placed into clipboard.
FALSE
Data is not placed into clipboard, either an error occurred, or ulh is NULL.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_FLAG (0x1019)
An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.
PMERR_INVALID_INTEGER_ATOM (0x1016)
The specified atom is not a valid integer atom

Remarks

Data of the specified format, already in the clipboard, is freed by this call.

An object passed to the clipboard becomes the property of the system, and is not deleted when the process that created it terminates.

Example Code

This example puts a bit map into the clipboard.

#define INCL_WINCLIPBOARD
#include <OS2.H>
HAB hab;                 /* anchor-block handle. */
HBITMAP bmap;            /* bit-map handle.      */

WinOpenClipbrd(hab);
WinSetClipbrdData(hab,
                 (ULONG)bmap,
                 CF_BITMAP,
                 CFI_HANDLE); /* tells the system that the  */
                               /* bmap parameter is a handle */
                               /* to a bit map.              */
WinCloseClipbrd(hab);

Definition

#define INCL_WINCLIPBOARD /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HAB      hab;        /*  Anchor-block handle. */
ULONG    ulh;        /*  General handle to the data object being set into the clipboard. */
ULONG    ulfmt;      /*  Clipboard format of the data object referenced by ulh. */
ULONG    flFmtInfo;  /*  Information. */
BOOL     rc;         /*  Data-placed indicator. */

rc = WinSetClipbrdData(hab, ulh, ulfmt, flFmtInfo);

Related Functions

  • WinCloseClipbrd
  • WinEmptyClipbrd
  • WinEnumClipbrdFmts
  • WinOpenClipbrd
  • WinQueryClipbrdData
  • WinQueryClipbrdFmtInfo
  • WinQueryClipbrdOwner
  • WinQueryClipbrdViewer
  • WinSetClipbrdOwner
  • WinSetClipbrdViewer

Related Messages

  • WM_RENDERFMT
  • WM_PAINTCLIPBOARD