Jump to content

Hyperlink on ListView


Syed23
 Share

Recommended Posts

Hi All,

Quite i was spending 2 days on this task to complete and took some of our Experts help but still i couldn't able to complete :graduated: . What i wanted is i have created a ListView with gridlines. i am trying to add Hyperlink as a listview item.if i click on the hyperlink it should open that URL. This is what i wanted.. i looked in to the below topics and tried to made it to work still i couldn't complete ;)

i could able to create hyperlink but nothing happens if i click on the link...

Please some one help me on the tast?

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

This is a snippet from a much longer program I created. Maybe it will help you

You need from Yashied

#include <WindowsConstants.au3>
#Include <Constants.au3>
#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <winapi.au3>
#include <GuiListView.au3>
#include <GDIPlus.au3>
#include <GuiImageList.au3>
#include <ListViewConstants.au3>
#include <INet.au3>
#include <String.au3>
#Include <Icons.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
 
Opt("MouseCoordMode", 2)
global $listcolour="0x666666"
global $quickonoff=0, $view=0, $comparedate=0,$totalappointments
Global $listview,$listview2, $hImage,$listviewGui
_starting()
func _starting()
Global $listviewGui = GUICreate("listviews", 420, 150, -1, -1, $WS_POPUP,$WS_EX_TOOLWINDOW)
internetlinks()
GUISetState(@SW_SHOWNOACTIVATE, $listviewGui)
EndFunc
while 1
Sleep (1000)
WEnd
 
Func _Main()
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
Global $inireference="files.ini"
    $listview = GUICtrlCreateListView("", 0, 0, 420, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
GUICtrlSetBkColor(-1,$listcolour)
GUICtrlSetFont(-1,10,400,0,"Verdana")
    _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
 
  $longest=0
   For $j = 1 To $names[0]
    $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j])
    if $sections[0][0]>$longest then $longest=$sections[0][0]
   Next
    $sections = IniReadSection(@scriptdir&"\files.ini", $names[1])
   For $i = 1 To $longest
    if $sections[0][0]>=$i then
     if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then
      _GUIImageList_AddBitmap($hImage,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp")
     Else
  
       _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
     EndIf
    Else
     _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 50)
    EndIf
   Next
   For $j = 2 To $names[0]
   $count2=0
   Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j])
    For $i = 1 To $sections[0][0]
     if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then
      _GUIImageList_AddBitmap($hImage,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp")
     Else
       _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
     EndIf
    Next
   Next
 
    _GUICtrlListView_SetImageList($listview, $hImage, 1)
$count=0
   $longest=0
   For $j = 1 To $names[0]
    _GUICtrlListView_AddColumn($listview, $names[$j], 136)
    $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j])
    if $sections[0][0]>$longest then $longest=$sections[0][0]
    Next
    $sections = IniReadSection(@scriptdir&"\files.ini", $names[1])
   For $i = 1 To $longest
    if $sections[0][0]>=$i then
    _GUICtrlListView_AddItem($listview, $sections[$i][0],$count)
   Else
    _GUICtrlListView_AddItem($listview, "", $count)
   EndIf
   $count=$count+1
   Next
  
  For $j = 2 To $names[0]
   $count2=0
   Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j])
    For $i = 1 To $sections[0][0]
      _GUICtrlListView_AddSubItem($listview, $count2, $sections[$i][0], $j-1, $count)
      $count2=$count2+1
      $count=$count+1
    Next
   Next
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
EndFunc ;==>_Main
 
func internetlinks()
  _GDIPlus_Startup ()
Global $names = IniReadSectionNames(@scriptdir&"\files.ini")
For $j = 1 To $names[0]
;   ConsoleWrite($names[$j]&@CRLF)
;  if not $names[$j]="tools" then
  Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j])
   For $i = 1 To $sections[0][0]
  
     if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then ContinueLoop
     $itsago=get_favicon($sections[$i][1],$sections[$i][0])
     $image = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".ico")
   ;  ConsoleWrite(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".ico")
     $t = _GDIPlus_EncodersGetCLSID ("bmp")
     _GDIPlus_ImageSaveToFileEx ($image,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp",$t)
   Next
;  EndIf
Next
_GDIPlus_Shutdown ()
 
_Main()
EndFunc
Func get_favicon($favicon_page, $filenamed)
if not FileExists(@scriptdir&"\favicon") then DirCreate(@scriptdir&"\favicon")
If not FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then
dim $searcharray[5]=[".com",".ca",".org",".net",".edu"]
for $i=0 to UBound($searcharray)-1
  $stringpos=StringInStr($favicon_page,$searcharray[$i])
  if $stringpos<>0 Then
   $favicon_page=StringTrimRight($favicon_page,(stringlen($favicon_page)-($stringpos+StringLen($searcharray[$i])-1))) ;get first page
  EndIf
Next
    $hDownload1 = InetGet($favicon_page & "/favicon.ico", @ScriptDir & "\favicon\favicon_" & $filenamed&".ico")
  If not FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then
   $source = _INetGetSource($favicon_page)
   $resultarray = _StringBetween($source, 'href="', '"')
   If IsArray($resultarray) Then
    For $i = 0 To UBound($resultarray) - 1
    ; ConsoleWrite($resultarray[$i] & @CRLF)
     If StringInStr($resultarray[$i], ".ico") Then
      if StringLeft($resultarray[$i],1)="/" then $resultarray[$i] = $favicon_page & $resultarray[$i]
      $hDownload1 = InetGet($resultarray[$i], @ScriptDir & "\favicon\favicon_" & $filenamed&".ico")
     ; ConsoleWrite($favicon_page)
      ExitLoop
     EndIf
    Next
   EndIf
  EndIf
  If FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then
   Return True
  Else
   Return False
  EndIf
    EndIf
return "Already Exists"
EndFunc   ;==>get_favicon
 
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
 
     #forceref $hWndGUI, $MsgID, $wParam
     Local $tagNMHDR, $event
     If $wParam = $ListView Then
  
         $tagNMHDR = DllStructCreate("int;int;int", $lParam)
         $event = DllStructGetData($tagNMHDR, 3)
     If $event = $NM_CLICK  Then
      $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
      $Number=DllStructGetData($tInfo, "SubItem")
      $col1 = _GUICtrlListView_GetItemText($ListView,_GUICtrlListView_GetNextItem($ListView),$Number)
    $inireference="files.ini"
    $names = IniReadSectionNames(@scriptdir&"\"&$inireference)
   For $j = 1 To $names[0]
   $count2=0
   Global $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j])
    For $i = 1 To $sections[0][0]
      if $col1=$sections[$i][0] then
       _GUICtrlListView_SetItemSelected ($ListView, -1, 0)
       ShellExecute($sections[$i][1])
       Return $GUI_RUNDEFMSG
      EndIf
    Next
   Next
     elseIf $event = $NM_RCLICK  Then
      $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
      $Number=DllStructGetData($tInfo, "SubItem")
      $col1 = _GUICtrlListView_GetItemText($ListView,_GUICtrlListView_GetNextItem($ListView),$Number)
  
    $names = IniReadSectionNames(@scriptdir&"\"&$inireference)
   For $j = 1 To $names[0]
   $count2=0
   Global $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j])
    For $i = 1 To $sections[0][0]
     ;ConsoleWrite("C:\applications\opera10\opera.exe "&$sections[$i][1]&@crlf)
      if $col1=$sections[$i][0] then
      
       if FileExists("C:\applications\opera10\opera.exe") then
        _GUICtrlListView_SetItemSelected ($ListView, -1, 0)
        ShellExecute("C:\applications\opera10\opera.exe",$sections[$i][1])
        Return $GUI_RUNDEFMSG
       endif
      EndIf
    Next
   Next
   EndIf
  elseIf $wParam = $ListView2 Then
   $tagNMHDR = DllStructCreate("int;int;int", $lParam)
   $event = DllStructGetData($tagNMHDR, 3)
     If $event = $NM_CLICK  Then
      $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
      $Number=DllStructGetData($tInfo, "SubItem")
      $col1 = _GUICtrlListView_GetItemText($ListView2,_GUICtrlListView_GetNextItem($ListView2),$Number)
    $inireference="folders.ini"
    $names = IniReadSectionNames(@scriptdir&"\"&$inireference)
   For $j = 1 To $names[0]
   $count2=0
   $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j])
    For $i = 1 To $sections[0][0]
      if $col1=$sections[$i][0] then
       _GUICtrlListView_SetItemSelected ($ListView2, -1, 0)
       ShellExecute($sections[$i][1])
       Return $GUI_RUNDEFMSG
      EndIf
    Next
   Next
   EndIf
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

files.ini

[Autoit]
Forum=http://www.autoitscript.com/forum/
[Newspaper]
The Globe and Mail=http://www.theglobeandmail.com/
[Programs]
File hippo=http://www.filehippo.com
Opera=http://www.opera.com/
Edited by picea892
Link to comment
Share on other sites

Thanks for your responses. i will try to use of this :graduated: Also i got help from MrCreatoR to reslove that UDF issue ;) Thanks a lot anyways.....

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

  • 3 years later...

Hello, I'm getting the same problem with this UDF when I create the Hyperlink in a new child window, any help about fixing that please?

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

  • Moderators

EKY32,

Rather than inserting a full hyperlink into the ListView, why not just detect a doubleclick on the relevant cell and then run the link programatically? Much easier to manage. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

EKY32,

Let me know if I can help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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