EditStreamRead     PROTO :DWORD, :DWORD, :DWORD, :DWORD

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

         mov     EditS.dwCookie, eax  ; Handle to input file
         mov     EditS.dwError, 0
         mov     EditS.pfnCallback, offset EditStreamRead
      INVOKE     SendMessage, hREdit, EM_STREAMIN, SF_RTF, addr EditS
; If the input is RTF you can read it in as plain text
      INVOKE     SendMessage, hREdit, EM_STREAMIN, SF_TEXT, addr EditS
                              ; eax = bytes read
;=====================================================================
; Edit Stream In Callback procedure - read from a file to a control
;=====================================================================
EditStreamRead PROC dwCookie:DWORD, pbBuff, cb, pcb
      INVOKE     ReadFile, dwCookie, pbBuff, cb, pcb, 0
         mov     eax, 0              ; Always return zero
EditStreamRead ENDP
