Saveing / Loading to ClipBoard with datatypes

6 posts / 0 new
Last post
broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Saveing / Loading to ClipBoard with datatypes

It's posible to save and load data to the cluipboard via datatypes library,and I have the simples case working fine. SketchBlock now supports copying and pasteing layers via the clipboard.

Using DTST_CLIPBOARD as source type with NewDatatypeObject allows loading from any clipboard unit. I think I have that working too.

To write to the clipboard you need the DTM_CopY method as faras I can tell. I can't see a way of specifying unit for this.

Anyone know how?

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
I don't think it's possible

I don't think it's possible currently. AFAIK SaveDTObject()/DTM_WRITE only allows writing to files even when using DTWM_IFF, although technically I don't see why this couldn't be extended to allow writing to clipboard (for IFF based datatypes only of course) by f.e. specifying DTA_SourceType (or a new DTA_DestType which could be an alias for DTA_SourceType) as DTST_CLIPBOARD in the taglist similar to how it's done for reading with NewDTObject().

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Actually is is possible

Actually is is possible tocopy to the cluipboard allready using the DTM_COPY method. The method is not mentioned in the datatypes.libray autdoc but is mwentioned in the subclasses ie picture.datatype text.datatype etc.

Nowhere does it say how or whether you can choose the clipboard unit.

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
I doubt that you can select

I doubt that you can select clipboard unit with DTM_COPY because the BOOPSI message structure for it is this:

  1. /* DTM_REMOVEDTOBJECT, DTM_CLEARSELECTED, DTM_COPY, DTM_ABORTPRINT */
  2. struct dtGeneral
  3. {
  4. ULONG MethodID;
  5. struct GadgetInfo *dtg_GInfo;
  6. };

The only way I can think of it would be possible is if there was OM_SET:able attribute that I don't know about for setting which clipboard unit to use.

TSK
TSK's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-06-28 02:06
Re: Saveing / Loading to ClipBoard with datatypes

Do you guys have any working example code how to do this ?

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: Saveing / Loading to ClipBoard with datatypes

Reading from the clipboard is as easy as....

  1. LONG clip = unitnumber_required
  2.  
  3. dto = IDataTypes->NewDTObject(clip,
  4. DTA_SourceType,DTST_CLIPBOARD,
  5. DTA_GroupID,GID_PICTURE,
  6. PDTA_DestMode,PMODE_V43,
  7. TAG_DONE);
  8.  
  9. if(dto)
  10. {
  11. /* Do stuff */
  12. }
  13.  

Writing to the clip is as follows

  1. /* assumes your datatype object already exists and is suitable IFF type */
  2.  
  3. LONG clip = clipboardunitnumber
  4.  
  5. struct dtGeneral dtm;
  6. dtm.MethodID = DTM_COPY;
  7. dtm.dtg_GInfo = (struct GadgetInfo *)clip;
  8. IIntuition->IDoMethodA(dto,(Msg)&dtm);

It would appear that sometime after starting this thread I learn't about those clip unit number options, but I've no recollection of where I found it!

Log in or register to post comments