Announcement

Collapse
No announcement yet.

RTF file -- how to add an image into an RTF file programatically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RTF file -- how to add an image into an RTF file programatically

    Hi all

    Need help to add an image to a RTF file programmatically, and to bold some characters in the file.
    I have the following program which can create a RTF file and would like to add a bitmap image ( kinda like a logo ) at the top of the file.

    I'm not sure how to go about doing it, as well as setting the top line bold. Appreciate all help

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    
     GLOBAL OurCompany(),CustomerAddress(),month(), notes() AS STRING
     GLOBAL numNotes AS LONG
    
    
    FUNCTION PBMAIN () AS LONG
        DIM  OurCompany(1 TO 6)
        OurCompany(1) = "My Company Ltd"
        OurCompany(2) = "PO box 2234"
        OurCompany(3) = "63 Any Street  Suite 222"
        OurCompany(4)  = "Any City "
        OurCompany(5) = "Any State 46000"
        OurCompany(6) = "USA"
    
        DIM  CustomerAddress(1 TO 6)
        CustomerAddress(1) = "Customer Ltd"
        CustomerAddress(2) = "6334 Any Street  "
        CustomerAddress(3) = " Any where"
        CustomerAddress(4)  = "Any City "
        CustomerAddress(5) = "Any State 29999"
        CustomerAddress(6) = "USA"
    
    
        numNotes = 3
        DIM  notes(1 TO numNotes)
         notes(1) = "This is a test reminder"
         notes(2) = "Test only "
         notes(3) = "have a good day"
    
    
         DIM month(1 TO 12)
             month(1) = "January"
             month(2) = "February"
             month(3) = "March"
             month(4) = "April"
             month(5) = "May"
             month(6) = "June"
             month(7) = "July"
             month(8) = "August"
             month(9) = "September"
             month(10) = "October"
             month(11) = "November"
             month(12) = "December"
    
    
       ' creates the RTF file
        createRTFFile
    
    
    END FUNCTION
    
    
    
    
    'this routine creates an RTF file
    SUB createRTFFile
    
       LOCAL hFile, i, n, mo AS LONG
       LOCAL f, s, ss, tBorder, tTop, tLeft, tBottom, tRight AS STRING
       LOCAL msg , shstr AS STRING
       LOCAL sdate AS STRING
    
       hFile = FREEFILE
       f =  "MyFile.rtf"
       OPEN f FOR OUTPUT AS hFile
       tBORDER = "\brdrw10\brdrs"
       tTop    = "\clbrdrt"
       tLeft   = "\clbrdrl"
       tBottom = "\clbrdrb"
       tRight  = "\clbrdrr"
    
       'print the header and sender
       PRINT #hFile, "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}"
       PRINT #hFile, "{\pard \fs24 \qc \b \sl300\slmult1"
       FOR i = 1 TO 6
          IF LEN(OurCompany(i)) = 0 THEN
               EXIT FOR
          END IF
          PRINT #hFile, OurCompany(i) + "\line"
       NEXT i
       PRINT #hFile, "\par}"
    
       'print the Customer Address lines and date
       PRINT #hFile, "{\pard \tx7000 \fs20 \sl300\slmult1"
    
       sDate = DATE$
       mo = VAL(LEFT$(sDate, 2))
       ss = month(mo) + " " + MID$(sDate, 4, 2) + ", " + RIGHT$(sDate, 4)
    
    
       PRINT #hFile, CustomerAddress(1) + "\tab " + s + "\line"
       PRINT #hFile, CustomerAddress(2) + "\tab " + ss + "\line"
       PRINT #hFile, CustomerAddress(3) + "\line"
       PRINT #hFile, CustomerAddress(4) + "\line"
       PRINT #hFile, CustomerAddress(5) + "\line"
       PRINT #hFile, CustomerAddress(6) + "\line"
       PRINT #hFile, "\line \par}"
    
    
    
       'print the lines of the note
       PRINT #hFile, "\pard\fs16\line\line"
       FOR i = 1 TO numNotes
          PRINT #hFile, notes(i) + "\line"
       NEXT i
    
       PRINT #hFile, "}"
       CLOSE hFile
    
       ' display message
       msg = "The RTF file has been successfully created at:"
       MSGBOX msg + $CRLF + $CRLF + f, %MB_ICONINFORMATION, "RTF File"
    
       ' display the RTF file
       shstr = "c:\Program Files\Windows NT\Accessories\wordpad.exe " + $DQ + f + $DQ
       SHELL shstr
    END SUB

  • #2

    Sorry, I already have the bold characters but would still need a bitmap image place on the RTF file as detail below:

    Click image for larger version

Name:	logo on RTF.PNG
Views:	133
Size:	46.6 KB
ID:	783796

    Comment


    • #3
      Hope I'm proved wrong, but
      https://docs.microsoft.com/en-us/win...-edit-controls
      and RichEdit.inc have no mention of images.

      Complicates other things, have you considered HTML? Or maybe a graphic control?

      Cheers,
      Dale

      Comment


      • #4
        Within the last year, I'm pretty sure that Pierre has posted examples of putting images in RTF files.

        Comment


        • #5
          Can be done via OLE interface. I did a bigger example of this many years ago - should be in source code forum somewhere and I know both Pierre and José Roce has updated such code too. Following is from a "minimal" sample I once did - updated to compile with both PBWin9 and PBWin10. You need to adjust the path + .BMP file for $BMP to make it work, then picture will be inserted at caret's place in RichEdit.
          Click image for larger version

Name:	RE_InsBmp.jpg
Views:	118
Size:	18.6 KB
ID:	783803
          Code:
          #COMPILE EXE
          #DIM ALL
          '--------------------------------------------------------------------
          #INCLUDE "WIN32API.INC"
          #INCLUDE "RICHEDIT.INC"
          '--------------------------------------------------------------------
          %IDC_RICHEDIT = 141
          $BMP = "C:\PBWin10\samples\Objects\PowerThread\Lime.bmp" ' <- adjust bmp file name to insert
          
          '====================================================================
          FUNCTION PBMAIN () AS LONG
            LOCAL hDlg AS DWORD
          
            DIALOG NEW 0, "RTF Insert Picture",,, 225, 180, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
          
            '------------------------------------------------------------------
            LoadLibrary("RICHED32.DLL")
            CONTROL ADD "RICHEDIT", hDlg, %IDC_RICHEDIT, "<<< Inserted Picture..", 5, 5, 215, 170, _
                      %WS_CHILD OR %WS_VISIBLE OR %WS_VSCROLL OR %ES_MULTILINE OR _
                      %ES_SAVESEL OR %ES_DISABLENOSCROLL OR %ES_WANTRETURN OR _
                      %ES_AUTOVSCROLL, %WS_EX_CLIENTEDGE
          
            '-------------------------------------------------------------------
            DIALOG SHOW MODAL hDlg, CALL DlgProc
          
          END FUNCTION
          
          '======================================================================
          CALLBACK FUNCTION DlgProc() AS LONG
            LOCAL hEdit AS DWORD
          
            SELECT CASE CB.MSG
            CASE %WM_INITDIALOG
                hEdit = GetDlgItem(CBHNDL, %IDC_RICHEDIT)
                Reo_SetComInterface hEdit                   'initiate RichEdit's COM interface
                Reo_InsertObject hEdit, $BMP, "RichCom", "" ' insert BMP picture at caret's place
          
            END SELECT
          
          END FUNCTION
          
          '======================================================================
          '======================================================================
          DECLARE SUB Reo_InsertObject (BYVAL hEdit AS DWORD, BYVAL fName AS STRING, _
                                        BYVAL ProgName AS STRING, BYVAL DocName AS STRING)
          '------------------------------------------------------------
          %IDM_UNDO          = 1030 'equates for edit menu - see Reo_GetContextMenu
          %IDM_CUT           = 1032
          %IDM_COPY          = 1033
          %IDM_PASTE         = 1034
          %IDM_DELETE        = 1035
          %IDM_SELALL        = 1036
          %IDM_OBJECTCONVERT = 2000
          %IDM_OBJECTMIN     = 2001
          '--------------------------------------------------------------------
          $IID_IOleObject           = "00000112-0000-0000-C000-000000000046"
          '------------------------------------------------------------
          
          TYPE ReCbInterface 'User Defined Structure for the RichEdit callback interface
            pIntf    AS DWORD PTR
            Refcount AS DWORD
          END TYPE
          '--------------------------------------------------------------------
          ' Structures needed for embedding objects (like pictures) in RichEdit
          '--------------------------------------------------------------------
          TYPE GUID2
              Data1     AS DWORD
              Data2     AS WORD
              Data3     AS WORD
              Data4(7)  AS BYTE
          END TYPE
          
          ' Structure passed to Rich Edit GetObject and InsertObject
          ' The REOBJECT structure contains information about an object
          TYPE REOBJECT
            cbStruct  AS DWORD    ' Structure size, in bytes
            cp        AS LONG     ' Character position of the object
            clsid     AS GUID2 ' Class identifier of the object
            poleobj   AS DWORD    ' Points to an inst of IOleObject intf for object
            pstg      AS DWORD    ' Points to an inst of IStorage interface. This is the
                                  ' storage object associated with the object
            polesite  AS DWORD    ' Points to an instance of the IOleClientSite interface. This is the
                                  ' object's client site in the rich edit control. This address must
                                  ' have been obtained from the IRichEditOle::GetClientSite method
            sizel     AS SIZEL    ' A SIZEL structure specifying the size of the object. A 0, 0 on
                                  ' insertion indicates that an object is free to determine its size
                                  ' until the modify flag is turned off
            dvaspect  AS DWORD    ' Display aspect used. See DVASPECT for an explanation of possible values
            dwFlags   AS DWORD    ' object status flags
            dwUser    AS DWORD    ' user-defined value
          END TYPE
          
          TYPE PDVTARGETDEVICE
            tdSize             AS DWORD  'Longint
            tdDriverNameOffset AS WORD
            tdDeviceNameOffset AS WORD
            tdPortNameOffset   AS WORD
            tdExtDevmodeOffset AS WORD
          END TYPE
          
          #IF %PB_REVISION < &H1000  ' if compiler PBWIN9 or earlier
            TYPE FORMATETC
              cfFormat AS DWORD  ' Clipboard format of interest
              ptd      AS DWORD  ' Pointer to a DVTARGETDEVICE structure
              dwAspect AS DWORD  ' One of the DVASPECT enumeration constants
              lindex   AS LONG   ' Part of the aspect when the data must be split across page boundaries (-1)
              tymed    AS DWORD  ' One of the TYMED enumeration constants
            END TYPE
          #ELSE
            TYPE FORMATETC DWORD FILL
                cfFormat AS WORD  ' Clipboard format
                ptd      AS DVTARGETDEVICE PTR
                dwAspect AS DWORD
                lindex   AS LONG
                tymed    AS DWORD
            END TYPE
          #ENDIF
          
          'Main UDT used in OleUIInsertObject.
          TYPE OLEUIINSERTOBJECTTYPE   ' these in -fields are standard across all OLEUI dialog box functions.
            cbStruct       AS DWORD    ' Structure size
            dwFlags        AS DWORD    ' in-out Flags
            hWndOwner      AS DWORD    ' Owning window
            lpszCaption    AS DWORD    ' dialog caption bar contents  LPCSTR
            lpfnHook       AS DWORD    ' Hook callback                LPFNOLEUIHOOK
            lCustData      AS DWORD    ' Custom data to pass to hook  LPARAM
            hInstance      AS DWORD    ' Instance for customized template name
            lpszTemplate   AS DWORD    ' Customized template name     LPCSTR
            hResource      AS DWORD    ' customized template handle   HRSRC
            CLSID          AS GUID2 ' out: CLSID for class of the object to be inserted. Filled on output.
            ' Specifics for OLEUIINSERTOBJECT
            lpszFile       AS DWORD    ' in-out: filename for inserts or links  LPTSTR
            cchFile        AS LONG     ' IN: size of lpszfile buffer (%MAX_PATH)  (delphi - INTEGER?)
            cClsidExclude  AS LONG     ' IN: CLSIDs IN lpClsidExclude             (delphi - INTEGER?)
            lpClsidExclude AS DWORD    ' IN: List of CLSIDs to exclude from listing  LPCLSID
            iid            AS GUID2 ' IN: Requested interface on creation
            ' Specifics to create objects if flags say so.
            oleRender        AS DWORD   ' IN: Rendering option
            lpFormatEtc      AS DWORD  ' IN: Desired format                  LPFORMATETC
            lpIOleClientSite AS DWORD  ' IN: Site to be use for the object   LPOLECLIENTSITE
            lpIStorage       AS DWORD  ' IN: Storage used FOR the object     LPSTORAGE
            ppvObj           AS DWORD  ' OUT: Where the object is returned   LPVOID FAR *
            sc               AS DWORD  ' OUT: Result of creation calls       SCODE
            hMetaPict        AS DWORD  ' OUT: metafile aspect (METAFILEPICT) HGLOBAL
          END TYPE
          
          '--------------------------------------------------------------------
          '  Object flags
          '--------------------------------------------------------------------
          %REO_GETOBJ_NO_INTERFACES  = &H00000000
          %REO_GETOBJ_POLEOBJ        = &H00000001
          %REO_GETOBJ_PSTG           = &H00000002
          %REO_GETOBJ_POLESITE       = &H00000004
          %REO_GETOBJ_ALL_INTERFACES = &H00000007
          
          %REO_CP_SELECTION    = &HFFFFFFFF ' (-1)  Place object at selection
          %REO_IOB_SELECTION   = &HFFFFFFFF ' (-1)
          %REO_IOB_SELECTION   = &HFFFFFFFF ' (-1)
          %REO_IOB_USE_CP      = &HFFFFFFFE ' (-2)
          
          %REO_NULL            = &H00000000 ' Null is null..
          %REO_RESIZABLE       = &H00000001 ' Object may be resized.
          %REO_BELOWBASELINE   = &H00000002 ' Object sits below the baseline of the surrounding text; the default is to sit on the baseline.
          %REO_INVERTEDSELECT  = &H00000004 ' Object is to be drawn entirely inverted when selected; the default is to be drawn with a border.
          %REO_DYNAMICSIZE     = &H00000008 ' Object always determines its extents and may change despite the modify flag being turned off.
          %REO_BLANK           = &H00000010 ' Object is brand new. This gives the object an opportunity to save nothing and be deleted from the control automatically.
          %REO_DONTNEEDPALETTE = &H00000020 ' Prevents creation and realization of a half-tone palette before rendering the object. Applies to 32-bit platforms only.
          %REO_GETMETAFILE     = &H00400000 ' The rich edit control retrieved the metafile from the object to correctly determine the object's extents. ReadOnly.
          %REO_LINKAVAILABLE   = &H00800000 ' Object is a link and is believed to be available. ReadOnly.
          %REO_HILITED         = &H01000000 ' Object is currently highlighted to indicate selection. Occurs when focus is in the control and REO_SELECTED is set. ReadOnly.
          %REO_INPLACEACTIVE   = &H02000000 ' Object is currently in place active. ReadOnly.
          %REO_OPEN            = &H04000000 ' Object is currently open in its server. ReadOnly.
          %REO_SELECTED        = &H08000000 ' Object is currently selected in the rich edit control. ReadOnly.
          %REO_STATIC          = &H40000000 ' Object is a static object. ReadOnly.
          %REO_LINK            = &H80000000 ' Object is a link. ReadOnly.
          
          %RECO_PASTE = &H00000000
          %RECO_DROP  = &H00000001
          %RECO_COPY  = &H00000002
          %RECO_CUT   = &H00000003
          %RECO_DRAG  = &H00000004
          
          ' *** Flags for pdwEffect in Reo_GetDragDropEffect ***
          %DROPEFFECT_NONE   = 0
          %DROPEFFECT_COPY   = 1
          %DROPEFFECT_MOVE   = 2
          %DROPEFFECT_LINK   = 4
          %DROPEFFECT_SCROLL = &H80000000???
          
          ' *** Device Aspect Defines ***
          %DVASPECT_CONTENT     = 1
          
          ' *** storage medium defines ***
          %TYMED_NULL           = 0 ' No data is being passed
          
          ' *** STGM enumeration Defines ***
          %STGM_DIRECT           = &H00000000&
          %STGM_TRANSACTED       = &H00010000&
          %STGM_SIMPLE           = &H08000000&
          %STGM_READ             = &H00000000&
          %STGM_WRITE            = &H00000001&
          %STGM_READWRITE        = &H00000002&
          %STGM_SHARE_DENY_NONE  = &H00000040&
          %STGM_SHARE_DENY_READ  = &H00000030&
          %STGM_SHARE_DENY_WRITE = &H00000020&
          %STGM_SHARE_EXCLUSIVE  = &H00000010&
          %STGM_PRIORITY         = &H00040000&
          %STGM_DELETEONRELEASE  = &H04000000&
          %STGM_CREATE           = &H00001000&
          %STGM_CONVERT          = &H00020000&
          %STGM_FAILIFTHERE      = &H00000000&
          
          'Various..
          %DVASPECT_CONTENT   = 1
          %DVASPECT_THUMBNAIL = 2
          %DVASPECT_ICON      = 4
          %DVASPECT_DOCPRINT  = 8
          
          %TYMED_NULL     = 0
          %TYMED_HGLOBAL  = 1
          %TYMED_FILE     = 2
          %TYMED_ISTREAM  = 4
          %TYMED_ISTORAGE = 8
          %TYMED_GDI      = 16
          %TYMED_MFPICT   = 32
          %TYMED_ENHMF    = 64
          
          ' *** OLERENDER enumeration Defines ***
          %OLERENDER_NONE   = 0
          %OLERENDER_DRAW   = 1
          %OLERENDER_FORMAT = 2
          %OLERENDER_ASIS   = 3
          
          %OLEUPDATE_ALWAYS = 1
          %OLEUPDATE_ONCALL = 3
          
          '-----------------------------------
          %OLEIVERB_SHOW             = -1
          %OLEIVERB_PRIMARY          =  0
          %OLEIVERB_SHOW             = -1
          %OLEIVERB_OPEN             = -2
          %OLEIVERB_HIDE             = -3
          %OLEIVERB_UIACTIVATE       = -4
          %OLEIVERB_INPLACEACTIVATE  = -5
          %OLEIVERB_DISCARDUNDOSTATE = -6
          '-----------------------------------
          
          'Constants used in the dwFlags of OLEUIINSERTOBJECTTYPE.
          %IOF_SHOWHELP             = &H1     'Specifies that the dialog will display a Help button.
          %IOF_SELECTCREATENEW      = &H2     'Specifies that the Create New radio button will initially be checked. This cannot be used with IOF_SELECTCREATEFROMFILE.
          %IOF_SELECTCREATEFROMFILE = &H4     'Specifies that the Create From File radio button will initially be checked. This cannot be used with IOF_SELECTCREATENEW.
          %IOF_CHECKLINK            = &H8     'Specifies that the Link check box will initially be checked.
          %IOF_CHECKDISPLAYASICON   = &H10    'Specifies that the Display As Icon check box will initially be checked, the current icon will be displayed, and the Change Icon button will be enabled.
          %IOF_CREATENEWOBJECT      = &H20    'Specifies that a new object should be created when the user selects OK to dismiss the dialog box and the Create New radio button was selected.
          %IOF_CREATEFILEOBJECT     = &H40    'Specifies that a new object should be created from the specified file when the user selects OK to dismiss the dialog box and the Create From File radio button was selected.
          %IOF_CREATELINKOBJECT     = &H80    'Specifies that a new linked object should be created when the user selects OK to dismiss the dialog box and the user checked the Link check box.
          %IOF_DISABLELINK          = &H100   'Specifies that the Link check box will be disabled on initialization.
          %IOF_VERIFYSERVERSEXIST   = &H200   'Specifies that the dialog box should validate the classes it adds to the listbox by ensuring that the server specified in the registration database exists. This is a significant performance factor.
          %IOF_DISABLEDISPLAYASICON = &H400   'Specifies that the Display As Icon check box will be disabled on initialization.
          %IOF_HIDECHANGEICON       = &H800   'Hides the Change Icon button in the Insert Object dialog.
          %IOF_SHOWINSERTCONTROL    = &H1000  'Displays the Insert Control radio button.
          %IOF_SELECTCREATECONTROL  = &H2000  'Displays the Create Control radio button.
          
          'Return codes from OleUIInsertObject
          %OLEUI_FALSE   = 0  ' Unknown failure (unused).
          %OLEUI_SUCCESS = 1  ' No error, same as OLEUI_OK.
          %OLEUI_OK      = 1  ' The user pressed the OK button.
          %OLEUI_CANCEL  = 2  ' Cancel button pressed.
          
          %OLEUI_ERR_STANDARDMIN           = 100 'Errors common to all dialogs lie in the range OLEUI_ERR_STANDARDMIN to OLEUI_ERR_STANDARDMAX. This value allows the application to test for standard messages in order to display error messages to the user.
          %OLEUI_ERR_STRUCTURENULL         = 101 'The pointer to an OLEUIXXX structure passed into the function was NULL.
          %OLEUI_ERR_STRUCTUREINVALID      = 102 'Insufficient permissions for read or write access to an OLEUIXXX structure.
          %OLEUI_ERR_CBSTRUCTINCORRECT     = 103 'The cbstruct value is incorrect.
          %OLEUI_ERR_HWNDOWNERINVALID      = 104 'The hWndOwner value is invalid.
          %OLEUI_ERR_LPSZCAPTIONINVALID    = 105 'The lpszCaption value is invalid.
          %OLEUI_ERR_LPFNHOOKINVALID       = 106 'The lpfnHook value is invalid.
          %OLEUI_ERR_HINSTANCEINVALID      = 107 'The hInstance value is invalid.
          %OLEUI_ERR_LPSZTEMPLATEINVALID   = 108 'The lpszTemplate value is invalid.
          %OLEUI_ERR_HRESOURCEINVALID      = 109 'The hResource value is invalid.
          'Initialization errors
          %OLEUI_ERR_FINDTEMPLATEFAILURE   = 110 'Unable to find the dialog template.
          %OLEUI_ERR_LOADTEMPLATEFAILURE   = 111 'Unable to load the dialog template
          %OLEUI_ERR_DIALOGFAILURE         = 112 'Dialog initialization failed.
          %OLEUI_ERR_LOCALMEMALLOC         = 113 'A call to LocalAlloc or the standard IMalloc allocator failed.
          %OLEUI_ERR_GLOBALMEMALLOC        = 114 'A call to GlobalAlloc or the standard IMalloc allocator failed.
          %OLEUI_ERR_LOADSTRING            = 115 'Unable to LoadString localized resources from the library.
          %OLEUI_ERR_OLEMEMALLOC           = 116 ' (or 100?) 'A call to the standard IMalloc allocator failed.
          'Function Specific Errors
          %OLEUI_ERR_STANDARDMAX           = 117 '(or 116?) 'Errors common to all dialogs lie in the range OLEUI_ERR_STANDARDMIN to OLEUI_ERR_STANDARDMAX. This value allows the application to test for standard messages in order to display error messages to the user.
          %OLEUI_IOERR_LPSZFILEINVALID         = %OLEUI_ERR_STANDARDMAX + 0 'The lpszFile value is invalid or user has insufficient write access permissions.. This lpszFile member points to the name of the file linked to or inserted.
          %OLEUI_IOERR_LPSZLABELINVALID        = %OLEUI_ERR_STANDARDMAX + 1
          %OLEUI_IOERR_HICONINVALID            = %OLEUI_ERR_STANDARDMAX + 2
          %OLEUI_IOERR_LPFORMATETCINVALID      = %OLEUI_ERR_STANDARDMAX + 3 'The lpFormatEtc value is invalid. This member identifies the desired format.
          %OLEUI_IOERR_PPVOBJINVALID           = %OLEUI_ERR_STANDARDMAX + 4 'The ppvOjb value is invalid. This member points to the location where the pointer for the object is returned.
          %OLEUI_IOERR_LPIOLECLIENTSITEINVALID = %OLEUI_ERR_STANDARDMAX + 5 'The lpIOleClientSite value is invalid. This member points to the client site for the object.
          %OLEUI_IOERR_LPISTORAGEINVALID       = %OLEUI_ERR_STANDARDMAX + 6 'The lpIStorage value is invalid. This member points to the storage to be used for the object.
          %OLEUI_IOERR_SCODEHASERROR           = %OLEUI_ERR_STANDARDMAX + 7 'The sc member of lpIO has additional error information.
          %OLEUI_IOERR_LPCLSIDEXCLUDEINVALID   = %OLEUI_ERR_STANDARDMAX + 8 'The lpClsidExclude value is invalid. This member contains the list of CLSIDs to exclude.
          %OLEUI_IOERR_CCHFILEINVALID          = %OLEUI_ERR_STANDARDMAX + 9 'The cchFile or lpszFile value is invalid. The cchFile member specifies the size of the lpszFile buffer. The lpszFile  member points to the name of the file linked to or inserted.
          
          '--------------------------------------------------------------------
          ' *** OLE Functions ***
          '--------------------------------------------------------------------
          ' creates a byte array object based on global memory
          DECLARE FUNCTION CreateILockBytesOnHGlobal LIB "OLE32.DLL" ALIAS "CreateILockBytesOnHGlobal" _
                                  (BYVAL hGlobal AS DWORD, _         ' Memory handle allocated by the GlobalAlloc function
                                  BYVAL fDeleteOnRelease AS LONG, _  ' Determines whether the underlying handle for this
          _                                                          ' byte array object should be automatically freed
          _                                                          ' when the object is released.
                                  ppLkbyt AS DWORD _                 ' Address of ILockBytes pointer variable that receives
          _                                                          ' the interface pointer to the new byte array object
                                  ) AS DWORD
          
          'This function creates and opens a new compound file storage object on top of a byte array
          ' object provided by the caller
          DECLARE FUNCTION StgCreateDocfileOnILockBytes LIB "OLE32.DLL" ALIAS _
                          "StgCreateDocfileOnILockBytes" (plkbyt AS ANY, _  ' Points to the ILockBytes interface on byte array object
                                                          BYVAL grfMode AS DWORD, _   ' Specifies the access mode
                                                          BYVAL reserved AS DWORD, _  ' Reserved; must be zero
                                                          ppstgOpen AS ANY) AS LONG   ' Points to loc for returning new storage obj
          
          ' Retrieves a data object you can use to access the contents of the clipboard.
          DECLARE FUNCTION OleGetClipboard LIB "OLE32.DLL" ALIAS "OleGetClipboard" _
                           (ppDataObj AS DWORD _    ' receives the IDataObject interface ptr to clipboard data object
                           ) AS DWORD               '
          
          ' Creates an embedded object from a data transfer object retrieved either from the clipboard or as part
          ' of an OLE drag-and-drop operation
          DECLARE FUNCTION OleCreateFromData LIB "OLE32.DLL" ALIAS "OleCreateFromData" _
                                  (pSrcDataObj AS DWORD, _       ' Pointer to the data transfer object
                                  riid AS GUID2, _             ' Ref to id of intf to communicate with new obj (usually IID_IOleObject)
                                  BYVAL renderopt AS DWORD, _    ' Value from the enumeration OLERENDER
                                  pFormatEtc AS FORMATETC, _     ' Ptr to val from OLERENDER indicates capabilities object will have
                                  pClientSite AS DWORD, _        ' Ptr to an instance of IOleClientSite
                                  pStg AS DWORD, _               ' Ptr to the IStorage interface on storage obj. Must not be NULL
                                  ppvObj AS DWORD _              ' Addr of ptr variable that receives the intf ptr requested in riid
                                  ) AS DWORD
          
          DECLARE FUNCTION OleCreateFromFile LIB "OLE32.DLL" ALIAS "OleCreateFromFile" _
                          (rclsid AS GUID2, BYVAL lpszFileName AS ASCIIZ PTR, riid AS GUID2, _
                           BYVAL renderopt AS DWORD, pFormatEtc AS FORMATETC, _
                           pClientSite AS DWORD, pStg AS DWORD, ppvObj AS DWORD) AS DWORD
          
          DECLARE FUNCTION OleUIInsertObject LIB "OLEDLG.DLL" ALIAS "OleUIInsertObjectA" (inParam AS ANY) AS LONG
          
          DECLARE FUNCTION OleUIAddVerbMenu LIB "OLEDLG.DLL" ALIAS "OleUIAddVerbMenuA" _
                                           (lpOleObj      AS DWORD, _       'Points to the selected object
                                            lpszShortType AS ASCIIZ, _      'The short name corresponding to the object
                                            BYVAL hMenu         AS DWORD, _ 'The handle to the menu to modify
                                            BYVAL uPos          AS LONG, _  'The position of the menu item.
                                            BYVAL uIDVerbMin    AS LONG, _  'The value at which to start the verbs
                                            BYVAL uIDVerbMax    AS LONG, _  'The maximum ID value for object verbs (0 = no max..)
                                            BYVAL bAddConvert   AS LONG, _  'Specifies whether to add convert item
                                            BYVAL idConvert     AS DWORD, _ 'The value to use for the convert item
                                            lphMenu       AS DWORD) AS LONG 'Points to the cascading verb menu, if created
          '------------------------------------------------------------------------------
          ' Rich Edit OLE stuff
          DECLARE SUB      Reo_DoVerb          (BYVAL hEdit AS DWORD, BYVAL ioleverb AS LONG)
          DECLARE FUNCTION Reo_SetComInterface (BYVAL hWnd AS DWORD) AS LONG
          '------------------------------------------------------------------------------
          '  *** All OLE IUnknown methods ***
          DECLARE FUNCTION QueryInterface   (ppOleObj AS DWORD, REFIID AS GUID2, ppvObj AS DWORD) AS DWORD
          DECLARE FUNCTION Release          (ppOleObj AS DWORD) AS DWORD
          '  *** IRichEditOle methods ***
          DECLARE FUNCTION GetClientSite    (ppOleObj AS DWORD, pOleSite AS DWORD) AS DWORD
          DECLARE FUNCTION GetObjectCount   (ppOleObj AS DWORD) AS LONG
          DECLARE FUNCTION GetLinkCount     (ppOleObj AS DWORD) AS LONG
          DECLARE FUNCTION Reo_GetObject    (ppOleObj AS DWORD, BYVAL iob AS LONG, lpreobject AS REOBJECT, BYVAL dwFlags AS DWORD) AS DWORD
          DECLARE FUNCTION InsertObject     (ppOleObj AS DWORD, lpreobject AS REOBJECT) AS DWORD
          DECLARE FUNCTION ImportDataObject (ppOleObj AS DWORD, lpdataobj AS DWORD, BYVAL cf AS LONG, BYVAL hMetaPict AS DWORD) AS DWORD
          DECLARE FUNCTION SetHostNames     (ppOleObj AS DWORD, lpstrContainerApp AS ASCIIZ, lpstrContainerObj AS ASCIIZ) AS LONG
          '------------------------------------------------------------------------------
          DECLARE FUNCTION DoVerb           (ppOleObj AS DWORD, BYVAL iVerb AS LONG, lpmsg AS DWORD, _
                                             pActiveSite AS DWORD, BYVAL lindex AS LONG, BYVAL hwndParent AS DWORD, _
                                             lprcPosRect AS RECT) AS DWORD
          
          '====================================================================
          ' Initiate RichEdit's COM interface (OLE)
          '--------------------------------------------------------------------
          FUNCTION Reo_SetComInterface(BYVAL hEdit AS DWORD) AS LONG
            DIM pObj_RichCom  AS DWORD PTR
            DIM pReCbIfc      AS STATIC ReCbInterface
            DIM dwVTable(12)  AS STATIC DWORD
          
            'Initialize the OLE part.
            dwVTable( 0) = CODEPTR(Reo_QueryInterface)
            dwVTable( 1) = CODEPTR(Reo_AddRef)
            dwVTable( 2) = CODEPTR(Reo_Release)
            dwVTable( 3) = CODEPTR(Reo_GetNewStorage)
            dwVTable( 4) = CODEPTR(Reo_GetInPlaceContext)
            dwVTable( 5) = CODEPTR(Reo_ShowContainerUI)
            dwVTable( 6) = CODEPTR(Reo_QueryInsertObject)
            dwVTable( 7) = CODEPTR(Reo_DeleteObject)
            dwVTable( 8) = CODEPTR(Reo_QueryAcceptData)
            dwVTable( 9) = CODEPTR(Reo_ContextSensitiveHelp)
            dwVTable(10) = CODEPTR(Reo_GetClipboardData)
            dwVTable(11) = CODEPTR(Reo_GetDragDropEffect)
            dwVTable(12) = CODEPTR(Reo_GetContextMenu)
          
            pReCbIfc.pIntf    = VARPTR(dwVTable(0))
            pReCbIfc.Refcount = 1
          
            FUNCTION = SendMessage(hEdit, %EM_SETOLECALLBACK, 0, VARPTR(pReCbIfc))
          END FUNCTION
          
          '====================================================================
          ' Methods of the IUnknown interface
          '--------------------------------------------------------------------
          FUNCTION Reo_QueryInterface (BYVAL pObject AS DWORD, REFIID AS DWORD, ppvObj AS DWORD) AS DWORD
            FUNCTION = %S_OK
          END FUNCTION
          
          '====================================================================
          FUNCTION Reo_AddRef (BYVAL pObject AS DWORD PTR) AS DWORD
            INCR @pObject[1]
            FUNCTION = @pObject[1]
          END FUNCTION
          
          '====================================================================
          FUNCTION Reo_Release (BYVAL pObject AS DWORD PTR) AS DWORD
            IF @pObject[1] > 0 THEN
               DECR @pObject[1]
               FUNCTION = @pObject[1]
            ELSE
               pObject = 0
            END IF
          END FUNCTION
          
          '====================================================================
          ' Methods of the IRichEditOleCallback interface
          ' Provides the application and document level interfaces and information
          ' required to support in-place activation
          '--------------------------------------------------------------------
          FUNCTION Reo_GetInPlaceContext (BYVAL pObject AS DWORD PTR, lplpFrame AS DWORD, _
                                            lplpDoc AS DWORD, lpFrameInfo AS DWORD) AS DWORD
            FUNCTION = %E_NOTIMPL
          END FUNCTION
          
          '====================================================================
          ' Tells the application whether to display its container user interface
          '--------------------------------------------------------------------
          FUNCTION Reo_ShowContainerUI (BYVAL pObject AS DWORD PTR, fShow AS LONG) AS DWORD
            FUNCTION = %E_NOTIMPL
          END FUNCTION
          
          '====================================================================
          ' Queries the application as to whether an object should be inserted.
          '--------------------------------------------------------------------
          FUNCTION Reo_QueryInsertObject (BYVAL pObject AS DWORD PTR, lpclsid AS DWORD, _
                                          BYVAL lpstg AS DWORD PTR, cp AS LONG) AS DWORD
            FUNCTION = %S_OK  ' Yes, we'd love to have this object inserted
          END FUNCTION
          
          '====================================================================
          ' Notification that an object is about to be deleted from a rich edit control
          '--------------------------------------------------------------------
          FUNCTION Reo_DeleteObject (BYVAL pObject AS DWORD PTR, lpoleobj AS DWORD) AS DWORD
            FUNCTION = %E_NOTIMPL
          END FUNCTION
          
          '====================================================================
          ' Called on a paste or drag to determine if the data pasted/dragged should be accepted
          '--------------------------------------------------------------------
          FUNCTION Reo_QueryAcceptData (BYVAL pObject AS DWORD PTR, lpdataobj AS DWORD, _
                                             lpcfFormat AS DWORD, reco AS DWORD, _
                                             fReally AS LONG, hMetaPict AS DWORD) AS DWORD
            FUNCTION = %S_OK ' Yes, we'd love to have this data accepted
          END FUNCTION
          
          '====================================================================
          ' Tells the application that it should transition into or out of context sensitive help mode
          '--------------------------------------------------------------------
          FUNCTION Reo_ContextSensitiveHelp (BYVAL pObject AS DWORD PTR, fEnterMode AS LONG) AS DWORD
            FUNCTION = %E_NOTIMPL
          END FUNCTION
          
          '====================================================================
          ' Allows the client to supply its own clipboard object
          '--------------------------------------------------------------------
          FUNCTION Reo_GetClipboardData (BYVAL pObject AS DWORD PTR, lpchrg AS DWORD, _
                                         reco AS DWORD, lplpdataobj AS DWORD) AS DWORD
            FUNCTION = %E_NOTIMPL
          END FUNCTION
          
          '====================================================================
          ' Allows the client to specify the effects of a drop operation
          '--------------------------------------------------------------------
          FUNCTION Reo_GetDragDropEffect (BYVAL pObject AS DWORD PTR, fDrag AS LONG, _
                                            grfKeyState AS DWORD, pdwEffect AS DWORD) AS DWORD
          '  pdwEffect = %DROPEFFECT_NONE 'to disable drag&drop for object
            FUNCTION = %E_NOTIMPL        ' delegate back to RichEdit
          END FUNCTION
          
          '======================================================================
          ' Queries the application for a context menu to use on a right mouse down
          ' If you use a right click context menu, it won't work until you create it here
          ' and pass the handle to lphmenu & return %S_OK. Note, RichEdit destroys the
          ' menu when it's done with it, so we don't have to bother about that part.
          '----------------------------------------------------------------------
          FUNCTION Reo_GetContextMenu (BYVAL pObject AS DWORD PTR, BYVAL seltype AS WORD, _
                                       BYVAL lpoleobj AS DWORD PTR, BYVAL lpchrg AS CHARRANGE PTR, _
                                       lphmenu AS DWORD) AS DWORD
          
            LOCAL hEdit AS DWORD, hmenu AS DWORD, hmenuVerbs AS DWORD
            LOCAL uiT   AS DWORD, uiT2 AS DWORD, uiT3 AS DWORD, uiT4 AS DWORD
            LOCAL lRes  AS LONG
          
            hEdit = GetFocus 'should be..
            hmenu = CreatePopupMenu()
            IF hmenu = 0 THEN EXIT FUNCTION
          
            uiT  = %MF_STRING OR %MF_BYCOMMAND 'set up some flags for Edit menu
            uiT  = uiT OR IIF&(@lpchrg.cpMin <> @lpchrg.cpMax, %MF_ENABLED, %MF_GRAYED)
            uiT2 = %MF_STRING OR %MF_BYCOMMAND
            uiT2 = uiT2 OR IIF&(SendMessage(hEdit, %EM_CANPASTE, 0, 0), %MF_ENABLED, %MF_GRAYED)
            uiT3 = %MF_STRING OR %MF_BYCOMMAND
            uiT3 = uiT3 OR IIF&(SendMessage(hEdit, %WM_GETTEXTLENGTH, 0, 0), %MF_ENABLED, %MF_GRAYED)
            uiT4 = %MF_STRING OR %MF_BYCOMMAND
            uiT4 = uiT4 OR IIF&(SendMessage(hEdit, %EM_CANUNDO, 0, 0), %MF_ENABLED, %MF_GRAYED)
          
            IF lpoleobj THEN 'if we have a pointer to the object, Put the verbs on the menu
               lRes = OleUIAddVerbMenu(@lpoleobj, "", hMenu, 0, %IDM_OBJECTMIN, _
                                       0, %FALSE, %IDM_OBJECTCONVERT, hmenuVerbs)
                                          ' %FALSE, because convert dlg is not implemented, yet..
          
               IF lRes = 0 THEN      ' on failure, a disabled item has been added to given menu
                  DestroyMenu hMenu  ' destroy menu, and create new for plain edit menu commands..
                  hMenu = CreatePopupMenu()
               ELSE 'on success, add a separator before the Edit menu items
                  AppendMenu hmenu, %MF_SEPARATOR, 0, BYVAL %NULL
               END IF
            END IF
          
            'add some Edit menu verbs (verbs = commands)
            'note - all these "verbs" (id's) will be triggered under parent dialog's WM_COMMAND on select
            AppendMenu hmenu, uiT4, %IDM_UNDO,   "&Undo"
            AppendMenu hmenu, %MF_SEPARATOR, 0,  ""
            AppendMenu hmenu, uiT,  %IDM_CUT,    "Cut"
            AppendMenu hmenu, uiT,  %IDM_COPY,   "Copy"
            AppendMenu hmenu, uiT2, %IDM_PASTE,  "&Paste"
            AppendMenu hmenu, uiT,  %IDM_DELETE, "Delete"
            AppendMenu hmenu, %MF_SEPARATOR, 0,  ""
            AppendMenu hmenu, uiT3, %IDM_SELALL, "Select &all"
          
            lphmenu = hmenu 'return handle of menu
            FUNCTION = %S_OK
          END FUNCTION
          
          '======================================================================
          ' Get storage interface for a new object
          '----------------------------------------------------------------------
          FUNCTION Reo_GetNewStorage (BYVAL pObject AS DWORD PTR, lplpstg AS DWORD) AS DWORD
            LOCAL sc          AS DWORD
            LOCAL lpLockBytes AS DWORD PTR
          
            ' Create a byte array in global memory -
            sc = CreateILockBytesOnHGlobal(BYVAL 0, BYVAL 1, lpLockBytes)
          
            IF sc THEN FUNCTION = sc : EXIT FUNCTION
          
            'and a compound file storage object.
            sc = StgCreateDocfileOnILockBytes(@lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _
                                              %STGM_READWRITE OR %STGM_CREATE, BYVAL 0, lplpstg)
          
            IF sc THEN CALL DWORD @@lpLockBytes[2] USING Reo_Release(@lpLockBytes)
          
            FUNCTION = sc
          END FUNCTION
          
          '====================================================================
          ' *** HELPER FUNCTIONS ***
          '--------------------------------------------------------------------
          SUB Str2Clsid(ClsidStr AS STRING, gClsid AS GUID2)
            LOCAL i AS LONG
            gClsid.Data1      = VAL("&H0" & LEFT$(ClsidStr, 8))
            gClsid.Data2      = VAL("&H0" & MID$(ClsidStr, 10, 4))
            gClsid.Data3      = VAL("&H0" & MID$(ClsidStr, 15, 4))
            gClsid.Data4(0)   = VAL("&H0" & MID$(ClsidStr, 20, 2))
            gClsid.Data4(1)   = VAL("&H0" & MID$(ClsidStr, 22, 2))
            FOR i = 0 TO 5
                gClsid.Data4(i + 2) = VAL("&H0" & MID$(ClsidStr, 25 + (i * 2), 2))
            NEXT
          END SUB
          
          '====================================================================
          ' ansiUCODE$ - Thanks to Dave Navarro
          '--------------------------------------------------------------------
          FUNCTION StrToUnicode(BYVAL s AS STRING) AS STRING
              DIM Buffer AS STRING
              Buffer = STRING$(LEN(s) * 2, $NUL)
              MultiByteToWideChar %CP_ACP, _      ' code page
                  %NULL, _                        ' performance and mapping flags
                  BYVAL STRPTR(s), _              ' ANSI string to convert
                  LEN(s), _                       ' len of ANSI string
                  BYVAL STRPTR(Buffer), _         ' buffer for Unicode string
                  LEN(Buffer)                     ' len of Unicode buffer
          
              FUNCTION = Buffer
          END FUNCTION
          
          '====================================================================
          ' Delete MetaFile or MetaFile handle
          '--------------------------------------------------------------------
          SUB DestroyMetaPict (BYVAL hMetaFile AS DWORD)
            IF hMetaFile THEN
              LOCAL pMF AS DWORD
              pMF = GlobalLock(hMetaFile)
              IF pMF THEN DeleteMetaFile pMF
              GlobalUnlock hMetaFile
              GlobalFree hMetaFile
            END IF
          END SUB
          
          '====================================================================
          ' wrapper for iOleObject's DoVerb
          '--------------------------------------------------------------------
          SUB Reo_DoVerb (BYVAL hEdit AS DWORD, BYVAL ioleverb AS LONG)
            LOCAL ppObject AS DWORD PTR, pOleObj AS DWORD PTR, pOleSite AS DWORD PTR, _
                  sc AS DWORD, IID_IIntf AS GUID2
            LOCAL reobj AS REOBJECT
            LOCAL pt    AS POINTAPI
            LOCAL rc    AS RECT
            LOCAL cr    AS CHARRANGE
          
            'Get the Richedit OLE Interface pointer
            SendMessage hEdit, %EM_GETOLEINTERFACE, %NULL, VARPTR(ppObject)
            SendMessage hEdit, %EM_EXGETSEL, 0, VARPTR(cr)
          
            reobj.cbStruct = LEN(reobj)
            reobj.cp       = %REO_CP_SELECTION
            CALL DWORD @@ppObject[6] USING Reo_GetObject(@ppObject, %REO_IOB_SELECTION, reobj, _
                                                         %REO_GETOBJ_POLESITE OR %REO_GETOBJ_POLEOBJ) TO sc
            IF sc <> %S_OK THEN GOTO DoVerbExit
          
            pOleObj  = reobj.poleobj
            pOleSite = reobj.polesite
            SendMessage hEdit, %EM_POSFROMCHAR, VARPTR(pt), reobj.cp
          
            LOCAL hDC AS DWORD
            hDC = GetDC(%NULL)
            rc.nRight  = MulDiv(reObj.sizel.cx, GetDeviceCaps(hDC, %LOGPIXELSX), 2540)
            rc.nBottom = MulDiv(reObj.sizel.cy, GetDeviceCaps(hDC, %LOGPIXELSY), 2540)
            ReleaseDC %NULL, hDC
            OffsetRect rc, pt.x, pt.y
          
            CALL DWORD @@pOleObj[11] USING DoVerb(@pOleObj, ioleverb, %NULL, _
                                                  @pOleSite, 0, hEdit, rc) TO sc
          
          DoVerbExit:
            IF pOleObj  THEN CALL DWORD @@pOleObj[2]  USING Release(@pOleObj)
            IF pOleSite THEN CALL DWORD @@pOleSite[2] USING Release(@pOleSite)
            IF ppObject THEN CALL DWORD @@ppObject[2] USING Release(@ppObject)
          
          END SUB
          
          '====================================================================
          ' Insert Object (OLE)
          '--------------------------------------------------------------------
          SUB Reo_InsertObject (BYVAL hEdit AS DWORD, BYVAL fName AS STRING, _
                                BYVAL ProgName AS STRING, BYVAL DocName AS STRING)
            LOCAL ppObject AS DWORD PTR, lpIStorage AS DWORD PTR, _
                  ppOleSite AS DWORD PTR, pOleObj AS DWORD PTR, sc AS DWORD, rc AS RECT
            LOCAL IID_IIntf AS GUID2, reo AS REOBJECT, sz AS SIZEL, fetc AS FORMATETC
          
            'RichEdit must have focus
            SetFocus hEdit
          
            'Get the Richedit OLE Interface pointer
            SendMessage hEdit, %EM_GETOLEINTERFACE, %NULL, VARPTR(ppObject)
          
            'We need a storage interface
            Reo_GetNewStorage 0, lpIStorage
          
            CALL DWORD @@ppObject[10] USING SetHostNames(@ppObject, BYCOPY ProgName, BYCOPY DocName) TO sc
            IF sc = %E_OUTOFMEMORY THEN
               MSGBOX "Cannot allocate memory for host name."
               GOTO Reo_InsertExit
            END IF
          
            'Get RichEdit's client site interface pointer
            CALL DWORD @@ppObject[3] USING GetClientSite(@ppObject, ppOleSite) TO sc
            IF sc THEN GOTO Reo_InsertExit
          
            'Init CLSID of IOleObject
            LSET IID_IIntf = GUID$("{" & $IID_IOleObject & "}")
          
          '-------------------------
            IF LEN(fName) THEN             ' insert picture from path
               fName = StrToUnicode(fName) ' file name need to be a multi-byte wide string
               sc = OleCreateFromFile(BYVAL %NULL, STRPTR(fName), _
                                      IID_IIntf, %OLERENDER_DRAW, BYVAL %NULL, _
                                      @ppOleSite, @lpIStorage, pOleObj)
               IF sc <> %S_OK THEN GOTO Reo_InsertExit
          
            ELSE ' insert object via OLE imsert dialog
               LOCAL szBuffer AS ASCIIZ * %MAX_PATH
               LOCAL io AS OLEUIINSERTOBJECTTYPE, gClsid AS GUID2
               'common IN-fields
               io.cbStruct         = SIZEOF(OLEUIINSERTOBJECTTYPE)
               io.dwFlags          = %IOF_CREATENEWOBJECT OR %IOF_CREATEFILEOBJECT OR _
                                     %IOF_SELECTCREATENEW OR %IOF_CREATELINKOBJECT
               io.hWndOwner        = GetParent(hEdit)
               io.clsid            = gClsid
               ' Specifics for OLEUIINSERTOBJECT
               io.lpszFile         = VARPTR(szBuffer)
               io.cchFile          = SIZEOF(szBuffer)
               io.iid              = IID_IIntf
               io.oleRender        = %OLERENDER_DRAW
               io.lpIOleClientSite = ppOleSite
               io.lpIStorage       = lpIStorage
               io.ppvObj           = VARPTR(pOleObj)
          
               MOUSEPTR 11 ' Note - insert object dialog resets mouse..
               sc = OleUIInsertObject(BYVAL VARPTR(io)) 'call up OLE insert object dialog
               MOUSEPTR 1  ' but to make sure..
          
               IF sc <> %OLEUI_SUCCESS THEN GOTO Reo_InsertExit
            END IF
          '-------------------------
          
            'Fill the REOBJECT structure
            reo.cbstruct    = SIZEOF(reo)
            reo.cp          = %REO_CP_SELECTION
            reo.clsid       = IID_IIntf
            reo.poleobj     = pOleObj
            reo.pstg        = lpIStorage
            reo.polesite    = ppOleSite
            reo.sizel       = sz
            reo.dvaspect    = %DVASPECT_CONTENT
            reo.dwFlags     = %REO_RESIZABLE
            reo.dwUser      = %NULL
          
            'Insert the object into Richedit at the current selection point
            CALL DWORD @@ppObject[7] USING InsertObject(@ppObject, reo)
            IF sc = %E_OUTOFMEMORY THEN
               MSGBOX "Memory could not be allocated for this object."
               GOTO Reo_InsertExit
            END IF
          
          '  'Do show verb only on new objects via OLE dialog, not pictures
            IF LEN(fName) = 0 AND (io.dwFlags AND %IOF_SELECTCREATENEW) THEN
               CALL DWORD @@pOleObj[11] USING DoVerb(@pOleObj, %OLEIVERB_SHOW, %NULL, _
                                                     @ppOleSite, 0, hEdit, rc) TO sc
            END IF
          
          Reo_InsertExit:        
            'Release the interfaces
            IF io.hMetaPict THEN CALL DestroyMetaPict(io.hMetaPict)
            IF pOleObj      THEN CALL DWORD @@pOleObj[2]    USING Release(@pOleObj)
            IF ppOleSite    THEN CALL DWORD @@ppOleSite[2]  USING Release(@ppOleSite)
            IF lpIStorage   THEN CALL DWORD @@lpIStorage[2] USING Release(@lpIStorage)
            IF ppObject     THEN CALL DWORD @@ppObject[2]   USING Release(@ppObject)
          
          END SUB

          Comment


          • #6
            But, thinking about it - why not create a logotype picture in Paint with your company info in bold text next to the picture, insert this picture into an RTF file in WordPad so the file would be ready to open/insert customer data below logotype picture? Sure would save a lot of hassle and code.

            Comment


            • #7
              Thanks Borje
              I will use your method in post #6 which is much simpler than your #5 ( this is way beyond my ability!)

              Comment


              • #8
                Jeez, I'd definitely make everything after
                '====================================================================== '====================================================================== into an include file

                Comment


                • #9
                  Originally posted by Tim Lakinir View Post
                  Thanks Borje
                  I will use your method in post #6 which is much simpler than your #5 ( this is way beyond my ability!)
                  Not if you just accept the OLE stuff as given and put it in an include. (Good job MCM isn't around to give me h* for suggesting "copy and paste without understanding"(

                  Comment


                  • #10
                    Hi Borje Hagsten

                    I wasn't able to compile your post #5 with Jose Roca includes ? gotten lots of errors like "Parameter mismatches definition"
                    as review below

                    Code:
                    Error 480 in C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas(565:008):  Parameter mismatches definition
                      Line 565:   sc = StgCreateDocfileOnILockBytes(BYREF @lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _  
                    
                    Saving files...
                    Files saved.
                    Compiling "C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas"
                    Error 480 in C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas(565:038):  Parameter mismatches definition
                      Line 565:   sc = StgCreateDocfileOnILockBytes( lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _  
                    
                    Saving files...
                    Files saved.
                    Compiling "C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas"
                    Error 480 in C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas(565:038):  Parameter mismatches definition
                      Line 565:   sc = StgCreateDocfileOnILockBytes( @@lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _  
                    
                    Saving files...
                    Files saved.
                    Compiling "C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas"
                    Error 480 in C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas(565:044):  Parameter mismatches definition
                      Line 565:   sc = StgCreateDocfileOnILockBytes( BYVAL lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _  
                    
                    Saving files...
                    Files saved.
                    Compiling "C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas"
                    Error 480 in C:\PB\Rich Edit progs\Embed Bitmap image\Embed Bmp.bas(565:039):  Parameter mismatches definition
                      Line 565:   sc = StgCreateDocfileOnILockBytes(  lpLockBytes, BYVAL %STGM_SHARE_EXCLUSIVE OR _

                    Comment


                    • #11
                      Did you try PB includes?
                      Dale

                      Comment


                      • #12
                        I don't have José's include files so can't say why, but error messages indicates declaration for StgCreateDocfileOnILockBytes is different in his files. Original code was from 2003, so could be something has been corrected by José since. He knows this stuff best. Maybe he already has a complete RichEdit OLE / Com interface in his include files? Then you can try removing everything below the double '==== lines and recompile.

                        Comment


                        • #13
                          Thanks to both of you, I will just stick to Borje's suggestion in #6 as bringing in an image into RTF is too complicated

                          Comment

                          Working...
                          X