EditStreamWrite     PROTO :DWORD, :DWORD, :DWORD, :DWORD

;=====================================================================
; Writes to a file from a richedit control
;=====================================================================
LOCAL    EditS:EDITSTREAM

         mov     EditS.dwCookie, eax  ; Handle to output file
         mov     EditS.dwError, 0
         mov     EditS.pfnCallback, offset EditStreamWrite
      INVOKE     SendMessage, hREdit, EM_STREAMOUT, SF_RTF, addr EditS
; If the input is RTF you can write it out as plain text
      INVOKE     SendMessage, hREdit, EM_STREAMOUT, SF_TEXT, addr EditS
                              ; eax = bytes written
;=====================================================================
; Edit Stream Out Callback procedure - write to a file from a control
;=====================================================================
EditStreamWrite PROC dwCookie:DWORD, pbBuff, cb, pcb
      INVOKE     WriteFile, dwCookie, pbBuff, cb, pcb, 0
         mov     eax, 0              ; Must return zero
         ret
EditStreamWrite ENDP
