Jump to content

Recommended Posts

Posted (edited)

LAST VERSION - 1.0

09-May-11

I don't know why AutoIt does not support SysLink controls, and I tried to fix it. This library is written similary as other AutoIt GUI libraries. For more information, see detailed descriptions of all functions inside GuiSysLink.au3.

SysLink.png

Available functions

  Reveal hidden contents

_GUICtrlSysLink_Create

_GUICtrlSysLink_Destroy

_GUICtrlSysLink_GetIdealHeight

_GUICtrlSysLink_GetIdealSize

_GUICtrlSysLink_GetItemEnabled

_GUICtrlSysLink_GetItemFocused

_GUICtrlSysLink_GetItemHighlighted

_GUICtrlSysLink_GetItemID

_GUICtrlSysLink_GetItemState

_GUICtrlSysLink_GetItemUrl

_GUICtrlSysLink_GetItemVisited

_GUICtrlSysLink_GetText

_GUICtrlSysLink_HitTest

_GUICtrlSysLink_HitTestEx

_GUICtrlSysLink_SetItemEnabled

_GUICtrlSysLink_SetItemFocused

_GUICtrlSysLink_SetItemHighlighted

_GUICtrlSysLink_SetItemID

_GUICtrlSysLink_SetItemState

_GUICtrlSysLink_SetItemUrl

_GUICtrlSysLink_SetItemVisited

_GUICtrlSysLink_SetText

SysLink UDF Library v1.0

Previous downloads: 161

SysLink.zip

Example

#include <GUIConstantsEx.au3>
#include <GUISysLink.au3>
#include <GUIStatusBar.au3>
#include <WindowsConstants.au3>

$Text = 'The SysLink controls provides a convenient way to embed hypertext links in a window. For more information, click <A HREF="http://msdn.microsoft.com/en-us/library/bb760706(VS.85).aspx">here</A>.' & @CRLF & @CRLF & _
        'To learn how to use the SysLink controls in AutoIt, click <A HREF="http://www.autoitscript.com/forum/">here</A>.'

$hForm = GUICreate("MyGUI", 428, 160)
$hStatusBar = _GUICtrlStatusBar_Create($hForm)
$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 10, 10, 408, 54)
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

While 1
    _SysLink_Over()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy
            ShellExecute(_GUICtrlSysLink_GetItemUrl($hSysLink, GUICtrlRead($Dummy)))
    EndSwitch
WEnd

Func _SysLink_Over()

    Local $Link = _GUICtrlSysLink_HitTest($hSysLink)

    For $i = 0 To 1
        If $i = $Link Then
            If Not _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 1)
                _GUICtrlStatusBar_SetText($hStatusBar, _GUICtrlSysLink_GetItemUrl($hSysLink, $i))
            EndIf
        Else
            If _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 0)
                _GUICtrlStatusBar_SetText($hStatusBar, "")
            EndIf
        EndIf
    Next
EndFunc   ;==>_SysLink_Over

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
    Local $hFrom = DllStructGetData($tNMLINK, "hWndFrom")
    Local $ID = DllStructGetData($tNMLINK, "Code")

    Switch $hFrom
        Case $hSysLink
            Switch $ID
                Case $NM_CLICK, $NM_RETURN
                    GUICtrlSendToDummy($Dummy, DllStructGetData($tNMLINK, "Link"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by Yashied
Posted

Thanks for sharing.

MrCreator posted yesterday but I must point that SysLink is a more appropriate name selection for the control than gui hyperlink. In any case, this is much better than how I used to track links on rich edit controls to simulate the SysLink control.

Great work to all (Gary, MrCreator and Yashied). The one thing I'm going to miss from simulating SysLinks via Rich edit controls is being able to apply style to text.

Regards,

IVAN

Posted

@ivan: There is a small difference between this UDF and the one from MrCreator.

SysLink is a native control, that displays text like a label and parses links. GUICtrlHyperLink is just a label with predefined functionality :)

RichEidt should also allow links, but it is not too easy to create them.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted (edited)

Thx ProgAndy. I knew SysLinks controls were native, and found them difficult to handle in automation. Your script not only provides a means to create these controls but may also address Autoit's main purpose, automation, which gives it an additional advantage, not to dismiss the merit of any other alternatives.

Taking a closer look at MrCreator's script you are quite right, it's a label with a predefined behavior. As for the rich edit alternative, I never wrote a fully fledged UDF simultation of a SysLink, because my script(s) were basically a sub part (the About) of other scripts, and I never got round to making something of general applicability that may be re-utilized. Every other About I created, I just copied entire sections of old scripts and pasted them in new scripts, edited as required ... not very efficient, shame on me, I know.

Anyhow, ThumbsUp for this effort.

Ivan

Edited by ivan
Posted (edited)

Nice UDF but I have a question, why is the example listening for $NM_RETURN?

Ok so you can tab them after one being pressed...

Edit1: Also noted that if you press the AutoIt link in the example MSDN opens when on x64. What a mess.

Edit2: DllStructGetData($tNMLINK, "Link") always returns 0 on x64.

Edit3: How do you get the background color right? (like on tabs)

Edited by AdmiralAlkex
  • 1 month later...
Posted

  On 4/2/2011 at 5:28 PM, 'AdmiralAlkex said:

DllStructGetData($tNMLINK, "Link") always returns 0 on x64.

#1479

Replace

$tagNMLINK = $tagNMHDR & ";" & $tagLITEM

to

$tagNMLINK = "hwnd hWndFrom;uint_ptr IDFrom;int_ptr Code;" & $tagLITEM

in SysLinkConstants.au3.

Posted

  On 5/6/2011 at 2:34 PM, 'AdmiralAlkex said:

Any idea about the background color?

#include <GUIConstantsEx.au3>
#include <GUISysLink.au3>
#include <GUIStatusBar.au3>
#include <WindowsConstants.au3>

$Text = 'The SysLink controls provides a convenient way to embed hypertext links in a window. For more information, click <A HREF="http://msdn.microsoft.com/en-us/library/bb760706(VS.85).aspx">here</A>.' & @CRLF & @CRLF & _
        'To learn how to use the SysLink controls in AutoIt, click <A HREF="http://www.autoitscript.com/forum/">here</A>.'

$hForm = GUICreate("MyGUI", 468, 180)
$hStatusBar = _GUICtrlStatusBar_Create($hForm)
GUICtrlCreateTab(10, 10, 450, 138)
GUICtrlCreateTabItem('Tab1')
$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 30, 44, 408, 54)
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_CTLCOLORSTATIC, "WM_CTLCOLORSTATIC")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

While 1
    _SysLink_Over()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy
            ShellExecute(_GUICtrlSysLink_GetItemUrl($hSysLink, GUICtrlRead($Dummy)))
    EndSwitch
WEnd

Func _SysLink_Over()

    Local $Link = _GUICtrlSysLink_HitTest($hSysLink)

    For $i = 0 To 1
        If $i = $Link Then
            If Not _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 1)
                _GUICtrlStatusBar_SetText($hStatusBar, _GUICtrlSysLink_GetItemUrl($hSysLink, $i))
            EndIf
        Else
            If _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 0)
                _GUICtrlStatusBar_SetText($hStatusBar, "")
            EndIf
        EndIf
    Next
EndFunc   ;==>_SysLink_Over

Func WM_CTLCOLORSTATIC($hWnd, $iMsg, $wParam, $lParam)
    Switch $lParam
        Case $hSysLink
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_CTLCOLORSTATIC

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
    Local $hFrom = DllStructGetData($tNMLINK, "hWndFrom")
    Local $ID = DllStructGetData($tNMLINK, "Code")

    Switch $hFrom
        Case $hSysLink
            Switch $ID
                Case $NM_CLICK, $NM_RETURN
                    GUICtrlSendToDummy($Dummy, DllStructGetData($tNMLINK, "Link"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Posted

If you add the style $WS_TABSTOP to the control, the links are added to the normal tab-navigation of the GUI, so just press tab to select the link you want to open and press enter :unsure:

$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 30, 44, 408, 54, $WS_TABSTOP)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

  • 2 years later...
  • 8 months later...
Posted

Very usefull UDF 

I notice it works on AutoIt 3.3.10.2 but not on AutoIt 3.3.13.8

It is because __UDF_ValidateClassName() was removed from UDFGlobalID.au3

but Why it is removed with out any notice ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 8/22/2014 at 9:22 PM, mLipok said:

It is because __UDF_ValidateClassName() was removed from UDFGlobalID.au3

but Why it is removed with out any notice ?

Because it's an internal function. It was also a pointless function that served no real purpose.

Anything that is documented and breaks will be mentioned in the appropriate section.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...