No announcement yet.

Blinking text in RichEdit control

  • Filter
  • Time
  • Show
Clear All
new posts

  • Blinking text in RichEdit control

    A user of my programming language has asked me if it would be possible to add blinking text into richedit control.

    As far as I know and reading MS documentation at it seems not possible.

    Can someone confirm it?

    Thanks in advance

  • #2
    There is no "video attribute" for blinking, but there is nothing to stop you from using a timer to blink text yourself. Nothing other than the fact it will be a PITA to code, test and debug, that is.

    (Unless the entire control contents are to blink, in which case it would probably not be too bad to do.... although I sure would not want to be the poor guy who is trying to edit that blinking text...... )

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]


    • #3
      Request comes from a user that has developed an interactive fiction system called TAB:
      You know that software that permits to develop text interactive stories to be played.

      Application consists of 2 main project: the story editor and the story player. Story Player has as main control a RichEdit control in which the story flow while the player goes on in the drama sending commands like: go north, look, take that object, use object, look at the window, ...


      I've developed a personalized RichEdit that is very simple to be used and permits to use BBC codes to format output. More or less like what happen in forum posts. So user has a function like:

      RTF_APPENDTEXT( hwnd, %id_richedit, "[B]this is some text in bold [/B]with [flash]flashing[/flash] text in it", %RTF_UBB )
      It allows formatting of font, size, bcolors and fcolors, styles, ...

      Blinking text is just a little part decided by the author of the story.
      Control can scroll many pages up/down depending on the story.
      If blinking is not native, I cannot keep track of all the blinking text using a timer, too much work I suppose for such a feature.

      Anyhow thanks
      Last edited by Eros Olmi; 11 Apr 2009, 06:02 PM.


      • #4
        Interesting picture.

        I'm not into those kinds of games, but I need to thank you for reminding me the opera is next Saturday night. It's Mozart's Magic Flute, which was one of the first operas I attended when the Milwaukee Florentine Opera Company presented it in 1999 or 2000.

        It's a good one and one of the reasons I've been a Florentine season ticketholder ever since.

        Then again, when did Mozart ever write anything bad?

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]


        • #5
          So, ... have a nice time
          Nothing better than some classic music to regenerate the spirit.


          • #6
            Originally posted by Eros Olmi View Post
            Nothing better than some classic music to regenerate the spirit.
            Or Elvis Presley, or Check Berry, or Pinetop Smith, or Blind Lemon Jefferson, or ...

            "Make everything as simple as possible,
            but not simpler."
            Albert Einstein (1879-1955)
            It's a pretty day. I hope you enjoy it.


            JWAM: (Quit Smoking):
            LDN - A Miracle Drug:


            • #7
              Or Elvis Presley, or Check Berry, or Pinetop Smith, or Blind Lemon Jefferson, or ...
              Hi Gösta;
              Perhaps you meant Chuck Berry?


              • #8


                • #9
                  The Text Object Model(TOM) supports animation(blinking background etc.). The model is supported by the
                  IRichEditOle interface of the rich edit control. Unfortunately, as the following quote from MSDN shows, the
                  control does not implement all aspects of the model.

                  The rich edit control is able to accept and return all ITextFont properties intact, that is, without modification,
                  both through TOM and through its Rich Text Format (RTF) converters. However, it cannot display the All Caps,
                  Animation, Embossed, Imprint, Shadow, Small Caps, Hidden, Kerning, Outline, and Style font properties.
                  If it did, you would be able to use low-level COM code similar to the following to implement blinking text.
                  FUNCTION Form1_TextBtn1_Clicked _
                    ( _
                    BYVAL hWndParent  AS DWORD, _ ' handle of parent window
                    BYVAL hWndCtrl    AS DWORD _  ' handle of control
                    ) AS LONG
                    ' Text Object Model (TOM)
                    LOCAL riid          AS GUID
                    LOCAL pUnk          AS DWORD
                    LOCAL pDoc          AS DWORD
                    LOCAL pRange        AS DWORD
                    LOCAL pFont         AS DWORD
                    LOCAL pFontDup      AS DWORD
                    LOCAL cp1           AS LONG
                    LOCAL cp2           AS LONG
                    LOCAL hr            AS LONG
                    ' User
                    LOCAL hWndEdit      AS DWORD
                    hWndEdit = GetDlgItem(hWndParent, %IDC_FORM1_RICHEDIT1)
                    cp1 = 0
                    cp2 = 4
                    IF SendMessage(hWndEdit, %EM_GETLINECOUNT, 0, 0) THEN
                      ' Get a pointer to the IRichEditOle interface
                      IF SendMessage(hWndEdit, %EM_GETOLEINTERFACE, 0, BYVAL VARPTR(pUnk)) THEN
                        riid = $IID_ITEXTDOCUMENT
                        hr = IUnknown_QueryInterface(pUnk, riid, pDoc)
                        IF hr = %S_OK THEN
                          ' If range is not empty
                          IF cp1 <> cp2 THEN
                            hr = ITextDocument_Range(pDoc, cp1, cp2, pRange)
                            IF hr = %S_OK THEN
                              hr = ITextRange_GetFont(pRange, pFont)
                              IF hr = %S_OK THEN
                                ' Duplicate the font
                                hr = ITextFont_GetDuplicate(pFont, pFontDup)
                                IF hr = %S_OK THEN 
                                  ITextFont_SetBackColor pFontDup, &H00FF00FF
                                  ITextFont_SetBold pFontDup, %TOMTRUE
                                  ITextFont_SetAnimation(pFontDup, %TOMBLINKINGBACKGROUND)
                                  ITextRange_SetFont pRange, pFontDup
                                  IUnknown_Release pFontDup
                                END IF
                                IUnknown_Release pFont
                              END IF
                              IUnknown_Release pRange
                            END IF
                          END IF
                          IUnknown_Release pDoc
                        END IF
                        IUnknown_Release pUnk
                      END IF
                    END IF
                  END FUNCTION

                  Your other option is to use a timer.
                  Dominic Mitchell
                  Phoenix Visual Designer


                  • #10
                    Thanks a lot Dominic but where can I find all requested TOM functions?


                    • #11
                      Ok, I found José TypeLib 2.04 that produced an interface file very close to what I need to test your code.



                      • #12
                        I was able to implement your suggestion but, as you noted, it does not support animations. Background and bold is correctly changing, animation is not applied.

                        Thanks in any case.


                        • #13
                          So, if RIchEdit does not support such animations, what MS control support them?


                          • #14
                            The short answer is none. You should be able to use the DHTML edit or WebBrowser control to do it, but you probably do not want to go that route.

                            Keep in mind that the rich edit control tracks the animation state even though it does not implement animation. This means that it might be possible to implement blinking using the EM_SETCHARFORMAT/EM_GETCHARFORMAT messages and a timer.
                            Dominic Mitchell
                            Phoenix Visual Designer


                            • #15
                              Thanks for the reply.

                              Yes, I've already implemented WebBrowser control in thinBasic programming language with success thanks to José Roca help:

                              I already suggested to thinBasic user asking for blinking text to use WebBrowser control instead of RichEdit but it is not worth for the moment to make such a switch in his application just for blinking text. His thinBasic application is already more that 13000 lines.

                              We will see.

                              Thanks again. I've learned a new interface (TOM) that I was not aware.
                              Last edited by Eros Olmi; 17 Apr 2009, 01:16 AM.


                              • #16
                                It may not be Impossible Eros,

                                Your question got me thinking about a "Back-Burner" idea I had when I wrote RTF made Easy for RichEdit in the source code forums

                                Not so easy since I wrote it back in January, but here it is April, and at least I did a good thing and made each function obvious enough that I can reverse-engineer and re-learn quickly what I forgot (rather than the tons of time it took to learn it) so I do not have to re-learn it.

                                I am the 1st one to admit that I know nothing about RichEdit, and its possibilities but if the image shows what I am guessing, is it RTF commands that change color and high lite???

                                If so, then I may be on my way to showing a possible way to make the high lite actually flash.
                                (May be a hack, may be the way it was meant to flash) but that is another matter
                                Engineer's Motto: If it aint broke take it apart and fix it

                                "If at 1st you don't succeed... call it version 1.0"

                                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                                "Document my code????" .... "WHYYY??? do you think they call it CODE? "


                                • #17
                                  The font formatting RTF control word that you would be looking for is described in the
                                  following excerpt from the RTF specification.
                                  Control Word    Meaning
                                  \animtextN      Animated text properties 
                                                  0 (none)
                                                  1 Las Vegas Lights
                                                  2 Blinking Background
                                                  3 Sparkle Text
                                                  4 Marching Black Ants
                                                  5 Marching Red Ants
                                                  6 Shimmer
                                                  7 Wipe down
                                                  8 Wipe right
                                  Dominic Mitchell
                                  Phoenix Visual Designer