Announcement

Collapse
No announcement yet.

Rich Edit control with Hyperlink support - please test

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

  • Rich Edit control with Hyperlink support - please test

    Hi all

    I needed the functionality, so I wrote this.

    Please comment and suggest corrections, before it goes to the source code Forum.
    I would really like suggestions on how to implement cut'n paste from MS word.
    It's only tested on Windows 98 SE. DK.
    --
    Best Regards
    Peter Scheutz

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' RichEdit DDT Hyperlink sample, showing how to create a
    ' Richedit Control with Hyperlink functionality.
    '
    ' By Peter Scheutz, released As Public Domain - November 28, 2000
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' HOWTO:
    ' Compile, execute, select some text, click "Make Hyperlink",
    ' enter link Text, press [ok], move mouse over link.
    ' Link text could be: [url="http://www.powerbasic.com"]www.powerbasic.com[/url]   or [url="http://www.powerbasic.com"]http://www.powerbasic.com[/url] 
    ' or mailto:[email protected]
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' REQUIRES:
    ' Rich Edit control 2 or later
     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' TODO:
    ' 1) Make it possible To paste rtf From MS Word And Preserve the
    '    hyperlinks. I hope that someone in the PB forum can help with that.
    '
    ' 2) Add  "richEd_Hyperlink_RemoveLink" function.
    ' 3) Add  "richEd_Hyperlink_CleanUpLinks" function, to use when
    '    text is changed by copy and paste
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' CODE BASED ON:
    ' "Small RichEdit sample",
    ' By Borje Hagsten, released As Public Domain - April 24, 2000
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' EXTERNAL RESCOURCES:
    ' The method was taken from:
    ' [url="http://www.wdj.com/archive/1108/feature.html"]http://www.wdj.com/archive/1108/feature.html[/url] 
    '
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    
    #Compile Exe
    #Dim All
    
    #Include "WIN32API.INC" 'Some include files
    #Include "COMMCTRL.INC"
    #Include "RICHEDIT.INC"
    Global hRichEd As Long
    
    Type charformat2a
        cbSize As Long
        dwMask As Dword
        dwEffects As Dword
        yHeight As Long
        yOffset As Long
        crTextColor As Dword
        bCharSet As Byte
        bPitchAndFamily As Byte
        szFaceName As Asciiz * %LF_FACESIZE
        wpad2 As Integer
        wWeight As Word
        sSpacing As Integer
        crBackColor As Dword
        lcid As Long
        dwReserved As Dword
        sStyle As Integer
        wKerning As Word
        bUnderlineType As Byte
        bAnimation As Byte
        bRevAuthor As Byte
        bReserved1 As Byte
    End Type
    
    Type ENLINK
        nmhdr As NMHDR
        msg As Dword
        wParam As Long
        lParam As Long
        chrg As CHARRANGE
    End Type
    
    
    %ID_RICHEDIT = 500
    '%IDSTYLECOMBO = 501
    %IDURLLABEL = 502
    
    '%EM_AUTOURLDETECT = ( %WM_USER + 91 )
    %CFM_LINK = &H20 '/* Exchange hyperlink extension */
    %CFM_LCID = &H2000000
    %CFE_LINK = &H20
    %EN_LINK = &H70b
    %ENM_LINK = &H4000000
    
    Global hEdit As Long
    
    Declare CallBack Function DlgCallback()
    
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Global richEd_Hyperlink_Hyperlinks() As String
    Global richEd_Hyperlink_HyperlinksCount As Long
    
    Function richEd_Hyperlink_GetFreeID() As Long
        Incr richEd_Hyperlink_HyperlinksCount
        ReDim Preserve richEd_Hyperlink_Hyperlinks(1 To richEd_Hyperlink_HyperlinksCount)
        Function= richEd_Hyperlink_HyperlinksCount
    End Function
    
    Function richEd_Hyperlink_GetHyperLink(ID As Long) As String
        If ID>0 And ID<=richEd_Hyperlink_HyperlinksCount Then _
            Function= richEd_Hyperlink_Hyperlinks(ID)
    End Function
    
    
    Function richEd_Hyperlink_SetLink( ByVal ID As Long ) As Long
        Local cf As charformat2a
        cf.cbSize = Len( cf ) 'Length of structure
        cf.dwMask = %CFM_LCID  Or %CFM_LINK 'Set mask to link and id only
    
        cf.dwEffects = %CFE_LINK
        cf.lcid = ID
        Call SendMessage( hEdit, %EM_SETCHARFORMAT, %SCF_SELECTION, VarPtr( cf ))
    
        Function=%True
    End Function
    
    
    Function richEd_Hyperlink_AddLink() As Long
        Local ID As Long
        Local url As String
        ID=richEd_Hyperlink_GetFreeID()
        If ID>0 Then
            url = InputBox$(" Type the link text")
            If Len(url)>2 Then  ' do a check for a valid Url here?
                richEd_Hyperlink_Hyperlinks(ID)=url
                Call richEd_Hyperlink_SetLink(ID)
                Function=%True
            End If
        End If
    End Function
    
    Function richEd_Hyperlink_UrlClicked(ByVal ID As Long) As Long
        Call ShellExecute(%NULL,"open",richEd_Hyperlink_GetHyperLink( ID ),"","",%SW_SHOW)
    End Function
    
    
    Function richEd_Hyperlink_HandleURL(ByVal hWnd As Long, lpLink As ENLINK) As Long
        Local linkCf2 As charformat2a
        Local chrg As CHARRANGE
        Call SendMessage(hEdit,%EM_HIDESELECTION,%True,0)
         ' cache current selection
        Call SendMessage(hEdit,%EM_EXGETSEL,0,VarPtr(chrg))
    
        Call SendMessage( hEdit, %EM_EXSETSEL, 0, VarPtr( lpLink.chrg ))
        linkCf2.cbSize = Len( linkCf2 ) 'Length of structure
        linkCf2.lcid = 0
        Call SendMessage( hEdit, %EM_GETCHARFORMAT, %True, VarPtr( linkCf2 ))
    
        ' restore old selection
        Call SendMessage(hEdit,%EM_EXSETSEL,0,VarPtr(chrg))
        Call SendMessage(hEdit,%EM_HIDESELECTION,%False,0)
        
        Select Case lpLink.msg
               Case %WM_LBUTTONDOWN
                Call richEd_Hyperlink_UrlClicked(linkCf2.lcid)
                Function=%True : Exit Function
                
               Case %WM_LBUTTONDBLCLK, %WM_LBUTTONUP ' Swallow these button events
                    Function=%True : Exit Function
               Case %WM_MOUSEMOVE
                     Control Set Text hWnd, %IDURLLABEL, richEd_Hyperlink_GetHyperLink( linkCf2.lcid )
                Function=%True : Exit Function
        End Select
       
        Function=%False
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    
    Function PbMain
        Local hDlg As Long, rText As String
    
        'hRichEd = LoadLibrary("RICHED32.DLL")
        hRichEd = LoadLibrary( "Riched20.DLL" )
        Call InitCommonControls
    
        Dialog New 0, "DDT RichEdit Hyperlinks demo",,, 320, 138, %WS_THICKFRAME Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MAXIMIZEBOX To hDlg
        Control Add Button, hDlg, %IDOK, "&Make Hyperlink", 140, 6, 70, 14
        Control Add Label, hDlg, %IDURLLABEL, "Empty", 2, 2, 100, 14
    
    
        Control Add "RichEdit20A", hDlg, %ID_RICHEDIT, "", 6, 6, 126, 110, _
        %WS_CHILD Or %WS_VISIBLE Or %ES_MULTILINE Or %WS_VSCROLL _
        Or %ES_AUTOVSCROLL Or %ES_WANTRETURN Or _
        %ES_NOHIDESEL, %WS_EX_CLIENTEDGE 'Call RichEdCallback
    
        Control Handle hDlg, %ID_RICHEDIT To hEdit
    
    '    Call SendMessage( hEdit, %EM_AUTOURLDETECT, %True, 0 )
        Call SendMessage( hEdit, %EM_SETEVENTMASK, 0, %ENM_LINK )
    
    
        rText = Repeat$( 30, "Compile, execute, select some text, click 'Make Hyperlink' " ) 'Create and set some text
        Call SendMessage( hEdit, %WM_SETTEXT, 0, StrPtr( rText ))
        SetFocus hEdit
    
        Dialog Show Modal hDlg Call DlgCallback
    
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main callback procedure for all controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CallBack Function DlgCallback()
        Local hiLparam As Integer
        Local loLparam As Integer
        Local enlink As ENLINK
        Local enlinkPtr As ENLINK Ptr
        'cache these and avoid sign loss if sending them to subs later on.
        hiLparam = HiWrd( CbLparam )
        loLparam = LoWrd( CbLparam )
    
    
    Select Case CbMsg
    
        Case %WM_NOTIFY
            ' get a Pointer to the ENLINK structure
            enlinkPtr = CbLparam
            enlink = @enlinkPtr
            ' MSDN states that it's better to use enlink.nmhdr.idFrom than Wparam for ID detection.
            If enlink.nmhdr.code = %EN_LINK And enlink.nmhdr.idFrom = %ID_RICHEDIT Then
                Call SetWindowLong(CbHndl,%DWL_MSGRESULT, richEd_Hyperlink_HandleURL(CbHndl,enlink))
    
                Function=%True ': Exit Function
            End If
            Function=%False ': Exit Function
        Case %WM_COMMAND
            Select Case CbCtl
                Case %IDOK
                    Call richEd_Hyperlink_AddLink() 'The sub will prompt for link text
    
            End Select
        Case %WM_SIZE
            MoveWindow GetDlgItem( CbHndl, %ID_RICHEDIT ), 4, 40, loLparam - 8, hiLparam - 50, - 1
    
    End Select
    End Function
    ------------------


    [This message has been edited by Peter Scheutz (edited November 29, 2000).]
    Best Regards
    Peter Scheutz

  • #2
    I've not tested the code, but I can tell you there is a spelling mistake in one of the comments near the end of the file...

    <grin, duck & run!>


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      The englis langwidge are wery duffykild ven you is a foiren.. forinar… a person from another coumtry.

      --
      Peter Schuetz




      ------------------
      Best Regards
      Peter Scheutz

      Comment


      • #4
        hi Peter,

        seems to work fine on my Win2k, but not my NT4(sp4).

        On the NT the "linktext" does not get colored/underlined, but
        it flickers when the mouse is moved over it. The caption on
        the menu-item is not updated when mouse is moved over a "linktext"

        Both the URL and mailto functionality seems to be ok on both my platforms.

        -p


        ------------------

        Comment


        • #5
          Originally posted by Per Fimmeland:
          hi Peter,

          seems to work fine on my Win2k, but not my NT4(sp4).

          On the NT the "linktext" does not get colored/underlined, but
          it flickers when the mouse is moved over it. The caption on
          the menu-item is not updated when mouse is moved over a "linktext"

          Both the URL and mailto functionality seems to be ok on both my platforms.

          -p


          Hi Per
          Thanks a lot. It's those kind of things I want to fix.
          I know why it flickers, and I think I know how to fix the underline/color issue.
          I'll look into the missing mouseover text update.

          --
          Best Regards
          Peter Scheutz



          ------------------
          Best Regards
          Peter Scheutz

          Comment


          • #6
            hi again.

            sorry for never finishing this!
            we found another way to do what was needed at the time.

            now there is a different option:
            qhtm, an html rendering control is once again available from www.gipsysoft.com

            discussion here: http://www.powerbasic.com/support/pb...ad.php?t=25837

            source code here: http://www.powerbasic.com/support/pb...ad.php?t=23059


            ------------------
            best regards
            peter scheutz
            Best Regards
            Peter Scheutz

            Comment


            • #7
              Newer versions of richedit supports hyperlinks.


              ------------------
              hellobasic

              Comment


              • #8
                Originally posted by Edwin Knoppert:
                Newer versions of richedit supports hyperlinks.
                Not in the form that the code posted attemts.
                They do things like http://www.somewhere.org and mailto: , but not
                "This is a link" and then link it to www.powerbasic.com
                In short the text itself has to be a valid link.


                ------------------
                Best Regards
                Peter Scheutz
                Best Regards
                Peter Scheutz

                Comment


                • #9
                  Hyperlink with RICHED32.DLL : Is it possible ? What change on Peter code ?

                  Comment


                  • #10
                    Paulo,
                    This is what I use. The code demos how to turn the feature on and off.
                    Code:
                    'Compilable Example:
                    'In this example, a button is used to toggle the display of active URLs.
                    #Compile Exe
                    #Dim All
                    #Include "Win32API.inc"
                    #Include "RichEdit.inc"
                    #Include "CommCtrl.inc"
                    Global hDlg As Dword, hRichEdit As Dword
                    %ID_RichEdit = 500 : %IDC_Button = 501
                    Function PBMain() As Long
                       Dialog New Pixels, 0, "URL Test",300,300,200,200, %WS_OverlappedWindow To hDlg
                       RichEditCreate
                       Control Add Button, hDlg, %IDC_Button, "Toggle URL Detect", 30,10,140,20
                       Dialog Show Modal hDlg Call DlgProc
                    End Function
                    
                    CallBack Function DlgProc() As Long
                       Select Case CB.Msg
                          Case %WM_Command
                             If CB.Ctl = %IDC_Button AND CB.Ctlmsg = %BN_Clicked Then
                                Static EnableURL&
                                EnableURL& = EnableURL& XOR 1
                                If EnableURL& Then
                                   Control Send hDlg, %ID_RICHEDIT, %EM_AUTOURLDETECT, %True, 0
                                   Control Set Text hDlg, %ID_RichEdit, "URL detect is on!" + $CrLf + $CrLf + " http://www.garybeene.com/"
                                Else
                                   Control Send hDlg, %ID_RICHEDIT, %EM_AUTOURLDETECT, %False, 0
                                   Control Set Text hDlg, %ID_RichEdit, "URL detect is off!" + $CrLf + $CrLf + " http://www.garybeene.com/"
                                End If
                             End If
                          Case %WM_Notify
                             If CB.NmID = %ID_RichEdit AND CB.Nmcode = %EN_Link Then
                                RichEditHyperLink(hDlg, CB.lParam)
                             End If
                       End Select
                    End Function
                    
                    Sub RichEditCreate
                        LoadLibrary("riched32.dll")
                        Call InitCommonControls
                        Control Add "RichEdit", hDlg, %ID_RichEdit, "", 20, 50, 160, 140, _
                                 %WS_Child Or %WS_Visible Or %ES_MultiLine Or %WS_VScroll Or %ES_AutoHScroll _
                                 Or %WS_HScroll Or %ES_AutoVScroll Or %ES_WantReturn Or %ES_NoHideSel Or %WS_TabStop, _
                                 %WS_Ex_ClientEdge
                        Control Handle hDlg, %ID_RichEdit To hRichEdit
                        SendMessage hRichEdit, %EM_SETEVENTMASK, 0, %ENM_SELCHANGE Or %ENM_CHANGE Or %ENM_LINK
                    End Sub
                    
                    Function RichEditHyperLink(ByVal hWnd As Dword, ByVal lpLink As Dword) As Long
                        Local enlinkPtr As ENLINK Ptr, tr As TEXTRANGE, linkText As String
                        enlinkPtr    = lpLink
                        tr.chrg      = @enLinkPtr.chrg
                        linkText     = Space$(tr.chrg.cpMax - tr.chrg.cpMin + 2)
                        tr.lpstrText = StrPTR(linkText)
                        Control Send hWnd, %ID_RICHEDIT, %EM_GETTEXTRANGE, 0, VarPTR(tr)
                        Select Case @enLinkPtr.Msg
                            Case %WM_LButtonDown
                                ShellExecute(%NULL, "open", ByCopy linkText, "", "", %SW_Show)
                                Function = %True                    ' Signal that we processed this
                            Case %WM_MouseMove
                        End Select
                    End Function
                    
                    'gbs_00225

                    Comment


                    • #11
                      Please Gary, there is some problem when I compile your code.
                      May be with fields CB.msg / CB.Ctl / CB.Ctlmsg / CB.NmID / CB.NmCode / etc...
                      Thanks.

                      Comment


                      • #12
                        Originally posted by Paulo Ferreira View Post
                        fields CB.msg / CB.Ctl / CB.Ctlmsg / CB.NmID / CB.NmCode / etc...
                        Are you using Version 8 compiler perchance?

                        Comment


                        • #13
                          Yes. 8.05.0042

                          Not sure in this part:

                          CASE %WM_Notify
                          IF CBCTL = %ID_RichEdit AND CBCTLMSG = %EN_Link THEN
                          RichEditHyperLink(hDlg, CBLPARAM)
                          END IF
                          END SELECT
                          Last edited by Paulo Ferreira; 15 Aug 2011, 07:28 PM. Reason: more inf

                          Comment


                          • #14
                            Paulo,
                            Do you mean this:?
                            Code:
                                  Case %WM_Notify
                                     If CB.NmID = %ID_RichEdit AND CB.Nmcode = %EN_Link Then
                                        RichEditHyperLink(hDlg, CB.lParam)
                                     End If
                            what you posted, asking about, was this:
                            Code:
                            CASE %WM_Notify
                               IF CBCTL = %ID_RichEdit AND CBCTLMSG = %EN_Link THEN
                                  RichEditHyperLink(hDlg, CBLPARAM)
                               END IF
                            My code was compiled in PBWin9. I don't have v8, but I think the CB.xx feature was new to v9. Help in v9 says:
                            These functions are only valid inside a Callback Function. The CB Callback functions replace CBMSG, CBHNDL, CBLPARAM, CBWPARAM, CBCTL, and CBCTLMSG . Note these functions may not be supported in future versions of PowerBASIC, so update your code to use the new syntax.
                            ... reading more, I see also that WM_Notify wasn't available in v8.
                            Prior to version 9.0 of PowerBASIC for Windows, Control Callback Functions received only %WM_COMMAND messages. Beginning with PB 9.0, %WM_NOTIFY messages are sent as well. There are many situations where these added messages will prove to be very important. If your existing callback functions are written with complete error checking (ensuring that CB.MSG = %WM_COMMAND), this minor addition will cause no problems. It just presents additional information which can be acted upon, or just ignored. However, if callbacks were written without complete error checking, some ambiguity is possible. In this case, you should either update your Control Callback code, or suppress %WM_NOTIFY messages with a #MESSAGES COMMAND metastatement
                            Last edited by Gary Beene; 15 Aug 2011, 08:34 PM.

                            Comment


                            • #15
                              So, if you're going to compile with v8, the question is how to code this, which compiles in v9:

                              Code:
                              CASE %WM_Notify
                                 IF CBCTL = %ID_RichEdit AND CBCTLMSG = %EN_Link THEN       
                                    RichEditHyperLink(hDlg, CBLPARAM)    
                                 END IF
                              to it's equivalent in v8.

                              Comment


                              • #16
                                Wait, I misunderstood Help about v8.
                                Control Callback Functions received only %WM_COMMAND messages. Beginning with PB 9.0, %WM_NOTIFY messages are sent as well.
                                The PBMain callback has always received WM_Notify. Help was referring only to Control Callback Function.

                                So the code as I posted it (not as you rewrote it), should have worked in v8 (with the CB.xx statement changed as needed, yes?

                                Comment


                                • #17
                                  This link is from 2001, which should be pre-PBWin9, and also shows the hyperlink code for the RichEdit control.

                                  Comment


                                  • #18
                                    Ok.
                                    Any example to do simple words (not urls: http, ftp, mailto, etc) modify
                                    cursor to "hand" and detect clic to event generate ?
                                    Something like: Clic here to see ...

                                    Comment


                                    • #19
                                      Paulo,

                                      Peter's original example used links as opposed to URLs which the later 'upgrades' used.

                                      The docs indicate that the technique that he used (EMN_LINK) was introduced with RichEdit20.dll but it does seem to work ok with RichEdit32.dll - or at least the emulation of RichEdit Ver 1.0 that is available on my pc (Win7) and is probably the same for those built into windows from Win2k onwards..?

                                      Here's a stripped down version of his code that works on my PC (Win7)..
                                      Code:
                                       
                                      #COMPILE EXE
                                      #DIM ALL
                                       
                                      #INCLUDE "WIN32API.INC"
                                      #INCLUDE "COMMCTRL.INC"
                                      #INCLUDE "RICHEDIT.INC"
                                       
                                      %ID_RICHEDIT  = 500
                                      %ID_URLLABEL  = 502
                                       
                                      DECLARE CALLBACK FUNCTION DlgCallback()
                                      '------------------/
                                       
                                      FUNCTION PBMAIN
                                        LOCAL hDlg AS DWORD
                                       
                                          LoadLibrary("RICHED32.DLL")                           ' RichEd Ver 1.0 (or emulation)
                                          CALL InitCommonControls
                                       
                                          DIALOG NEW 0, "DDT RichEdit Hyperlink demo",,, 320, 140, %WS_CAPTION OR %WS_SYSMENU TO hDlg
                                            CONTROL ADD LABEL, hDlg, %ID_URLLABEL, " ", 10, 5, 100, 15
                                       
                                            CONTROL ADD "RichEdit", hDlg, %ID_RICHEDIT, "This is a HyperLink for testing"+$CRLF, 10, 20, 300, 110, _
                                              %WS_CHILD OR %WS_VISIBLE OR %ES_MULTILINE OR %ES_WANTRETURN OR %ES_NOHIDESEL, %WS_EX_CLIENTEDGE
                                       
                                                                                                            '     Enable EN_LINK notifications
                                            CONTROL SEND hDlg, %ID_RICHEDIT, %EM_SETEVENTMASK, 0, %ENM_LINK ' Supposed to be RE Ver 2.0 and later ie not < win2K ??
                                                                                                            ' - included in later OS Ver 1.0 emulations anyway?
                                            CONTROL SET FOCUS hDlg, %ID_RICHEDIT
                                       
                                          DIALOG SHOW MODAL hDlg CALL DlgCallback
                                       
                                      END FUNCTION
                                      '------------------/
                                       
                                      CALLBACK FUNCTION DlgCallback()
                                        LOCAL enlnk     AS ENLINK
                                        LOCAL enlinkPtr AS ENLINK PTR
                                        LOCAL hHandCur  AS DWORD
                                       
                                        SELECT CASE CBMSG
                                          CASE %WM_INITDIALOG
                                            LOCAL cf AS CHARFORMAT2
                                              ' Select text and apply CFM_LINK effects
                                              CONTROL SEND CBHNDL, %ID_RICHEDIT, %EM_SETSEL, 10, 19             ' select chars for link effects
                                                cf.cbSize = LEN( cf )     ' Length of charformat structure
                                                cf.dwMask = %CFM_LINK     ' Set mask to link
                                                cf.dwEffects = %CFE_LINK
                                                CONTROL SEND CBHNDL, %ID_RICHEDIT, %EM_SETCHARFORMAT, %SCF_SELECTION, VARPTR( cf )    ' apply effects
                                              CONTROL SEND CBHNDL, %ID_RICHEDIT, %EM_SETSEL, -1, -1             ' finished with char selection
                                       
                                          CASE %WM_NOTIFY
                                              enlinkPtr = CBLPARAM      ' Pointer to the ENLINK structure
                                              enlnk = @enlinkPtr
                                              IF enlnk.nmhdr.code = %EN_LINK AND enlnk.nmhdr.idFrom = %ID_RICHEDIT THEN
                                                SELECT CASE enLnk.msg
                                                  CASE %WM_LBUTTONDOWN
                                                      CALL ShellExecute(%NULL,"open","[URL="http://www.powerbasic.com","","",%SW_SHOW"]www.powerbasic.com","","",%SW_SHOW[/URL])
                                       
                                                  CASE %WM_MOUSEMOVE
                                                      CONTROL SET TEXT CBHNDL, %ID_URLLABEL, "[URL="http://www.powerbasic.com"]www.powerbasic.com[/URL]"
                                                      hHandCur = GetCursor()
                                       
                                                END SELECT
                                              END IF
                                       
                                          CASE %WM_SETCURSOR
                                            IF GetCursor <> hHandCur THEN
                                              CONTROL SET TEXT CBHNDL, %ID_URLLABEL, " "
                                            END IF
                                       
                                        END SELECT
                                      END FUNCTION
                                      '------------------/
                                      Last edited by Dave Biggs; 18 Aug 2011, 07:24 AM. Reason: Modify URL label display
                                      Rgds, Dave

                                      Comment


                                      • #20
                                        Richedit control versions, what was supported when:

                                        http://msdn.microsoft.com/en-us/libr...73(VS.85).aspx

                                        Go to MSDN home @ http://msdn.microsoft.com/en-us/default.aspx

                                        Put "richedit versions" in search box and go. Can't miss it.
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X