Jump to content

WinSetClipbrdData: Difference between revisions

From EDM2
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:


==Parameters==
==Parameters==
;hab (HAB) - input
;''hab'' (HAB) - input:Anchor-block handle.
: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.
;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.
: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.  
: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''.
;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.
: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.
 
:{| class="wikitable"
:;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.  
! Format Name !! Description
:;CF_DSPTEXT
|-
::Text display format associated with private format.  
| 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_BITMAP
|-
::Bit map.  
| CF_DSPTEXT || Text display format associated with private format.
:;CF_DSPBITMAP
|-
::Bit-map display format associated with private format.  
| CF_BITMAP || Bit map.
:;CF_METAFILE
|-
::Metafile.  
| CF_DSPBITMAP || Bit-map display format associated with private format.
:;CF_DSPMETAFILE
|-
::Metafile display format associated with private format.  
| CF_METAFILE || Metafile.
:;CF_PALETTE
|-
::Palette.  
| CF_DSPMETAFILE || Metafile display format associated with private format.
 
|-
;flFmtInfo (ULONG) - input
| CF_PALETTE || Palette.
:Information.
|}
:Information about the type of data referenced by the ulh parameter.
;''flFmtInfo'' (ULONG) - input:Information.
:;Memory Model
:Information about the type of data referenced by the ''ulh'' parameter.
::One and only one of CFI_POINTER and CFI_HANDLE must be specified, unless CFI_OWNERDISPLAY is also specified.
:;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_POINTER
:::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.
:::The ulh parameter is a flat pointer to the object.
:;Usage Flags:CFI_OWNERFREE - Handle is not freed by [[WinEmptyClipbrd]]. The application must free the data if necessary.
:::When this memory model is specified, the system:
::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.
:::: 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==
==Returns==
;rc (BOOL) - returns
;''rc'' (BOOL) - returns:Data-placed indicator.
:Data-placed indicator.
:Indicates whether data is placed into clipboard by this call:
: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.


:;TRUE
==Errors==
::Data placed into clipboard.  
Possible returns from [[WinGetLastError]]
:;FALSE
::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.
::Data is not placed into clipboard, either an error occurred, or ulh is NULL.
::PMERR_INVALID_INTEGER_ATOM (0x1016): The specified atom is not a valid integer atom.


==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==
==Remarks==
Data of the specified format, already in the clipboard, is freed by this call.
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.  
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==
==Example Code==
This example puts a bit map into the clipboard.
This example puts a bit map into the clipboard.
<pre>
<pre>
#define INCL_WINCLIPBOARD
#define INCL_WINCLIPBOARD
#include <OS2.H>
#include <os2.h>
HAB hab;                 /* anchor-block handle. */
 
HBITMAP bmap;           /* bit-map handle.     */
HAB hab;         /* anchor-block handle. */
HBITMAP bmap;     /* bit-map handle.     */


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


Definition
==Related Messages==
<pre>
* [[WM_RENDERFMT]]
#define INCL_WINCLIPBOARD /* Or use INCL_WIN, INCL_PM, */
* [[WM_PAINTCLIPBOARD]]
#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);
 
</pre>


==Related Functions==
==Related Functions==
* WinCloseClipbrd
* [[WinCloseClipbrd]]
*WinEmptyClipbrd
* [[WinEmptyClipbrd]]
*WinEnumClipbrdFmts
* [[WinEnumClipbrdFmts]]
*WinOpenClipbrd
* [[WinOpenClipbrd]]
*WinQueryClipbrdData
* [[WinQueryClipbrdData]]
*WinQueryClipbrdFmtInfo
* [[WinQueryClipbrdFmtInfo]]
*WinQueryClipbrdOwner
* [[WinQueryClipbrdOwner]]
*WinQueryClipbrdViewer
* [[WinQueryClipbrdViewer]]
*WinSetClipbrdOwner
* [[WinSetClipbrdOwner]]
*WinSetClipbrdViewer  
* [[WinSetClipbrdViewer]]
==Related Messages==
* WM_RENDERFMT
* WM_PAINTCLIPBOARD


[[Category:Win]]
[[Category:Win]]

Latest revision as of 19:13, 10 April 2025

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.
Format Name Description
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);

Related Messages

Related Functions