-
Jun 21st, 2021, 08:02 PM
#1
Thread Starter
Fanatic Member
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.
-
Jun 21st, 2021, 08:30 PM
#2
Member
-
Jun 21st, 2021, 09:13 PM
#3
Thread Starter
Fanatic Member
Re: SysLink
Originally Posted by AthlonArg
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.
-
Jun 21st, 2021, 09:32 PM
#4
Member
Re: SysLink
Originally Posted by JAAFAR
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.
-
Jun 22nd, 2021, 07:04 AM
#5
Re: SysLink
VBCCR uses SysLink for the LinkLabel control.
-
Jun 22nd, 2021, 08:14 PM
#6
Thread Starter
Fanatic Member
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 ?
-
Jun 23rd, 2021, 12:00 PM
#7
Re: SysLink
Please post a fully copy & pasteable example with all API & UDT declares.
-
Jun 23rd, 2021, 12:02 PM
#8
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"?
-
Jun 23rd, 2021, 12:09 PM
#9
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)
-
Jun 23rd, 2021, 09:12 PM
#10
Thread Starter
Fanatic Member
Re: SysLink
Originally Posted by jpbro
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.
-
Jun 23rd, 2021, 11:14 PM
#11
Thread Starter
Fanatic Member
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.
-
Jun 24th, 2021, 04:47 AM
#12
Re: SysLink
Originally Posted by JAAFAR
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.
-
Jun 24th, 2021, 02:55 PM
#13
Thread Starter
Fanatic Member
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.
Originally Posted by Krool
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.
-
Jun 24th, 2021, 06:29 PM
#14
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|