Listview mit Hyperlink

  • Hallo,

    weiß jemand wie man einen Hyperlink in eine Listview einbauen kann?

    Meine Versuche:

    Spoiler anzeigen
    [autoit]


    #include <GuiListView.au3>

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

    Const $programm = 'Tierliste'

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

    GUICreate($programm, 500, 250)
    $GuiBut_beenden = GUICtrlCreateButton('Beenden', 5, 5)
    $GuiList = GUICtrlCreateListView('Nr|Tiergattung|Adresse|', 80, 20, 400, 200, 0x0001, BitOR(0x00000001, 0x00000020, 0x00010000))
    GUICtrlCreateListViewItem('1|hunde|http://www.hunde.de', $GuiList)
    GUICtrlCreateListViewItem('2|katzen|http://www.katzen.de', $GuiList)
    _GUICtrlListView_SetColumnWidth($GuiList, 2, 50)
    GUISetState()
    Global $hWndListView = GUICtrlGetHandle($GuiList)
    _GUICtrlListView_RegisterSortCallBack($hWndListView)
    Do
    $aktion = GUIGetMsg()
    Switch $aktion
    Case $GuiList
    _GUICtrlListView_SortItems($hWndListView, GUICtrlGetState($GuiList))
    MsgBox(0, "Listview", "angeklickt=" & GUICtrlGetState($GuiList), 2)

    Case $GuiBut_beenden
    ContinueCase
    Case -3
    _GUICtrlListView_UnRegisterSortCallBack($hWndListView)
    Exit

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

    EndSwitch
    Until 0

    [/autoit]

    Ich meine wenn man in die 2. Spalte klickt (Gattung)
    daß dann der Link gestartet wird.
    Konnte nichts finden.

    Geht das?

    Liebe Grüße
    Ilse ;)

    2 Mal editiert, zuletzt von Ilse (23. Juni 2011 um 11:57)

  • Hallo Bugfix,

    ich habe mir die Dateien heruntergeladen
    erhalte aber diesen Fehler:

    ERROR: $HDN_FIRST previously declared as a 'Const'

    Das ist die UDF
    _ListView_SysLink

    Spoiler anzeigen
    [autoit]


    ;===================================================================================================
    ; UDF Name: _ListView_SysLink
    ; Description: Set of functions to set Hyperlink (via SysLink control) for ListView items.
    ;
    ; Requirement(s): AutoIt 3.2.12.1 and above
    ;
    ; Author(s): G.Sandler (a.k.a MsCreatoR), initial concept idea by R.Gilman (a.k.a rasim), this UDF idea by ptrex!
    ;
    ; History:
    ; v1.0 [10.10.2008, 02:20]
    ; First release.
    ;
    ; v1.1 [21.10.2008, 00:03]
    ; - Added handler to activate the main window when SysLink control is focused.
    ; This handler also set hot cursor ($OCR_NO) while user trying to drag the SysLink control.
    ;
    ; - Added 2 more functions:
    ; _GUICtrlListView_SysLinkSetLinkInfo() - Sets link information.
    ; _GUICtrlListView_SysLinkGetLinkInfo() - Gets link information.
    ;
    ; - Added WM_CTLCOLORSTATIC registration to set bk color for the SysLink control.
    ; (To change the color just set $nSysLinkBkColor variable to desired color).
    ;
    ; - Rewrited parameters for the _GUICtrlListView_SysLinkCreate() function...
    ; * $sTextFormat splitted into different 3 parameters: $sTitle, $sLink and $iLnkID.
    ; * Added $iFillItemText - Allows to fill item text (SysLink text),
    ; so the LV item will have the same text as SysLink control. Default is 1.
    ;
    ; - Fixed inactive GUI window after executing url.
    ;===================================================================================================
    ;

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

    #include-once
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>
    #include <Misc.au3>
    #include <GuiListView.au3>
    ;

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

    Global Const $OCR_APPSTARTING = 32650
    Global Const $OCR_NORMAL = 32512
    Global Const $OCR_CROSS = 32515
    Global Const $OCR_HAND = 32649
    Global Const $OCR_IBEAM = 32513
    Global Const $OCR_NO = 32648
    Global Const $OCR_SIZEALL = 32646
    Global Const $OCR_SIZENESW = 32643
    Global Const $OCR_SIZENS = 32645
    Global Const $OCR_SIZENWSE = 32642
    Global Const $OCR_SIZEWE = 32644
    Global Const $OCR_UP = 32516
    Global Const $OCR_WAIT = 32514

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

    Global Const $SW_HIDE = 0
    Global Const $SW_SHOW = 5

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

    Global Const $HDN_FIRST = -300
    Global Const $HDN_ITEMCHANGINGA = $HDN_FIRST - 0
    Global Const $HDN_ITEMCHANGEDA = $HDN_FIRST - 1

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

    ;Global Const $LOGPIXELSX = 88
    ;Global Const $PROOF_QUALITY = 2

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

    Global Const $ICC_LINK_CLASS = 0x8000
    Global Const $LIF_ITEMINDEX = 0x1
    Global Const $LIF_STATE = 0x2
    Global Const $LIF_URL = 0x8
    Global Const $LIF_ITEMID = 0x4
    Global Const $LIS_ENABLED = 0x2
    Global Const $LIS_FOCUSED = 0x1
    Global Const $LIS_VISITED = 0x4
    Global Const $MAX_LINKID_TEXT = 48
    Global Const $L_MAX_URL_LENGTH = (2048 + 32 + StringLen("://"))
    Global Const $WC_LINK = "SysLink"

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

    Global Const $COINIT_MULTITHREADED = 0x0
    Global Const $COINIT_APARTMENTTHREADED = 0x2
    Global Const $COINIT_DISABLE_OLE1DDE = 0x4
    Global Const $COINIT_SPEED_OVER_MEMORY = 0x8

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

    Global Const $LM_SETITEM = ($WM_USER + 0x302)
    Global Const $LM_GETIDEALHEIGHT = ($WM_USER + 0x301)
    Global Const $LM_GETITEM = ($WM_USER + 0x303)
    Global Const $LM_HITTEST = ($WM_USER + 0x300)

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

    Global Const $LITEM = "int;int;int;int;wchar[" & $MAX_LINKID_TEXT & "];wchar[" & $L_MAX_URL_LENGTH & "]"
    Global Enum $iMask = 1, $iLink, $iState, $iStateMask, $iID, $iUrl

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

    Global $aSysLink[1][1]
    Global $hLastSysLink = -1
    Global $iSetFirstSubItem = True
    Global $iSysLinkIsActive = 0
    Global $nSysLinkBkColor = 0xFFFFFF
    Global $nSysLinkStockObject = $WHITE_BRUSH

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

    GUIRegisterMsg($WM_CTLCOLORSTATIC, "_ListView_SysLink_WM_CTLCOLORSTATIC")
    GUIRegisterMsg($WM_NOTIFY, "_ListView_SysLink_NOTIFY_EVENTS")
    GUIRegisterMsg($WM_SIZE, "_ListView_SysLink_NOTIFY_EVENTS")
    GUIRegisterMsg($WM_ACTIVATE, "_ListView_SysLink_WM_ACTIVATE")

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

    Func _ListView_SysLink_NOTIFY_EVENTS($hWnd, $nMsg, $wParam, $lParam)
    If $nMsg = $WM_SIZE Then
    For $i = 1 To $aSysLink[0][0]
    _GUICtrlListView_SysLinkSetItem($i)
    Next

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

    Return $GUI_RUNDEFMSG
    EndIf

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

    Local Const $tagNMLINK = $tagNMHDR & ";UINT mask; int iLink; UINT state; UINT stateMask; WCHAR szID[48]; WCHAR szUrl[2083]"
    Local $tNMHDR, $iCode, $hWndFrom, $hLV

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

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")

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

    $hLV = GUIGetCursorInfo($hWnd)

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

    If Not @error Then $hLV = GUICtrlGetHandle($hLV[4])
    If Not IsHWnd($hLV) Then $hLV = -1

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

    Switch $iCode
    Case $NM_CLICK, $NM_RETURN ;Handle the SysLink clicks
    For $i = 1 To $aSysLink[0][0]
    If $aSysLink[$i][0] = $hWndFrom Then
    Local $NMHDR = DllStructCreate($tagNMLINK, $lParam)

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

    Local $iLink = DllStructGetData($NMHDR, "iLink")
    Local $szURL = DllStructGetData($NMHDR, "szURL")
    Local $szID = DllStructGetData($NMHDR, "szID")

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

    If $szURL <> "" Then
    $iSysLinkIsActive = 1
    WinActivate($hWnd) ;Fix for inactive GUI window after executing url

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

    DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", "", "string", $szURL, _
    "string", "", "string", "", "long", @SW_SHOWNORMAL)

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

    Local $aLink_Info = _GUICtrlListView_SysLinkGetLinkInfo($aSysLink[$i][0])
    If @error Then ExitLoop

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

    _GUICtrlListView_SysLinkSetLinkInfo($aSysLink[$i][0], $szURL, $szID, BitOR($aLink_Info[1], $LIS_VISITED))
    EndIf

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

    ExitLoop
    EndIf
    Next
    Case $HDN_ITEMCHANGEDA, $HDN_ITEMCHANGEDW, $LVN_ENDSCROLL ;Move the SysLink window
    For $i = 1 To $aSysLink[0][0]
    _GUICtrlListView_SysLinkSetItem($i, $hLV)
    Next
    Case $HDN_ITEMCHANGINGA, $HDN_ITEMCHANGINGW
    _WinAPI_RedrawWindow($hLV, 0, 0, $RDW_INVALIDATE)
    EndSwitch

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

    Return $GUI_RUNDEFMSG
    EndFunc

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

    Func _ListView_SysLink_WM_ACTIVATE($hWnd, $nMsg, $wParam, $lParam)
    Local $nActive = BitAnd($wParam, 0x0000FFFF)
    Local $hActWnd = $lParam

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

    If $nActive Or $hActWnd = $hWnd Then Return $GUI_RUNDEFMSG

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

    Local $hHovered_Ctrl = _ControlGetHovered()
    If $hHovered_Ctrl <> $hActWnd And $hHovered_Ctrl <> $hWnd Then Return $GUI_RUNDEFMSG

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

    Local $aCurInfo = GUIGetCursorInfo($hWnd)

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

    If Not @error And $aCurInfo[2] = 1 Then
    Local $ahCursor = DllCall("user32.dll", "int", "LoadCursorW", "hwnd", 0, "int", $OCR_NORMAL)
    DllCall("user32.dll", "int", "SetSystemCursor", "int", $ahCursor[0], "int", $OCR_NO)

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

    For $i = 1 To $aSysLink[0][0]
    If $aSysLink[$i][0] <> $hActWnd Then WinSetState($aSysLink[$i][0], "", @SW_DISABLE)
    Next

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

    While $aCurInfo[2] = 1
    $aCurInfo = GUIGetCursorInfo($hWnd)
    If @error Then ExitLoop

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

    Sleep(1)
    WEnd

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

    $ahCursor = DllCall("user32.dll", "int", "LoadCursorW", "hwnd", 0, "int", $OCR_NO)
    DllCall("user32.dll", "int" , "SetSystemCursor", "int", $ahCursor[0], "int", $OCR_NORMAL)

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

    If Not $iSysLinkIsActive Then
    If _ControlGetHovered() <> $hActWnd Then DllCall("user32.dll", "int", "MessageBeep", "int", -1)
    WinActivate($hWnd)
    EndIf

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

    For $i = 1 To $aSysLink[0][0]
    WinSetState($aSysLink[$i][0], "", @SW_ENABLE)
    Next

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

    $iSysLinkIsActive = False
    ElseIf Not @error And $aCurInfo[3] = 1 Then
    WinActivate($hActWnd)
    WinActivate($hWnd)
    Else
    WinActivate($hWnd)
    EndIf
    EndFunc

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

    Func _ListView_SysLink_WM_CTLCOLORSTATIC($hWnd, $Msg, $wParam, $lParam)
    For $i = 1 To $aSysLink[0][0]
    If $lParam = $aSysLink[$i][0] Then
    ;DllCall("gdi32.dll", "int", "SetBkMode", "hwnd", $wParam, "int", $TRANSPARENT)
    ;DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $wParam, "int", 0xFF0000)
    DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $wParam, "int", $nSysLinkBkColor)

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

    Return _WinAPI_GetStockObject($nSysLinkStockObject)
    EndIf
    Next

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

    Return $GUI_RUNDEFMSG
    EndFunc

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

    ;===================================================================================================
    ; Function Name: _GUICtrlListView_SysLinkCreate()
    ; Description: Inserts a Hyperlink (SysLink control) into the ListView Item.
    ; Syntax.........: _GUICtrlListView_SysLinkCreate($sHwnd, $sItemIndex[, $sSubItemIndex])
    ; Parameter(s): $sHwnd - Handle to the ListView control.
    ; $sTitle - Link Title (i.e: "AutoIt Home page").
    ; $sLink - Link URL (i.e: "http://autoitscript.com").
    ; $sItemIndex - Zero based index of the item at which the progressbar should be inserted.
    ; $sSubItemIndex - [Optional] Zero based index of the subitem where progressbar should be placed, +default is 1.
    ; $sLnkID - [Optional] SysLink identifier (i.e: "LInkIDURL+ID").
    ; $iFillItemText - [Optional] If this parameter = 1 (it is the default),
    ; the function will set the item (by $iItemIndex and $iSubItemIndex) with text from $sTitle.
    ;
    ; Return Value(s): Returns the Handle of the new SysLink control.
    ; Requirement(s): AutoIt 3.2.12.1 and above.
    ; Note(s):
    ;
    ; Author(s): G.Sandler (a.k.a MsCreatoR)
    ;===================================================================================================
    Func _GUICtrlListView_SysLinkCreate($hWnd, $sTitle, $sLink, $iItemIndex, $iSubItemIndex=0, $sLnkID="", $iFillItemText=1)
    If $hWnd = -1 Then $hWnd = $hLastSysLink

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

    If $iFillItemText = 1 Then _GUICtrlListView_SetItemText($hWnd, $iItemIndex, $sTitle, $iSubItemIndex)

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

    ;Local $nBkColor = _WinAPI_GetSysColor($COLOR_3DFACE)
    ;GUICtrlSetBkColor($hWnd, $nBkColor)

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

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

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

    Local $aRect = _GUICtrlListView_GetSubItemRect($hWnd, $iItemIndex, $iSubItemIndex)
    If $iSetFirstSubItem And $iSubItemIndex = 0 Then $aRect = _GUICtrlListView_GetItemRect($hWnd, $iItemIndex, 2)

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

    Local $sTextFormat = StringFormat('<a href="%s" ID="%s">%s</a>', $sLink, $sLnkID, $sTitle)

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

    $aSysLink[0][0] += 1
    ReDim $aSysLink[$aSysLink[0][0] + 1][4]

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

    $aSysLink[$aSysLink[0][0]][0] = _WinAPI_CreateWindowEx($WS_EX_TOPMOST, $WC_LINK, $sTextFormat, _
    BitOR($WS_POPUP, $WS_VISIBLE, $WS_CHILD), $aRect[0], $aRect[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1], $hWnd)

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

    DllCall("user32.dll", "int", "SetParent", "hwnd", $aSysLink[$aSysLink[0][0]][0], "hwnd", $hWnd)

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

    _GUICtrlListView_SysLinkSetLinkInfo($aSysLink[$aSysLink[0][0]][0], $sLink, $sLnkID)

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

    $aSysLink[$aSysLink[0][0]][1] = $iItemIndex
    $aSysLink[$aSysLink[0][0]][2] = $iSubItemIndex
    $aSysLink[$aSysLink[0][0]][3] = $hWnd

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

    $hLastSysLink = $aSysLink[$aSysLink[0][0]][0]

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

    Return $hLastSysLink
    EndFunc

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

    Func _GUICtrlListView_SysLinkDelete($hWnd)
    Local $aTmpArr[1][1]

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

    If $hWnd = -1 Then $hWnd = $hLastSysLink

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

    For $i = 1 To $aSysLink[0][0]
    If $aSysLink[$i][0] <> $hWnd Then
    $aTmpArr[0][0] += 1
    ReDim $aTmpArr[$aTmpArr[0][0]+1][4]

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

    $aTmpArr[$aTmpArr[0][0]][0] = $aSysLink[$i][0]
    $aTmpArr[$aTmpArr[0][0]][1] = $aSysLink[$i][1]
    $aTmpArr[$aTmpArr[0][0]][2] = $aSysLink[$i][2]
    $aTmpArr[$aTmpArr[0][0]][3] = $aSysLink[$i][3]
    EndIf
    Next

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

    $aSysLink = $aTmpArr

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

    Local $aResult = DllCall("User32.dll", "int", "DestroyWindow", "hwnd", $hWnd)
    If @error Then Return SetError(1, 0, 0)

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

    Return $aResult[0] <> 0
    EndFunc

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

    Func _GUICtrlListView_SysLinkSetItem($iID, $hLV=-1)
    If $iID > $aSysLink[0][0] Or $iID < 1 Then Return SetError(1, 0, 0)

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

    Local $iItemIndex = $aSysLink[$iID][1]
    Local $iSubItemIndex = $aSysLink[$iID][2]
    Local $LV_hWnd = $aSysLink[$iID][3]

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

    If $hLV <> -1 And $LV_hWnd <> $hLV Then Return SetError(2, 0, 0)

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

    Local $aRect = _GUICtrlListView_GetSubItemRect($LV_hWnd, $iItemIndex, $iSubItemIndex)
    If $iSetFirstSubItem And $iSubItemIndex = 0 Then $aRect = _GUICtrlListView_GetItemRect($LV_hWnd, $iItemIndex, 2)
    If $aRect[0] = 0 And $iSubItemIndex <> 0 Then Return SetError(3, 0, 0)

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

    If $aRect[1] < 20 And BitAND(WinGetState($aSysLink[$iID][0]), 2) Then
    _WinAPI_ShowWindow($aSysLink[$iID][0], $SW_HIDE)
    ElseIf $aRect[1] >= 20 And BitAND(WinGetState($aSysLink[$iID][0]), 2) = 0 Then
    _WinAPI_ShowWindow($aSysLink[$iID][0], $SW_SHOW)
    EndIf

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

    _WinAPI_MoveWindow($aSysLink[$iID][0], $aRect[0], $aRect[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1], True)
    _WinAPI_RedrawWindow($aSysLink[$iID][0], 0, 0, $RDW_INVALIDATE)
    EndFunc

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

    Func _GUICtrlListView_SysLinkSetFont($hWnd, $sFontName="Arial", $iFontSize=10, $iFontWeight=400, $iFontItalic=0, $iFontUnderline=0, $iFontStrikeThru=0)
    Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", 0, "long", $LOGPIXELSX)
    If @error Or $aRet[0] = -1 Then Return SetError(1, 0, 0)

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

    Local $lfHeight = Round(($iFontSize * $aRet[2]) / 72, 0)
    Local $stFont = DllStructCreate("int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[32]")

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

    DllStructSetData($stFont, 1, $lfHeight + 1)
    DllStructSetData($stFont, 5, $iFontWeight)
    DllStructSetData($stFont, 6, $iFontItalic)
    DllStructSetData($stFont, 7, $iFontUnderline)
    DllStructSetData($stFont, 8, $iFontStrikeThru)
    DllStructSetData($stFont, 12, $PROOF_QUALITY)
    DllStructSetData($stFont, 14, $sFontName)

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

    If $hWnd = -1 Then $hWnd = $hLastSysLink

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

    $aRet = DllCall("gdi32.dll", "long", "CreateFontIndirect", "long", DllStructGetPtr($stFont))
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $WM_SETFONT, "long", $aRet[0], "int", True)
    EndFunc

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

    Func _GUICtrlListView_SysLinkSetLinkInfo($hWnd, $s_Link, $s_szID, $v_State=-1, $iLink_Num=0)
    Local $vMask

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

    If $v_State = -1 Then
    $vMask = BitOR($LIF_URL, $LIF_ITEMINDEX, $LIF_ITEMID)
    Else
    $vMask = BitOR($LIF_URL, $LIF_ITEMINDEX, $LIF_STATE, $LIF_ITEMID)
    EndIf

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

    Local $stLink = DllStructCreate($LITEM)

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

    DllStructSetData($stLink, $iMask, $vMask)
    DllStructSetData($stLink, $iLink, $iLink_Num)

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

    If $v_State <> - 1 Then
    DllStructSetData($stLink, $iState, $v_State)
    DllStructSetData($stLink, $iStateMask, $v_State)
    EndIf

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

    DllStructSetData($stLink, $iID, $s_szID)
    DllStructSetData($stLink, $iUrl, $s_Link)

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

    Local $aHL = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, _
    "int", $LM_SETITEM, "int", 0, "ptr", DllStructGetPtr($stLink))

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

    Return $aHL[0]
    EndFunc

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

    Func _GUICtrlListView_SysLinkGetLinkInfo($hWnd, $iLink_Num=0)
    Local $stLink = DllStructCreate($LITEM)

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

    DllStructSetData($stLink, $iMask, BitOR($LIF_URL, $LIF_ITEMINDEX, $LIF_STATE, $LIF_ITEMID))
    DllStructSetData($stLink, $iLink, $iLink_Num)
    DllStructSetData($stLink, $iStateMask, BitOR($LIS_ENABLED, $LIS_FOCUSED, $LIS_VISITED))

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

    Local $aHL = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, _
    "int", $LM_GETITEM, "int", 0, "ptr", DllStructGetPtr($stLink))

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

    If @error Or Not $aHL[0] Then Return SetError(1, 1, 0)

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

    Local $hLV = -1

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

    For $i = 1 To $aSysLink[0][0]
    If $aSysLink[$i][0] = $hWnd Then
    $hLV = $aSysLink[$i][3]
    ExitLoop
    EndIf
    Next

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

    Local $sRet = _
    DllStructGetData($stLink, $iState) & "|" & _
    DllStructGetData($stLink, $iUrl) & "|" & _
    DllStructGetData($stLink, $iID) & "|" & $hLV

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

    Return StringSplit($sRet, "|")
    EndFunc

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

    Func _ControlGetHovered($iGetDlgCtrlID=0)
    Local $iOld_Opt_MCM = Opt("MouseCoordMode", 1)

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

    Local $aRet = DllCall("user32.dll", "int", "WindowFromPoint", _
    "long", MouseGetPos(0), _
    "long", MouseGetPos(1))

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

    If $iGetDlgCtrlID Then $aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0])

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

    Opt("MouseCoordMode", $iOld_Opt_MCM)

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

    Return $aRet[0]
    EndFunc

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

    und das ist die Listview

    Spoiler anzeigen
    [autoit]


    #include <_ListView_SysLink.au3>

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

    $hGUI = GUICreate("ListView with SysLink Control!", 420, 530, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))

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

    $hListView1 = GUICtrlCreateListView("Files|Path|Links", 10, 10, 400, 240, BitOR($LVS_REPORT, $WS_BORDER, $WS_CLIPSIBLINGS))
    GUICtrlCreateListViewItem("AutoIT|C:\Program Files\AutoIt3", $hListView1)
    GUICtrlCreateListViewItem("Opera|C:\Program Files\Opera", $hListView1)
    GUICtrlCreateListViewItem("Script|C:\MyScripts", $hListView1)

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

    $nSysLinkBkColor = 0xC0C0C0
    $nSysLinkStockObject = $LTGRAY_BRUSH

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

    $hListView2 = GUICtrlCreateListView("Name|Links", 10, 270, 400, 240, BitOR($LVS_REPORT, $WS_BORDER, $WS_CLIPSIBLINGS))
    GUICtrlCreateListViewItem("Some Name", $hListView2)

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

    $hSysLink1 = _GUICtrlListView_SysLinkCreate($hListView1, "AutoIt Script Home Page", "http://autoitscript.com", 0, 2)
    _GUICtrlListView_SysLinkSetFont(-1, "Tahoma", 9.5)

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

    $hSysLink2 = _GUICtrlListView_SysLinkCreate($hListView1, "Opera Home Page", "http://opera.com", 1, 2)
    _GUICtrlListView_SysLinkSetFont(-1, "Tahoma", 9.5)

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

    $hSysLink3 = _GUICtrlListView_SysLinkCreate($hListView1, "My Scripts Home Page?", "http://creator-lab.ucoz.ru", 2, 2)
    _GUICtrlListView_SysLinkSetFont(-1, "Tahoma", 9.5)

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

    $hSysLink1_2 = _GUICtrlListView_SysLinkCreate($hListView2, "Some other Home Page", "http://creator-lab.ucoz.ru", 0, 1)
    _GUICtrlListView_SysLinkSetFont(-1, "Arial", 10.5)

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

    GUICtrlSetBkColor($hListView1, $nSysLinkBkColor)
    GUICtrlSetBkColor($hListView2, $nSysLinkBkColor)

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

    GUICtrlSendMsg($hListView1, $LVM_SETCOLUMNWIDTH, 0, 80)
    GUICtrlSendMsg($hListView1, $LVM_SETCOLUMNWIDTH, 1, 150)
    GUICtrlSendMsg($hListView1, $LVM_SETCOLUMNWIDTH, 2, 120)

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

    GUICtrlSendMsg($hListView2, $LVM_SETCOLUMNWIDTH, 0, 230)
    GUICtrlSendMsg($hListView2, $LVM_SETCOLUMNWIDTH, 1, 115)

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

    ;Here we add ID to the $hSysLink1
    _GUICtrlListView_SysLinkSetLinkInfo($hSysLink1, "http://autoitscript.com", "AutoIt")

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

    ;And now we check if it was added :)
    $aInfo = _GUICtrlListView_SysLinkGetLinkInfo($hSysLink1)
    $sInfo = StringFormat("Info For $hSysLink1:\n\nSysLink State\t\t= %i\nURL\t\t\t= %s\nID\t\t\t= %s\nParent ListView Handle\t= %s", _
    $aInfo[1], $aInfo[2], $aInfo[3], $aInfo[4])

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

    ConsoleWrite($sInfo)

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

    GUISetState(@SW_SHOW, $hGUI)

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

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    [/autoit]

    krieg es leider nicht zum laufen!


    Grüße
    Ilse ;)

    3 Mal editiert, zuletzt von Ilse (23. Juni 2011 um 14:01)

  • Hallo Bugfix,

    muß mich leider wieder melden.

    Es läuft jetzt (habe Zeile 59 escaped Errormeldung...)
    Sehe nun die Listview mit den Links
    aber die Hyperlinks funktionieren nicht!

    Man sieht zwar die Hand wenn man über den Link fährt,
    aber beim anklicken passiert nichts!

    Grüße
    Ilse ;)