Announcement

Collapse
No announcement yet.

Richedit - creating tables

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

  • Richedit - creating tables

    A couple of questions:

    1. Do I need to modify RichEdit.inc for use with msfedit.dll (version 4.1)?

    2. I am trying to create a table using rtf. Is this possible?

    I send a copy of the rtf code which works with MSWord2003 but all the table commands seem to be ignored.

    (Added Later: - yes you can create tables! I missed two vital commands in my rtf)

    Bob
    Last edited by Robert Wallace; 27 Feb 2009, 08:04 AM. Reason: Found test data error

  • #2
    Cliff Nichols' "RTF made easy post" here .... http://www.powerbasic.com/support/pb...light=richedit

    ... might have some useful code for you.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      MCM - thanks for info - I had found the link.

      I do have a major problem though - I cannot enable multi-line in a table cell in Richedit although the rtf works OK in MSWord.

      Bob

      Comment


      • #4
        You don't need (to modify) RichEdit.inc to use MSFTEDIT.DLL
        But it does look like you will need Ver.4.1 to have multi-line table cells.

        That means loading the library and using the appropriate class control. Something like ..
        Code:
        #COMPILE EXE
        #INCLUDE "WIN32API.INC"
         
        '*** #INCLUDE "RichEdit.inc"  'or just define one Type and couple of Equates
        TYPE EDITSTREAM DWORD                                                       '
          dwCookie AS DWORD    ' user value passed to callback as first parameter   '
          dwError AS DWORD     ' last error                                         '
          pfnCallback AS DWORD                                                      '
        END TYPE                                                                    '
                                                                                    '
        %EM_STREAMIN    = %WM_USER + 73                                             '
        %SF_RTF         = &H0002                                                    '
        '***                                                                        '
         
        %IDC_RICHEDIT1  = 101
         
        FUNCTION REStreamInCB(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
          pcb = MIN(LEN(@psBuffer), cb)
          IF pcb > 0 THEN
            POKE$ pbBuff, LEFT$(@psBuffer, pcb)
            @psBuffer = MID$(@psBuffer, pcb + 1)
          END IF
         
        END FUNCTION
        '------------------/REStreamInCB
         
        FUNCTION REStreamIn(BYVAL hEd AS DWORD, BYVAL sBuffer AS STRING, BYVAL StrmFmt AS LONG) AS LONG
         LOCAL ES AS EDITSTREAM
         
          ES.dwCookie    = VARPTR(sBuffer)
          ES.pfnCallback = CODEPTR(REStreamInCB)
         
         FUNCTION = SendMessage(hEd, %EM_STREAMIN, StrmFmt, VARPTR(ES))
        END FUNCTION
        '------------------/REStreamIn
         
        CALLBACK FUNCTION DlgProc()
         STATIC RtfStr, TempStr AS STRING
          SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
              RtfStr = _
              "{\rtf1\ansi\ansicpg1252\deff0\deflang1033"+$CRLF+ _
              "{\fonttbl"+$CRLF+ _
              "{\f0\fswiss\fcharset0 Arial;}"+$CRLF+ _
              "{\f1\froman\fprq2\fcharset0 Times New Roman;}"+$CRLF+ _
              "{\f2\fnil\fprq2\fcharset2 Wingdings;}}"+$CRLF+ _
              "{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20\par"+$CRLF+ _
              "\trowd\trgaph108\trleft-108\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 "+$CRLF+ _
              "\trbrdrb\brdrs\brdrw10 \trpaddl108\trpaddr108\trpaddfl3\trpaddfr3"+$CRLF+ _
              "\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs "+$CRLF+ _
              "\cellx2040\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs "+$CRLF+ _
              "\cellx4320\pard\intbl\lang3081\f1\fs24 Cell 1.1\line Multiline?\line Oh Yeah \f2 J\f1\cell "+$CRLF+ _
              "Cell 1.2\cell\row\trowd\trgaph108\trleft-108\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 "+$CRLF+ _
              "\trbrdrb\brdrs\brdrw10 \trpaddl108\trpaddr108\trpaddfl3\trpaddfr3"+$CRLF+ _
              "\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs "+$CRLF+ _
              "\cellx2040\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs "+$CRLF+ _
              "\cellx4320\pard\intbl Cell 2.1\cell Cell 2.2\cell\row\pard\lang1033\f0\fs20\par"+$CRLF+ _
              "}"
              DIALOG POST CBHNDL, %WM_USER + 1000, 0, 0
         
            CASE %WM_USER + 1000
              'Control Set Text CbHndl, %IDC_RICHEDIT1, RtfStr                        ' only w/RichEdit ver 1.0!
              REStreamIn GetDlgItem(CBHNDL, %IDC_RICHEDIT1), RtfStr, %SF_RTF          ' ver 2.0 +
         
            CASE %WM_SYSCOMMAND
              IF CBWPARAM AND &H0FFF0 = %SC_CLOSE THEN
                DIALOG END CBHNDL
              END IF
         
          END SELECT
        END FUNCTION
        '------------------/DlgProc
         
        FUNCTION PBMAIN()
         LOCAL hDlg  AS DWORD
         'LoadLibrary("RichEd32.dll")                                                 ' No good for multiline
         LoadLibrary("MSFTEDIT.DLL")                                                  ' <-- V4.1
         
          DIALOG NEW 0, "RE 4.1 Test", , , 240, 120, %WS_CAPTION OR %WS_SYSMENU, TO hDlg
            'CONTROL ADD "RichEdit", hDlg, %IDC_RICHEDIT1, " ", 5, 5, 230, _          ' use w / Riched32.dll
            CONTROL ADD "RichEdit50W", hDlg, %IDC_RICHEDIT1, " ", 5, 5, 230, 90, _    ' <--  V4.1
                %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %ES_MULTILINE OR %ES_AUTOVSCROLL OR %ES_WANTRETURN
         
          DIALOG SHOW MODAL hDlg, CALL DlgProc
         
        END FUNCTION
        '------------------/PBMain
        Rgds, Dave

        Comment


        • #5
          Hi Dave,

          Many thanks for your code - it gave me a working master that enabled me to find what was wrong with my code.

          Eventually it had nothing to do with my RTF or code but an illegal combination of %nnnnnSCROLL commands when the DIALOG NEW was generated by PBForms

          Like many others I would be VERY grateful for an updated PBForms.

          Bob

          Comment

          Working...
          X