Date: 02-16-2022
Return to Index
created by gbSnippets
'Primary Code:
Function ExportRichEditGetRTF( ByVal hWndRTF As Long ) As String
Local ES As EDITSTREAM
Local sBuffer As String
es.dwCookie = VarPTR( sBuffer )
es.pfnCallback = Codeptr( ExportRTFCallback )
SendMessage( hWndRTF, %EM_STREAMOUT, %SF_RTF, VarPTR( es ) )
Function = sBuffer
End Function
Function ExportRichEditSaveRTF(ByVal sFileName As String ) As Long
Local FF As Long
Local sBuffer As String
sFileName = Trim$( Trim$( Trim$( sFileName ), $Dq ) )
If Len( sFileName ) = 0 Then Exit Function
If IsFile(sFileName) Then Kill sFileName
FF = FreeFile
Open sFileName For Binary Access Write As #FF
If Lof( FF ) Then Close #FF: Exit Function
sBuffer = ExportRichEditGetRTF( hRichEdit )
Put #FF,, sBuffer
Function = Lof( FF )
Close #FF
End Function
Function ExportRTFCallback( ByVal dwCookie As Dword, ByVal pbbuff As Byte Ptr, ByVal CB As Long, ByRef pcb As Long ) As Long
Local psBuffer As String Ptr
psBuffer = dwCookie
If CB < 1 Then Exit Function
@psBuffer = @psBuffer & Peek$( pbbuff, CB )
pcb = CB
End Function
'gbs_00229
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm