Announcement

Collapse
No announcement yet.

Rich Edit

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

  • Rich Edit

    I have not used the RC control other than to display plain text. Is there an API function that will parse RC tags and display the text in the correct format, font, and color?
    Walt Decker

  • #2
    What's the "RC control" and what are "RC Tags"?

    Did you mean "RE" ? If so then the RichEdit control displays properly formatted text in the correct font and colour.

    The relevant API file is in José's includes. It is "TextServ.inc" which includes "richedit.inc" and "objidl.inc"

    Comment


    • #3
      There must be something more to it. I created an rtf and streamed it into a richedit. All the tags were shown.

      Perhaps sending it a font on creation over-road the imbeded text or perhaps I have to load the text into a wide string then stream the text into the control.

      I do not have Mr. Roca's includes.
      Walt Decker

      Comment


      • #4
        , not even the RTF string you're testing with.

        Dale

        Comment


        • #5
          Originally posted by Dale Yarker View Post
          , not even the RTF string you're testing with.

          Exactly!

          Comment


          • #6
            Minimalist demonstration:
            '
            Code:
            #INCLUDE "win32api.inc"
            #INCLUDE "richedit.inc"
            %IDC_RICHEDIT = 100
            
            FUNCTION PBMAIN
             LOCAL hDlg AS DWORD
             LOCAL strRich AS STRING
             'RTF text created in Wordpad and saved as RTF file, then opened in Notepad++ and copied into PB Edit
             strRich  = "{\rtf1\ansi\ansicpg1252\deff0\deflang3081" & _
                            "{\fonttbl" & _
                                "{\f0\fswiss\fprq2\fcharset0 Calibri;}" & _
                                "{\f1\fscript\fprq2\fcharset0 Comic Sans MS;}" & _
                                "{\f2\fnil\fcharset0 Calibri;}}" & _
                            "{\colortbl ;\red255\green0\blue0;}" & _
                            _ "{\*\generator Msftedit 5.41.21.2510;}" & _
                        "\viewkind4\uc1\pard\sa200\sl276\slmult1\f0\fs22 This is \cf1\b\f1\fs44 Rich \cf0\b0\f0 text\par \lang9\f2\fs22\par}"
            
              DIALOG NEW 0, "RichEdit",,,250,100, %WS_OVERLAPPEDWINDOW TO hDlg
              LoadLibrary "RichEd32.dll"
              CONTROL ADD "RichEdit", hDlg, %IDC_RICHEDIT, "Some text for testing", 5, 5, 240, 90, _
                          %WS_CHILD OR %WS_VISIBLE OR %ES_MULTILINE OR %WS_HSCROLL OR %WS_VSCROLL OR _
                          %ES_AUTOVSCROLL OR %ES_NOHIDESEL OR %ES_WANTRETURN OR %ES_SAVESEL, %WS_EX_CLIENTEDGE
              CONTROL SET TEXT hDlg,%IDC_RICHEDIT, strRich
              DIALOG SHOW MODAL hDlg, CALL DialogProc
            END FUNCTION
            
            CALLBACK FUNCTION DialogProc
            END FUNCTION
            '
            Click image for larger version  Name:	Richtext.jpg Views:	0 Size:	6.9 KB ID:	799248

            Comment


            • #7
              There must be something more to it. I created an rtf and streamed it into a richedit. All the tags were shown.
              If your marked up content is correctly formatted the SF_RTF / SF_TEXT wParam value (eg StrmFmt) determines whether the tags are shown or not.

              Code:
              SendMessage(hEd, %EM_STREAMIN, StrmFmt, VarPtr(ES))           ' Write RE content
              See test code here.
              Rgds, Dave

              Comment


              • #8
                Mr. Mclachlan, Mr. Yarker; how can one display failing code when one does not know where it is failing?

                Mr. Biggs: Thank you. I am sure that is the problem. It has been a while since I have used this particular piece of code and IMS I have some detection code that is "supposed" to see if the text is in rtf or plain text.
                Walt Decker

                Comment


                • #9
                  If file contents is in a string, simple CONTROL SET TEXT can be used directly for both plain text and RTF formatted string (Open ..For Binary / Get$ / Close).
                  CONTROL SET TEXT CB.HNDL, %IDC_RICHEDIT, sBuf

                  Comment


                  • #10
                    Originally posted by walt decker View Post
                    mr. Mclachlan, mr. Yarker; how can one display failing code when one does not know where it is failing?
                    .

                    on error
                    if err
                    try...catch...try

                    Comment


                    • #11
                      Mr. Mclachlan, Mr. Yarker; how can one display failing code when one does not know where it is failing?
                      Post it all. Collectively, anyway, we are a reasonably bright group and can figure it out.

                      Be sure to include the failing data!

                      Oh, if you are looking for the easy way to do this, see the source code bundler at ... well <bleep> I cannot find it.

                      Maybe if I give you these:

                      Get current source and executable at: (PBWin/DLL 7,6,5 and CC 3,2,1)
                      http://www.powerbasic.com/files/pub/...SCBundle11.zip


                      Source Code Bundler v 3 handles PBWIN v 7/8/9/10 and PBCC v 3/4/5/6 source code

                      These are the old references. Maybe someone else can find the current URLs.

                      Anyway, what this does is finds all the files need to create a and stores in a ZIP file. You can even add data files to the source code bundle.

                      It's a really nice* piece of code.


                      MCM
                      * non-objective assessment
                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Borje Hagsten View Post
                        If file contents is in a string, simple CONTROL SET TEXT can be used directly for both plain text and RTF formatted string (Open ..For Binary / Get$ / Close).
                        CONTROL SET TEXT CB.HNDL, %IDC_RICHEDIT, sBuf
                        As per post #6

                        Comment


                        • #13
                          Mr. Biggs pin-pointed the problem. I guess it really was not that difficult to figure out given the description of the problem.

                          Mr. Hagsten,

                          When I wrote the module about 5 years ago, I originally used CONTROL SET TEXT hdlg, Id, Txt$ and had it fail on some very large files.

                          Anyway, the problem is solved. Before streaming the string I check the first five (5) characters. If they match "{/rtf" I then use rtf other wise text.

                          Walt Decker

                          Comment


                          • #14
                            I found the correct link to the Source Code Bundler:

                            https://forum.powerbasic.com/forum/u...dler-version-3

                            As you will read there, the archive contains the EXE so you may use the tool without having to recompile - very handy if you don't happen to have the PB version I used to compile it (PB/WIn 10.03.3).

                            Michael Mattias
                            Tal Systems Inc. (retired)
                            Racine WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment

                            Working...
                            X