Article # 671, added by Geoworks, historical record
| first | previous | index | next | last |

How to paste GString clipboard data.



Q. I am trying to get access to the GString data from the clipboard.
   Can you give a code example of how to do this?

A. Here is how it is done:

        #define GRAPHICS_FORMAT FormatIDFromManufacturerAndType(             MANUFACTURER_ID_GEOWORKS, CIF_GRAPHICS_STRING )

        /*
         * query   - return values for clipboard query
         * request - return values from clipboard request
         * gstate  - handle of gstate containing gstring; this
         *           is not a real gstate in that it is not
         *           attached to a window; don't attempt to
         *           draw to this gstate
         */
        ClipboardQueryArgs   query;
        ClipboardRequestArgs request;
        Handle               gstate;

        /*
         * Get the handle of the clipboard VM file.
         */
        ClipboardQueryItem( TIF_NORMAL, &query );

        /*
         * See if this clipboard has GString data in it.
         */
        if ( ( query.CQA_numFormats > 0 ) &&
             ClipboardTestItemFormat( query.CQA_header, GRAPHICS_FORMAT ) ) {
                ClipboardRequestItemFormat( GRAPHICS_FORMAT,
                                            query.CQA_header,
                                            &request );
                /*
                 * request.CRA_file   - file handle
                 * request.CRA_data   - start of data vm chain
                 * request.CRA_extra1 - H size
                 * request.CRA_extra2 - V size
                 */

                /*
                 * Copy the clipboard GString to a new block so
                 * we can perform work on it.
                 */
                gstate = GrLoadGString(
                    request.CRA_file,
                    GST_VMEM,
                    VMCHAIN_GET_VM_BLOCK( request.CRA_data ) );

                /* Do work on GString here. */

                /*
                 * After performing our work we can destroy the
                 * GString we grabbed.
                 */
                GrDestroyGString( newGString, NULL, GSKT_LEAVE_DATA );
        }
        ClipboardDoneWithItem( query.CQA_header );