From: Alessandro Antonangeli on
Well you are so near to the solution! (I hope)
Reading the window help seems that you can store more different data
"The EmptyClipboard function empties the clipboard and frees handles to data
in the clipboard."
Please notice the word "handles", which is plural. So more handles, more set
of data. Probably you cannot have (easily) the same kind of data (not 2 RTF,
but 1 RTF and 1 text yes).

You cannot just put RTF text and hope that Window will understand that this
is not text but rtf or viceversa

Use an RTF control, than extract the plain text in an other variable
than
dwLen := SLen(cRTFText)
hText := GlobalAlloc(_OR(GMEM_MOVEABLE,GMEM_DDESHARE), dwLen+1)

// Put our string in the global memory...
pPTR := GlobalLock(hText)

IF ! OpenClipboard(NULL_PTR) .OR. (PTR(_CAST,pPTR) == NULL_PTR)
GlobalFree(hText)
RETURN SELF
ENDIF


EmptyClipboard()
MemCopyString(pPTR,cRTFText,dwLen)
GlobalUnlock(hText)

SetClipboardData(dwId, hText) //RTF

redo the same (without EmpyClipboard()) putting the plain text, NOT simply
SetClipboardData(CF_TEXT, hText)

doing as in your example will put the text comprensive of the RTF control:
so when you retrieve it , it will still contain them!

Sorry it's all teory, but may help
--
Ciao
Alessandro



"J�rgen Knauf" <j.knauf(a)kp-software.de> ha scritto nel messaggio
news:487e1b9f$1(a)news.arcor-ip.de...
> Allesandro,
>
> the problem is, you can only add additional formats to the clipboard but
> no data.
> I need a convertion in the clipboard from the rtf format to plain text.
>
> I have tried to change the SDK method "InsertRtf()" of the clipboard class
> and have added addional formats.
> But it doesn't work.
> ##########
> METHOD InsertRtf(cText) CLASS MyClipboard
> STATIC LOCAL dwId AS DWORD
> LOCAL hText AS PTR
> LOCAL pPTR AS PTR
> LOCAL dwLen AS DWORD
>
> // Get Clipboard format id for RTF.
> IF dwId == 0
> dwId := RegisterClipboardFormat(PSZ("Rich Text Format"))
> ENDIF
>
> IF IsString(cText) .AND. dwId > 0
> // Allocate global memory for transfer...
> dwLen := SLen(cText)
> hText := GlobalAlloc(_OR(GMEM_MOVEABLE,GMEM_DDESHARE), dwLen+1)
>
> // Put our string in the global memory...
> pPTR := GlobalLock(hText)
>
> IF ! OpenClipboard(NULL_PTR) .OR. (PTR(_CAST,pPTR) == NULL_PTR)
> GlobalFree(hText)
> RETURN SELF
> ENDIF
>
>
> EmptyClipboard()
> MemCopyString(pPTR,cText,dwLen)
> GlobalUnlock(hText)
>
> SetClipboardData(dwId, hText) //RTF
> SetClipboardData(CF_TEXT, hText)
> SetClipboardData(CF_OEMTEXT, hText)
> ...
> ...
> ############
>
> Juergen
>
>
> "Alessandro Antonangeli" <alcati(a)alcati.RemoveThis.com> schrieb im
> Newsbeitrag news:g5l2ii$v0u$1(a)aioe.org...
>>I was just courious and read just now.
>> For what i read you can do it quite easily (but may be it doesnt work,
>> never used it)
>>
>> 1) open the GUI sdk ClipBoard class
>> 2) based on method InsertRTF() and Insert(), make your own one called ie
>> InsertRTFAndText()
>> 3) copy the stuff from both method InsertRTF() and Insert()
>> 4) make sure you just call once at the beginning EmptyClipboard()
>>
>> If I well understood, you can put different data in the clipboard and
>> retrieve them based on the kind of data you need (windows also provide
>> conversion)
>>
>> let me know if it works (hope not to hang the pc <g>)
>>
>> --
>> Ciao
>> Alessandro
>>
>>
>> "J�rgen Knauf" <j.knauf(a)kp-software.de> ha scritto nel messaggio
>> news:487dbc04$1(a)news.arcor-ip.de...
>>> Hi,
>>>
>>> I want to copy a text into the clipboard, as a formated and as
>>> unformated text.
>>>
>>> How can I copy the text to the clipboard without clearing the old
>>> content?
>>>
>>> Juergen
>>>
>>>
>>>
>>
>>
>


From: Alessandro Antonangeli on
Ok, you win, you (and my curiosity <g>) made me work for you
here is a working sample
Create a window (here named Fiestra), put a RTF control on it (here called
oDCRTF) and a PushButton (here called Copia)
Copy some text from an editor (for example) OpenOffice with bold and some
other character effetcs and copy it in the RTF control
Press the Copia pushbutton
Then you will be able to copy it both on (for example) OpenOffice and
Notepad
--
Ciao
Alessandro

METHOD Copia( ) CLASS Finestra
LOCAL oClipBoard AS ClipBoard
oClipBoard:=Clipboard{}
oClipBoard:InsertRTFAndText(oDCRTF:VALUE,oDCRTF:CurrentText)
RETURN NIL

METHOD InsertRTFAndText(cRTFText,cText) CLASS ClipBoard
//PP-030929 New method
STATIC LOCAL dwId AS DWORD
LOCAL hText AS PTR
LOCAL pPTR AS PTR
LOCAL dwLen AS DWORD
// Get Clipboard format id for RTF.
IF dwId == 0
dwID := RegisterClipboardFormat(PSZ("Rich Text Format"))
ENDIF
IF IsString(cRTFText) .AND. dwId > 0
// Allocate global memory for transfer...
dwLen := SLen(cRTFText)
hText := GlobalAlloc(_OR(GMEM_MOVEABLE,GMEM_DDESHARE), dwLen+1)
// Put our string in the global memory...
pPTR := GlobalLock(hText)
IF ! OpenClipboard(NULL_PTR) .OR. (PTR(_CAST,pPTR) == NULL_PTR)
GlobalFree(hText)
RETURN SELF
ENDIF
// Empty anything already there...
EmptyClipboard()
MemCopyString(pPTR,cRTFText,dwLen)
GlobalUnlock(hText)
// Put data on the clipboard!
SetClipboardData(dwId, hText)
dwLen := SLen(cText)
hText := GlobalAlloc(_OR(GMEM_MOVEABLE,GMEM_DDESHARE), dwLen+1)
// Put our string in the global memory...
pPTR := GlobalLock(hText)
IF ! OpenClipboard(NULL_PTR) .OR. (PTR(_CAST,pPTR) == NULL_PTR)
GlobalFree(hText)
RETURN SELF
ENDIF
// Empty anything already there...
MemCopyString(pPTR,cText,dwLen)
GlobalUnlock(hText)
// Put data on the clipboard!
SetClipboardData(CF_TEXT, hText)
// Free memory...
// RvdH 061002 Memory may not be freed, is now owned by Clipboard
// GlobalFree(hText)
// Close clipboard...
CloseClipboard()
ENDIF
RETURN SELF


From: Alessandro Antonangeli on

"Geoff Schaller" <geoffx(a)softxwareobjectives.com.au> ha scritto nel
messaggio news:487ddb21(a)dnews.tpgi.com.au...
> No, there is only one format at once.
Not true
You could put in the clipboard both a picture (bitmap) and, for example, the
text explainig the picture: if the receiving application expects a picture
get the picture, it it expects text get the text

> there is only one format and it needs to know how to retrieve the data.
> You tell the receiving app that by setting the data content type.
The application which copy data tell which kind of data is inserted in the
clipboard.
The receiving app try to get from clipboard the kind of data it expect: if
not such kind of data exist, it get nothing (even if th clipboard has
something)
--
Ciao
Alessandro


From: Geoff Schaller on
Sorry - I was referring to the VO way it does things.
I referenced some C# which shows how to manage multiple formats.


"Alessandro Antonangeli" <alcati(a)alcati.RemoveThis.com> wrote in message
news:g5lj4n$vap$1(a)aioe.org:

> "Geoff Schaller" <geoffx(a)softxwareobjectives.com.au> ha scritto nel
> messaggio news:487ddb21(a)dnews.tpgi.com.au...
>
> > No, there is only one format at once.
>
> Not true
> You could put in the clipboard both a picture (bitmap) and, for example, the
> text explainig the picture: if the receiving application expects a picture
> get the picture, it it expects text get the text
>
>
> > there is only one format and it needs to know how to retrieve the data.
> > You tell the receiving app that by setting the data content type.
>
> The application which copy data tell which kind of data is inserted in the
> clipboard.
> The receiving app try to get from clipboard the kind of data it expect: if
> not such kind of data exist, it get nothing (even if th clipboard has
> something)
> --
> Ciao
> Alessandro

From: Geoff Schaller on
Camille.

Agreed. A good summary (better than mine).

Geoff

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: VO programmer in CZ (praha)
Next: Connect with TCP/IP