|
Prev: Dialog Window remains after EndDialog()
Next: HELP PLEASE: How to get longer fields than 255 chars with SqlConnection
From: Jürgen Knauf on 17 Jul 2008 01:49 Alessandro, THANK YOU!!!! That was the solution, you are great. Juergen "Alessandro Antonangeli" <alcati(a)alcati.RemoveThis.com> schrieb im Newsbeitrag news:g5lid9$s8a$1(a)aioe.org... > 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 > |