Results 1 to 14 of 14

Thread: SysLink

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    SysLink

    Hi,

    Does anybody have a working example of the SysLink control ?

    Basically, I am trying to add the control at runtime to a hooked MsgBox in order to display a marked up text in it . I did manage to add the control to the MsgBox using creatwindowex + manifest but for some reason, the text that is displayed is static text (not hyperlink text as I expected)

    Any ideas ?

    Regards.

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: SysLink

    Quote Originally Posted by AthlonArg View Post
    Thanks but that uses the TaskDialogIndirect ... I am trying to add the hyperlink to a MsgBox.

    Seeing a Syslink added to a standard win32 window created from scratch (CreateWindowEx) would also help.

  4. #4
    Member
    Join Date
    Jan 2021
    Posts
    55

    Re: SysLink

    Quote Originally Posted by JAAFAR View Post
    Thanks but that uses the TaskDialogIndirect ... I am trying to add the hyperlink to a MsgBox.

    Seeing a Syslink added to a standard win32 window created from scratch (CreateWindowEx) would also help.
    But CtaskDialog has a Hyperlink support

    Last edited by AthlonArg; Jun 21st, 2021 at 09:37 PM.

  5. #5
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: SysLink

    VBCCR uses SysLink for the LinkLabel control.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: SysLink



    As you can see, the SysLink control is successfully created and added to the form but the text is not markedup text .


    Below is roughly the code I am using:
    Code:
    Public Sub AddTextLink( _
        ByVal UserForm As Object _
    )
    
        Const WS_CHILD = &H40000000
        Const WS_VISIBLE = &H10000000
        Const WC_LINK = "SysLink"
        Const ICC_LINK_CLASS = &H8000&
    
        Dim hwnd As Long, hSysLink As Long
        Dim tIccex As InitCommonControlsEx
        Dim sCaption As String
    
    
        Call IUnknown_GetWindow(UserForm, VarPtr(hwnd))
    
        With tIccex
            .Size = LenB(tIccex)
            .ICC = ICC_LINK_CLASS
        End With
    
        If InitCommonControlsEx(tIccex) Then
    
            sCaption = "<a href= " & Chr(34) & "www.google.com" & Chr(34) & ">click here</a>"
    
            hSysLink = CreateWindowEx(0, StrPtr(WC_LINK), StrPtr(sCaption), WS_CHILD + WS_VISIBLE, _
                                20, 20, 300, 20, hwnd, 0, GetModuleHandle(StrPtr(vbNullString)), 0)
    
        End If
        
    
    End Sub
    Can anyone spot where I am going wrong ?

  7. #7
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: SysLink

    Please post a fully copy & pasteable example with all API & UDT declares.

  8. #8
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: SysLink

    One thing I notice though is that your link address doesn't have a protocol. MSDN states:

    Code:
    SysLink Markup
    
    The SysLink control supports the anchor tag(<a>) along with the attributes HREF and ID. An HREF can be any protocol, such as http, ftp, and mailto.
    Maybe "https://" is required in front of "www.google.com"?

  9. #9
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: SysLink

    SysLink doesn't appear to like whitespace between the attribute and quotation mark. So use "HREF=" & Chr$(34) instead of "HREF= " & Chr$(34)

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: SysLink

    Quote Originally Posted by jpbro View Post
    SysLink doesn't appear to like whitespace between the attribute and quotation mark. So use "HREF=" & Chr$(34) instead of "HREF= " & Chr$(34)
    Wow! Brilliant !!

    After removing the whitespace, the SysLink control now displays the text as expected.



    Thank you very much.

    Now, subclassing the control remains to be done in order to handle the keyboard and mouse click events.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: SysLink

    I am monitoring the SysLink control windows messages in Spy++ but it captures only the WM_PAINT and WM_DESTROY messages !

    I can't see any other useful messages such as WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_MOUSELEAVE etc ...

    I have also subclassed the control after its creation but I have the same problem.

    I have also sent the LM_SETITEM notification message after creating the control as per the documentation, but still no joy.
    Code:
    Private Sub DoEnable()
      Dim tLitem As tagLITEM
      With tLitem
        .iLink = 0
        .mask = LIF_STATE + LIF_URL + LIF_ITEMINDEX + LIF_ITEMID
        .state = LIS_ENABLED + LIS_HOTTRACK
        .stateMask = LIS_ENABLED + LIS_HOTTRACK + LIS_FOCUSED
      End With
      Debug.Print SendMessage(hSysLink, LM_SETITEM, 0, tLitem) 'Returns 1 indicating success.
    End Sub
    Is there a Style that I have to set prior to subclassing the control ? What am I missing here ?
    Last edited by JAAFAR; Jun 23rd, 2021 at 11:19 PM.

  12. #12
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: SysLink

    Quote Originally Posted by JAAFAR View Post
    I am monitoring the SysLink control windows messages in Spy++ but it captures only the WM_PAINT and WM_DESTROY messages !

    I can't see any other useful messages such as WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_MOUSELEAVE etc ...

    I have also subclassed the control after its creation but I have the same problem.

    I have also sent the LM_SETITEM notification message after creating the control as per the documentation, but still no joy.
    Code:
    Private Sub DoEnable()
      Dim tLitem As tagLITEM
      With tLitem
        .iLink = 0
        .mask = LIF_STATE + LIF_URL + LIF_ITEMINDEX + LIF_ITEMID
        .state = LIS_ENABLED + LIS_HOTTRACK
        .stateMask = LIS_ENABLED + LIS_HOTTRACK + LIS_FOCUSED
      End With
      Debug.Print SendMessage(hSysLink, LM_SETITEM, 0, tLitem) 'Returns 1 indicating success.
    End Sub
    Is there a Style that I have to set prior to subclassing the control ? What am I missing here ?
    The LIS_HOTTRACK style is "dumb" in the SysLink control. You need to set it manually upon WM_MOVE in the control itself.
    Code:
    Case WM_MOUSEMOVE
        If PropHotTracking = True Then
            Dim LHTI1 As LHITTESTINFO, Index As Long
            With LHTI1
            .PT.X = Get_X_lParam(lParam)
            .PT.Y = Get_Y_lParam(lParam)
            With .Item
            If SendMessage(LinkLabelHandle, LM_HITTEST, 0, ByVal VarPtr(LHTI1)) <> 0 Then
                Index = .iLink + 1
            End If
            .iLink = 0
            .Mask = LIF_ITEMINDEX Or LIF_STATE
            .StateMask = LIS_HOTTRACK
            Do While SendMessage(LinkLabelHandle, LM_GETITEM, 0, ByVal VarPtr(LHTI1.Item)) <> 0
                If .State = LIS_HOTTRACK Then
                    If .iLink <> Index - 1 Or Index = 0 Then
                        .State = 0
                        SendMessage LinkLabelHandle, LM_SETITEM, 0, ByVal VarPtr(LHTI1.Item)
                    End If
                Else
                    If .iLink = Index - 1 And Index > 0 Then
                        .State = LIS_HOTTRACK
                        SendMessage LinkLabelHandle, LM_SETITEM, 0, ByVal VarPtr(LHTI1.Item)
                    End If
                End If
                .iLink = .iLink + 1
            Loop
            End With
            End With
        End If
    And also WM_MOUSELEAVE (you need to enable it once upon a WM_MOUSEMOVE and clear the "once" in WM_MOUSELEAVE; TrackMouseEvent API with TME_LEAVE)
    Code:
    Case WM_MOUSELEAVE
        If PropHotTracking = True Then
            Dim Item As LITEM
            With Item
            .iLink = 0
            .Mask = LIF_ITEMINDEX Or LIF_STATE
            .StateMask = LIS_HOTTRACK
            Do While SendMessage(LinkLabelHandle, LM_GETITEM, 0, ByVal VarPtr(Item)) <> 0
                If .State = LIS_HOTTRACK Then
                    .State = 0
                    SendMessage LinkLabelHandle, LM_SETITEM, 0, ByVal VarPtr(Item)
                End If
                .iLink = .iLink + 1
            Loop
            End With
        End If
    For the click and keyboard events, you need to subclass the parent of the SysLink and catch NM_CLICK or NM_RETURN.
    Last edited by Krool; Jun 24th, 2021 at 04:51 AM.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: SysLink

    The LIS_HOTTRACK style is "dumb" in the SysLink control. You need to set it manually upon WM_MOVE in the control itself.
    The problem is I can't handle the WM_MOVE nor the WM_MOUSELEAVE messages because, as I mentioned in my earlier post, the SysLink control doesn't seem to fire those windows messages. The WM_MOVE and the WM_MOUSELEAVE don't fire in SPY++ when I move the mouse pointer over the SysLink control ... Same problem when I subclass the control.


    Quote Originally Posted by Krool View Post
    For the click and keyboard events, you need to subclass the parent of the SysLink and catch NM_CLICK or NM_RETURN.
    When I subclass the SysLink control Parent window (ie: Form window) I don"t see the WM_NOTIFRY, NM_CLICK OR NM_RETURN either.
    Last edited by JAAFAR; Jun 24th, 2021 at 05:06 PM.

  14. #14
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: SysLink

    According to MSDN WM_NOTIFY should arrive. Can you please post your current *full* code for testing by others?

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