Jump to content

WpclsAddClipboardAssoc: Difference between revisions

From EDM2
No edit summary
 
Line 4: Line 4:
  _wpclsAddClipboardAssoc(somSelf, aCBFormat, pszClassName)
  _wpclsAddClipboardAssoc(somSelf, aCBFormat, pszClassName)
==Parameters==
==Parameters==
;somSelf (M_WPDataFile *) - input
;''somSelf'' (M_WPDataFile *) - input
:Pointer to the WPDataFile class object.  
:Pointer to the WPDataFile class object.  


;aCBFormat ([[ULONG]]) - input
;''aCBFormat'' ([[ULONG]]) - input
:Atom referring to the clipboard format.  
:Atom referring to the clipboard format.  


;pszClassName ([[PSZ]]) - input
;''pszClassName'' ([[PSZ]]) - input
:String containing the name of the class to associate the clipboard format with.
:String containing the name of the class to associate the clipboard format with.


==Returns==
==Returns==
;rc (ULONG) - returns:Success indicator.
;''rc'' ([[ULONG]]) - returns:Success indicator.
:;0:The method class call was successful.  
:;0:The method class call was successful.  
:;Not 0: The method class call was unsuccessful.
:;Not 0: The method class call was unsuccessful.

Latest revision as of 23:08, 19 May 2025

This class method adds an association between a clipboard format and a particular class name.

Syntax

_wpclsAddClipboardAssoc(somSelf, aCBFormat, pszClassName)

Parameters

somSelf (M_WPDataFile *) - input
Pointer to the WPDataFile class object.
aCBFormat (ULONG) - input
Atom referring to the clipboard format.
pszClassName (PSZ) - input
String containing the name of the class to associate the clipboard format with.

Returns

rc (ULONG) - returns
Success indicator.
0
The method class call was successful.
Not 0
The method class call was unsuccessful.

Remarks

This method adds an association between a clipboard format such as "#1" (special name for Plain Text) and a particular class name such as WPDataFile. This is used in the paste-to-folder function to decide which classes support a particular rendering format.

This method is usually called in wpclsInitData when an object class is registered for the first time.

Note
You should block the call to this method with a static variable which forces it to only be called once. Otherwise, it will execute the same code when the object's subclasses are registered.

How to Override

This method is not generally overridden.

Usage

This method can be called at any time to associate a private clipboard format to an object class.

Example Code

Declaration.

#define INCL_WINWORKPLACE
#include <os2.h>

M_WPDataFile     *somSelf;       /*  Pointer to the WPDataFile class object. */
ULONG             aCBFormat;     /*  Atom referring to the clipboard format. */
PSZ               pszClassName;  /*  String containing the name of the class to associate the clipboard format with. */
ULONG             rc;            /*  Success indicator. */

rc = _wpclsAddClipboardAssoc(somSelf, aCBFormat,
       pszClassName);

This example associates the private clipboard format "MyFormat" with the object class "MyObjectClass".

 HATOMTBL   hAtomTable = NULLHANDLE;
 ATOM       aFormat = 0;

 /* Find the system atom table  */
 hAtomTable = WinQuerySystemAtomTable();
 if (hAtomTable)
 {

    /* Add an atom to the system atom table for the clipboard format  */
    aFormat = WinAddAtom(hAtomTable,"MyFormat");
    if (aFormat)
    {

       /* Associate the clipboard format to the object class  */
       _wpclsAddClipBoardAssoc(_WPDataFile,aFormat,"MyObjectClass");
       WinDeleteAtom(hAtomTable,aFormat);
    }
 }

Related Methods