Page 2 of 4 FirstFirst 1234 LastLast
Results 41 to 80 of 159

Thread: RichTextBox Tricks and Tips

  1. #41

  2. #42
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: RichTextBox Tricks and Tips

    StdPicture

    VB doesn't open correct page on local MSDN if you press F1 from code window. Open MSDN separately and in the "Index" tab type "StdPicture" to get the offline reference.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #43

  4. #44
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: RichTextBox Tricks and Tips

    @MartinLiss,
    RE: RTB Hyperlink problem

    As the Wordpad of XP (SP2) can display hyperlinks the way you want, I thought may be we should try using XP's rtf dll.
    In XP SP1 or later the dll is msftedit.dll and the class name is RICHEDIT50W. RichEdit version 4.0 (5.0 in XP2 ?).

    So, I've created a window of that class and IT WORKED !

    But creating a RTB from scratch is a very big task.
    vbAccelerator RichEdit Control uses similar method to load Riched20.dll (version 2.0 and version 3.0) library using the LoadLibrary function and create a RichEdit window of that version. So, if we load msftedit.dll library, then may be it can create a v4.0 window ?

    Unfortunetly, that ocx is not running in my system. Some registry problem. (this XP installation is damaged). I've worked with this control before. It used to work smoothly.

    So, if you try my idea and modify that control's code, I hope it will work.

    BTW, I'm using XP SP2. If the attatched code can't create the window, open Wordpad and get it's classname and try with that class name.
    Attached Files Attached Files
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #45
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: RichTextBox Tricks and Tips

    Above method works with VBBox CRichEditCtl.cls
    I've used the code inside a usercontrol and it is working.

    Now all is left to do is - Modifying properties for this version and Getting the URL. I hope someone can help me on this.

    Edit:
    As far as I can remember, we are not allowed to distribute 'msftedit.dll'. So, even if we create a new RTB control, it will work only in XP.
    Last edited by iPrank; Feb 14th, 2007 at 11:51 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #46
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    Moeur, I'm using code that I believe I got from your GIFAnimatorV3 project to put smilies in a RichTextbox. I'm using the following code (in part) but when I do the background of the picturebox is not transparent.

    VB Code:
    1. Set GIF = New clsGIF
    2.                 With GIF
    3.                     .LoadGIF LoadResData(GIFNumber(mstrSmilies(intTag)), "CUSTOM")
    4.                     ' Clear the picture
    5.                     picSmilies.Picture = LoadPicture
    6.                     .CopyFrame 1, picSmilies.hdc, 10, 10
    7.                     Set picSmilies.Picture = GIF.Frames(1).Picture
    8.                 End With
    9.                 strRTF = PictureToRTF(picSmilies)
    10.                 mstrRTF = VBA.Left$(mstrRTF, mintSmiliePos - 1) _
    11.                         & strRTF _
    12.                         & Right$(mstrRTF, Len(mstrRTF) - (mintSmiliePos - 1 + Len(mstrSmilies(intTag))))
    Any hints as to where I can look to fix this?

  7. #47
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    Bill, I've found a serious problem. If you put just the following in a timer (where GIF is member of clsGIF) the app runs out of memory in a minute or so.

    VB Code:
    1. With GIF
    2.        .LoadGIF LoadResData(113, "CUSTOM")
    3.         rtbMessage.TextRTF = PictureToRTF(.Frames(1).Picture)
    4.     End With

  8. #48
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    I don't know why the problem occurs, but if LoadGIF is in a timer then memory(?) gets used up and the program crashes. LoadGIF can be removed from the timer and still allow for animation of a smilie, but only one smilie.

    I was able to resolve the problem by doing this
    VB Code:
    1. Private GIF() As clsGIF
    2. 'instead of
    3. Private WithEvents GIF As clsGIF

    You can't do WithEvents with an array but apparently it isn't needed (at least in my code). After that do the following outside of the timer

    VB Code:
    1. If UBound(GIF) < the_nbr_of_gifs_to_animate - 1 Then
    2.     ReDim Preserve GIF(UBound(GIF) + 1)
    3.     Set GIF(UBound(GIF)) = New clsGIF
    4. End If
    5. With GIF(UBound(GIF))
    6.     .LoadGIF LoadResData(the_number_of_the_gif), "CUSTOM")
    7. End With
    And in the timer

    VB Code:
    1. For lngIndex = 0 To the_nbr_of_gifs_to_animate  - 1
    2.         With GIF(lngIndex)
    3.             tmrGIF.Interval = .Frames(1).DelayTime
    4.             mbFrameDisplayed = False
    5.             If iFrame <= .Frames.Count Then
    6.                 ' The following line is simplified. In an app you would want to place
    7.                 ' the picture somplace within the existing TextRTF rather than
    8.                 ' replacing the TextRTF as this does. (PM me for further details)
    9.                 MyRTB.TextRTF = PictureToRTF(.Frames(iFrame).Picture)
    10.                 mbFrameDisplayed = True
    11.             End If
    12.         End With
    13.     Next
    14.     If mbFrameDisplayed Then
    15.         iFrame = iFrame + 1
    16.     Else
    17.         iFrame = 1
    18.     End If

  9. #49

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    Marty,

    I couldn't reproduce the out of memory error you get, however the solution you came up with is definitely the way to go. You don't want to have to keep reloading the gif.

  10. #50
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    Marty,

    I couldn't reproduce the out of memory error you get, however the solution you came up with is definitely the way to go. You don't want to have to keep reloading the gif.
    In the version of my program that I sent you I don't believe that the LoadGIF code at that time was in the Timer.

    Have you been able to figure out the non-transparent background problem?

  11. #51

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    OK, try this. It copies the frame to a picturebox first. The picturebox background color has been set to the same color as the RTB.
    Each time you press the button it loads the next smilie from the resource file.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type RECT
    4.         Left As Long
    5.         Top As Long
    6.         Right As Long
    7.         Bottom As Long
    8. End Type
    9. Private Declare Function CreateSolidBrush Lib "gdi32" ( _
    10.     ByVal crColor As Long _
    11. ) As Long
    12.  
    13. Private Declare Function FillRect Lib "user32" ( _
    14.     ByVal hdc As Long, _
    15.     lpRect As RECT, _
    16.     ByVal hBrush As Long _
    17. ) As Long
    18.  
    19. Private Declare Function SetRect Lib "user32" ( _
    20.     lpRect As RECT, _
    21.     ByVal X1 As Long, _
    22.     ByVal Y1 As Long, _
    23.     ByVal X2 As Long, _
    24.     ByVal Y2 As Long _
    25. ) As Long
    26.  
    27. Private Declare Function GetSysColor Lib "user32" ( _
    28.     ByVal nIndex As Long _
    29. ) As Long
    30.  
    31.  
    32. Dim GIF As clsGIF
    33. Private FrameIndex As Integer
    34. Dim hbrBkgnd As Long
    35. Dim lpRect As RECT
    36.  
    37. Private Sub Command1_Click()
    38. Static index As Integer
    39.  
    40.         GIF.LoadGIF LoadResData(101 + index, "CUSTOM")
    41.         Picture1.Width = GIF.xWidth
    42.         Picture1.Height = GIF.yHeight
    43.         hbrBkgnd = CreateSolidBrush(CheckSysColor(Picture1.BackColor))
    44.         SetRect lpRect, 0, 0, GIF.xWidth, GIF.yHeight
    45.  
    46.         FrameIndex = 0
    47.         Timer1.Interval = 50
    48.         index = index + 1
    49.         If index = 16 Then index = 0
    50. End Sub
    51.  
    52. Private Sub Form_Load()
    53.     Set GIF = New clsGIF
    54.     Me.ScaleMode = vbPixels
    55.     With Picture1
    56.         .BorderStyle = 0
    57.         .BackColor = RTB.BackColor
    58.         .AutoRedraw = True
    59.         .AutoSize = False
    60.     End With
    61. End Sub
    62.  
    63. Private Sub Timer1_Timer()
    64.  
    65.     EraseBackground Picture1.hdc
    66.     With GIF
    67.         FrameIndex = FrameIndex + 1
    68.         If FrameIndex > .Frames.Count Then FrameIndex = 1
    69.         .CopyFrame FrameIndex, Picture1.hdc, 0, 0
    70.         Picture1.Picture = Picture1.Image
    71.     End With
    72.    
    73.     RTB.TextRTF = PictureToRTF(Picture1.Picture)
    74. End Sub
    75.  
    76. Private Sub EraseBackground(hdc As Long)
    77.     FillRect hdc, lpRect, hbrBkgnd
    78. End Sub
    79.  
    80. Public Function CheckSysColor(ByVal ColorRef As Long) As Long
    81. 'sometimes VB colors are expressed as system colors
    82. 'we need to change this to an RGB color
    83.    Const HighBit = &H80000000
    84.    If ColorRef And HighBit Then
    85.       CheckSysColor = GetSysColor(ColorRef And Not HighBit)
    86.    Else
    87.       CheckSysColor = ColorRef
    88.    End If
    89. End Function

  12. #52

  13. #53

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    OK, here you go.
    Here is a sample project that replaces the tags with the proper animated smilie. The smilies are in gif files so you don't have to mess with resource files.

    The project also demonstrates the hyperlink functionality we discussed earlier. this is because everytime you change TextRTF you have to reenable the EN_LINK effect for the hyperlinks. Since the animator messes with TextRTF, hyperlinks have to be updated too.

    I'm sure there are some bugs and it can be cleaned up a bit but here it is.
    Let me know how it works.
    Attached Files Attached Files

  14. #54

  15. #55

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    I'll also check this out but I don't find any problem in my code with animation vs. the EN_LINK effect.
    Hmm...
    I noticed in your code that you do the hyperlinks last. I assumed this was because if you set them first then changed RTB.TextRTF the blue links would go away. This is what happens on my system, so each time the animation timer fires and RTB.TextRTF is updated the links need to be reestablished.

  16. #56

  17. #57
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    OK, here you go.
    Here is a sample project that replaces the tags with the proper animated smilie. The smilies are in gif files so you don't have to mess with resource files.

    The project also demonstrates the hyperlink functionality we discussed earlier. this is because everytime you change TextRTF you have to reenable the EN_LINK effect for the hyperlinks. Since the animator messes with TextRTF, hyperlinks have to be updated too.

    I'm sure there are some bugs and it can be cleaned up a bit but here it is.
    Let me know how it works.
    That's a very nice example.

  18. #58
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: RichTextBox Tricks and Tips

    Bill (or anyone). I sometimes store my TextRTF in a string variable, manipulate the string and then replace the TextRTF with the string. Would you have any idea why when the string contains this

    blah blah \v\'10s105\'11\v0 \i0

    it becomes the following in the TextRTF????

    blah blah \v\'10s105\'11\i0\v0

  19. #59
    New Member
    Join Date
    Mar 2007
    Posts
    1

    Re: RichTextBox Tricks and Tips

    Why was vbcode turned off in this forum? ._.

  20. #60
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: RichTextBox Tricks and Tips

    This is truly a great thread with loads of useful information. I stumbled upon it when I wanted to see what was involved in setting up a RTB to allow hyperlinks. Great stuff, Bill!
    "It's cold gin time again ..."

    Check out my website here.

  21. #61

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Inserting Hyperlinks

    In addition to turning a URL you enter into a hyperlink (as in "Auto Detect and respond to URLs" above) you can turn ordinary text into hyperlinked text that points to a URL of your choice.

    To do this the text in the Richtextbox has to have its link notification turned on. Then, as before, the form containing the Richtextbox has to be subclassed so that you can respond to user actions. I've created a class that simplifies these tasks.

    This class has two events:
    Clicked - raised when user clicks a hyperlink.
    MouseMove - raised when the user moves the mouse over a hyperlink
    And three methods
    Initialize - called once to attach the RTB to the hyperlink class
    InsertHyperlink - can hyperlink selected text or insert new text and hyperlink it.
    RefreshHyperlinks - Unfortunately, whenever the richtextbox's TextRTF property is changed, the RTB will lose all link notification information. To remind the RTB of previously hyperlinked text you must call this method each time the textRTF property is changed.
    Here is an example of how to use the class
    Code:
    'instantiate and initialize the class
        Dim Hypertext As clsHyperText
        Set Hypertext = New clsHyperText
        Hypertext.Initialize RTB
        
        'hyperlink the word "this" in the Richtextbox
        RTB.Find ("this")
        Hypertext.InsertHyperlink ("http://www.vbforums.com")
    To respond to user action on the hyperlinks, simply place code in the events.
    Code:
    Private Sub Hypertext_Clicked(Button As Integer, URL As String, UnderlyingText As String)
        'launch the browser here
        If Button = vbLeftButton Then
            ShellExecute 0&, "OPEN", URL, vbNullString, "C:\", SW_SHOWNORMAL
        Else
            'popup menu?
            Debug.Print URL, UnderlyingText
        End If
    End Sub
    Attached is a demo project which contains the class.
    Attached Files Attached Files
    Last edited by moeur; Mar 12th, 2007 at 09:40 PM.

  22. #62

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Insert Animated images

    Here is a control that shows you how to add animated GIF images to a Richtextbox. This control was built to replace VBCode smilie tags with their corresponding animated images. It takes advantage of my VB GIF Animator Control and the PictureToRTF function in my above post Insert Pictures.

    I placed this functionality on a usercontrol because it uses a timer and an array of picture boxes. The GIFs cannot by placed into the richtextbox transparently, so I change the background of each image to match the background color of the RTB.

    The control has two properties
    BackColor - set this property to the backcolor of your Richtextbox to simulate transparency. This property can only be set from code and cannot be changed once pictures have been inserted into the RTB.

    FrameInterval - This interval in ms, affects the speed of the animation.
    two methods
    LoadIcon - load a GIF file and its corresponding tag into the control
    ReplaceTags - Replaces each tag in the Richtextbox text with its corresponding animated image.
    and one event
    NextFrame - Raised at each frame advance interval.
    The following is an example of how you might initialize the control
    Code:
        'set the picture backgrounds to match the RTB background
        GIF.BackColor = RTB.BackColor
        
        'load some icon files along with the corresponding tags
        Path = App.Path & "\icons\"
        With GIF
            .loadIcon ":)", Path & "smile.gif"
            .loadIcon ":(", Path & "Frown.gif"
            .loadIcon ":o", Path & "redface.gif"
            .loadIcon ":D", Path & "BigGrin.gif"
        End With
    Now to replace all the tags in the RTB text with the proper smilie
    Code:
        GIF.replaceTags RTB
    Attached is a demo project which illustrates the proper use of this control.
    Attached Files Attached Files
    Last edited by moeur; Mar 13th, 2007 at 07:06 PM.

  23. #63
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    I've got a problem with insertion of rtf, when the text in the target rtb control is colored and the text/rtf being inserted has some colors also, when inserted the color of the inserted rtf is lost... :-( Any workarounds there? :-)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  24. #64

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    what do you mean by "insertion of rtf"?

  25. #65
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    Using your function to insert. :-) For instance, if the target rtb control got some colored text then the rtf being inserted got some colored text also, the color of the rtf being inserted is overridden, the color table is not updated... :-(
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  26. #66

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    what you're saying still does not make sense to me.
    what do you mean by my function to insert :-) ?
    Do you mean inserting an animated GIF? If so then how can that have colored text?

    Please explain in detail or supply example code.

  27. #67

  28. #68
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    what you're saying still does not make sense to me.
    what do you mean by my function to insert :-) ?
    Do you mean inserting an animated GIF? If so then how can that have colored text?

    Please explain in detail or supply example code.
    For example, the ff. is the tex of the target rtb: dee-u

    And the text being inserted is: moeur

    If you will try to insert the rtf of moeur to the rtf of dee-u then the colors of meour is not preserved, it is being overridden. Clear now? :-)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  29. #69

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    Not clear,

    I still don't know how you are trying to insert text.
    why don't you just show me the code you are using to insert text?

  30. #70
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    Ok, here is further explanation since I don't have VB6.0 here.

    RichTextbox1 control has the 'dee-u' text (with the colors as in my previous post), RichTextbox2 control has the 'moeur' text (with the colors as in my previous post), get the TextRTF of Richtexbox1 then insert it, using your function to insert rtf, in the RichTextbox2, perhaps in the middle of 'm' and 'o'.... The color of 'dee-u' will be overriden... :-(

    I hope I made myself clear already.... :-)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  31. #71

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    After asking 3 times.
    I give up.

    If you want to supply code mabye I can help.

  32. #72
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    Ok, have a look at the attached form... :-)
    Attached Files Attached Files
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  33. #73

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    works ok for me.
    Maybe you have an outdated version of the Richtextbox control.

  34. #74

  35. #75
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by MartinLiss
    When you click the button and move "dee-u" to rtb2, dee-u takes on the colors of rtb2 rather than maintaining the colors it had in rtb1.
    Yup, that is what I am trying to tell...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  36. #76

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    The simplest way to do what you want to do is this
    Code:
    RTB2.SelRTF = RTB1.TextRTF

  37. #77
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: RichTextBox Tricks and Tips

    Moeur, thanks for all of this, it's great and alot of it is what I have been looking for, although I don't confess to totally understand all of the code.
    I am working through it slowly.

    I have used the hyperlink code and there are a couple of question I have:

    Firstly, I would only like to enable the autourldetect under certain circumtances. How can I turn it off?

    Secondly, if there is a link in the RTB, if I click anywhere in the RTB it opens the link. Is this how you planned it?
    I have other text in the RTB which I would be editing and when I click somewhere in the RTB, it opens the link.

    If the non-link text is first in the RTB it's ok, but if I click anywhere after the link, where there is no text, just space, it still selects the link and opens the link.

    I hope you can follow what I am trying to explain.
    I have just done a straight copy of your code in the example project, with the exception of this line which is not in the Form_Load, but in a treeview node_click.
    vb Code:
    1. EnableAutoURLDetection RTB
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  38. #78
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: RichTextBox Tricks and Tips

    I have now used the following to turn off the detection.
    I just wondered, being new to subclassing, is this ok, or do I need anything else.
    It seems to work ok.
    vb Code:
    1. Public Sub DisableAutoURLDetection(rtb As RichTextBox)
    2.  
    3. Set FormSubClass = Nothing
    4.  
    5. End Sub
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  39. #79

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    try this instead
    Code:
    Public Sub DisableAutoURLDetection(RTB As RichTextBox)
        'disable auto URL detection
        SendMessage RTB.hwnd, EM_AUTOURLDETECT, 0&, ByVal 0&
        'turn off subclassing
        FormSubClass.Unsubclass
    End Sub
    As to your other problem:

    I only see this when the hyperlink is the very last text in the richTextBox. This is a bug in the richtextbox itself. To eliminate this problem, put something after the hyperlink even just a new line.

  40. #80
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    try this instead
    Code:
    Public Sub DisableAutoURLDetection(RTB As RichTextBox)
        'disable auto URL detection
        SendMessage RTB.hwnd, EM_AUTOURLDETECT, 0&, ByVal 0&
        'turn off subclassing
        FormSubClass.Unsubclass
    End Sub
    As to your other problem:

    I only see this when the hyperlink is the very last text in the richTextBox. This is a bug in the richtextbox itself. To eliminate this problem, put something after the hyperlink even just a new line.
    Thanks moeur.

    I will change the Disable code.
    Is this to change the message from the RTB back to, I guess the form?

    I eventually realised that the way to do this was to put the link first, then the text afterwards.

    Thanks for all your hard work.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width