Label in Gui als Link verwenden

  • Ganz einfach. :)

    Spoiler anzeigen
    [autoit]

    GUICreate("", 200, 50)
    $Label = GUICtrlCreateLabel("Das ist ein Link",10,10)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x0000FF)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $Label
    MsgBox(0,"It Works!","Ja, es funktioniert. :P")
    EndSwitch
    Sleep(10)
    WEnd

    [/autoit]

    MfG
    qixx

  • Wenn man nur bestimmte Teile eines Labels verlinken will hilft das SysLink-Control ;)

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    Global Const $WC_LINK = "SysLink"
    Global Const $WC_LINKA = $WC_LINK
    Global Const $WC_LINKW = $WC_LINK

    [/autoit] [autoit][/autoit] [autoit]

    $Parent = GUICreate("SysLink demo")

    [/autoit] [autoit][/autoit] [autoit]

    $g_hLink = _WinAPI_CreateWindowEx(0,$WC_LINK, _
    'For more information, <A HREF="http://www.microsoft.com" ID="LInkIDURL+ID">click here</A> or ' & _
    '<A href="http://www.microsoft.com">here</a> or ' & _
    '<A href="mailto:xxx.[email='yyyy@mycompany.com'][/email]&subject=Syslink Demo&body=%0A%0AFrom AutoIT%0A%0A&cc=cc@address.com&bcc=bcc@address.com">E-mail Me</a> or, ' & _
    '<A ID="idInfo">here</A>. And at last <a>here</a>', _
    BitOR($WS_VISIBLE , $WS_CHILD , $WS_TABSTOP), _
    10,10, 350,60, $Parent)
    GUICtrlCreateButton("hi",10,80,80,30)
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY,"MY_LINK_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While GUIGetMsg() <> -3
    Sleep(1)
    WEnd

    ;~ // g_hLink is the handle of the SysLink control.
    Func MY_LINK_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local Const $tagNMLINK = $tagNMHDR & ";" & "UINT mask; int iLink; UINT state; UINT stateMask; WCHAR szID[48]; WCHAR szUrl[2083];"
    Local $NMHDR = DllStructCreate($tagNMHDR,$lParam)
    Local $hwndFrom = DllStructGetData($NMHDR,"hwndFrom");
    Switch $hwndFrom
    Case $g_hLink
    switch DllStructGetData($NMHDR,"code")
    case $NM_CLICK
    ContinueCase
    case $NM_RETURN
    $NMHDR = DllStructCreate($tagNMLINK,$lParam)
    Local $iLink = DllStructGetData($NMHDR,"iLink")
    Local $szURL = DllStructGetData($NMHDR,"szURL")
    Local $szID = DllStructGetData($NMHDR,"szID")

    if $szURL <> "" Then
    Local $ShouldOpen = MsgBox(4, 'Open URL?',"Should the URL be opened? "& @CRLF & $szURL & _
    @CRLF & "If available, the Next Line Contains szID:" &@CRLF & $szID )
    If $ShouldOpen = 6 Then ShellExecute($szURL, "", "", "open",@SW_SHOW);
    ElseIf $szID <> "" Then
    MsgBox(0, 'Link Clicked',"The Link has no URL, but the following szID: " & @CRLF & $szID)
    Else
    MsgBox(0, 'Link Clicked',"The Link has no URL, and no szID: " & @CRLF & $szID)
    EndIf
    EndSwitch
    EndSwitch
    EndFunc

    [/autoit]