Sign in to follow this  
Followers 0
AuToItItAlIaNlOv3R

Chebox on ListView

10 posts in this topic

#1 ·  Posted (edited)

Hi! i've a problem. I write a linkchecker that display me online and offlinelink. Now i would like to disable any offline link checkbox. For esample i've this code:

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <INet.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $j=1,$ArrayOL[1000]
Local $controllsource
$Form1 = GUICreate("Add Link Here", 394, 247, 156, 156)
$Link = GUICtrlCreateEdit("", 0, 0, 393, 201)
$Clear = GUICtrlCreateButton("Clear", 120, 208, 75, 33, $WS_GROUP)
$Check = GUICtrlCreateButton("Check Now!", 216, 208, 75, 33, $WS_GROUP)
$Exitnow = GUICtrlCreateButton("Exit Now", 312, 208, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Clear
            GUICtrlSetData($Link, "")
        Case $Check
            Linkcheck (GUICtrlRead ($Link))
        Case $Exitnow
            Exit
    EndSwitch
WEnd


Func Linkcheck ($sLinks)
$_1 = GUICreate("Link Checker", 461, 294, 184, 156)
$List = GUICtrlCreateListView("Link|Title|State", 0, 0, 458, 246, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 220)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84)
$Add = GUICtrlCreateButton("Add To List", 8, 256, 91, 33, $WS_GROUP)
$Select = GUICtrlCreateButton("Select All", 120, 256, 91, 33, $WS_GROUP)
$Deselect = GUICtrlCreateButton("Deselect All", 232, 256, 91, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 352, 256, 91, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
$aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF)
For $i = 1 To $aLinks[0]
Dim $listitem[$aLinks[0] + 1]
$sourcecontroll = _INetGetSource ($aLinks[$i])
If StringInStr ($sourcecontroll,"Enter this") Then
    $Sourcetitle =_INetGetSource ("http://www.xxxxxxx.com.php?url=" & $aLinks[$i])
    $Onlinetitle = StringTrimLeft($Sourcetitle,StringInStr($Sourcetitle,'/',0,-1))
    $listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & $Onlinetitle & "|" & "Online",$List)
    GUICtrlSetState($listitem[$i], $GUI_CHECKED)
EndIf
If Not StringInStr ($sourcecontroll,"Enter this") Then
    $listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & "//" & "|" & "Offline",$List) 
    GUICtrlSetState($listitem[$i],$GUI_nofocus);this don't work
EndIf
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Add
        For $i = 1 To $aLinks[0]
            If _GUICtrlListView_GetItemChecked($list,$i-1)=1 
            $ArrayOL[$j]=$aLinks[$i]
            $j=$j+1
            EndIf
        Next
        _ArrayDisplay($ArrayOL)
    Case $Select
        For $x = 1 To $aLinks[0]
        _GUICtrlListView_SetItemChecked($List,-1)
    Next
    Case $Deselect
        For $y = 1 To $aLinks[0]
        _GUICtrlListView_SetItemChecked($List,-1,False)
    Next
        Case $Exit
        Exit
        EndSwitch
        WEnd
EndFunc

Posted Image

I would to disable the check box of offline link :D... How to do this?

Thank's !

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites



your checkboxes dont have their own ID, only your list have a ID.

so you can't disable offline-list-entries.

easiest solution would be to don't list offline-links.

Share this post


Link to post
Share on other sites

The way I have done somethng similar is I have used an image list. You would need images for a checked box, an unchecked box and a disabled box. Then you can set the image as required.

Look up

_GUICtrlListView_SetImageList

_GUICtrlListView_SetItemStateImage


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@martin

If a set an image all checkbox are disable :D...autoit don't include any function for my question?

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

maybe this is a solution for you:

Posted Image

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <INet.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $j=1,$ArrayOL[1000]
Local $controllsource
$Form1 = GUICreate("Add Link Here", 394, 247, 156, 156)
$Link = GUICtrlCreateEdit("", 0, 0, 393, 201)
$Clear = GUICtrlCreateButton("Clear", 120, 208, 75, 33, $WS_GROUP)
$Check = GUICtrlCreateButton("Check Now!", 216, 208, 75, 33, $WS_GROUP)
$Exitnow = GUICtrlCreateButton("Exit Now", 312, 208, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Clear
            GUICtrlSetData($Link, "")
        Case $Check
            Linkcheck (GUICtrlRead ($Link))
        Case $Exitnow
            Exit
    EndSwitch
WEnd


Func Linkcheck ($sLinks)
$_1 = GUICreate("Link Checker", 461, 294, 184, 156)
$List = GUICtrlCreateListView("Link|Title|State", 0, 0, 458, 20, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 220)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84)
$Add = GUICtrlCreateButton("Add To List", 8, 256, 91, 33, $WS_GROUP)
$Select = GUICtrlCreateButton("Select All", 120, 256, 91, 33, $WS_GROUP)
$Deselect = GUICtrlCreateButton("Deselect All", 232, 256, 91, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 352, 256, 91, 33, $WS_GROUP)
$gui3 = 0
GUISetState(@SW_SHOW)
$aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF)
For $i = 1 To $aLinks[0]
Dim $listitem[$aLinks[0] + 1]
$sourcecontroll = _INetGetSource ($aLinks[$i])
;msgbox (16,"",$sourcecontroll)
If StringInStr ($sourcecontroll,"html") Then
    $Sourcetitle =_INetGetSource ("http://www.xxxxxxx.com.php?url=" & $aLinks[$i])
    $Onlinetitle = StringTrimLeft($Sourcetitle,StringInStr($Sourcetitle,'/',0,-1))
    ;$listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & $Onlinetitle & "|" & "Online",$List)
    ;GUICtrlSetState($listitem[$i], $GUI_CHECKED)
    $gui3 = $gui3 + 25
    GUICtrlCreateCheckbox ($aLinks[$i], 10, $gui3, 300, 20) ;16
    GUICtrlSetState ( -1, $GUI_CHECKED )
EndIf
If Not StringInStr ($sourcecontroll,"html") Then
    ;$listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & "//" & "|" & "Offline",$List) 
    ;GUICtrlSetState($listitem[$i],$GUI_nofocus);this don't work
    $gui3 = $gui3 + 25
    GUICtrlCreateCheckbox ($aLinks[$i], 10, $gui3, 300, 20) ;16
    GUICtrlSetState ( -1, $GUI_UNCHECKED + $GUI_DISABLE)
EndIf
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Add
        For $i = 1 To $aLinks[0]
            If _GUICtrlListView_GetItemChecked($list,$i-1)=1 then
            $ArrayOL[$j]=$aLinks[$i]
            $j=$j+1
            EndIf
        Next
        _ArrayDisplay($ArrayOL)
    Case $Select
        For $x = 1 To $aLinks[0]
        _GUICtrlListView_SetItemChecked($List,-1)
    Next
    Case $Deselect
        For $y = 1 To $aLinks[0]
        _GUICtrlListView_SetItemChecked($List,-1,False)
    Next
        Case $Exit
        Exit
        EndSwitch
        WEnd
EndFunc
Edited by andygo

Share this post


Link to post
Share on other sites

@andygo

With your script, the listview don't show me the title of file and the status.Also this code checked all check box whether online or offline.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@martin

If a set an image all checkbox are disable :D...autoit don't include any function for my question?

What I meant was that you can use an icon instead of a checkbox, not as well. The user will see them as checkboxes if you set them correctly.

Here is a screen shot example of what I did, with the checkboxes either ticked, not ticked or no checkbox if the option isn't available.

post-3602-12521582912617_thumb.png

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

try it again:

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <INet.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $j=1,$ArrayOL[1000]
Local $controllsource
$Form1 = GUICreate("Add Link Here", 394, 247, 156, 156)
$Link = GUICtrlCreateEdit("", 0, 0, 393, 201)
$Clear = GUICtrlCreateButton("Clear", 120, 208, 75, 33, $WS_GROUP)
$Check = GUICtrlCreateButton("Check Now!", 216, 208, 75, 33, $WS_GROUP)
$Exitnow = GUICtrlCreateButton("Exit Now", 312, 208, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Clear
            GUICtrlSetData($Link, "")
        Case $Check
            Linkcheck (GUICtrlRead ($Link))
        Case $Exitnow
            Exit
    EndSwitch
WEnd


Func Linkcheck ($sLinks)
$_1 = GUICreate("Link Checker", 461, 294, 184, 156)
$List = GUICtrlCreateListView("Link|Title|State", 0, 0, 458, 20, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 220)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 84)
$Add = GUICtrlCreateButton("Add To List", 8, 256, 91, 33, $WS_GROUP)
$Select = GUICtrlCreateButton("Select All", 120, 256, 91, 33, $WS_GROUP)
$Deselect = GUICtrlCreateButton("Deselect All", 232, 256, 91, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 352, 256, 91, 33, $WS_GROUP)
$gui3 = 0
GUISetState(@SW_SHOW)
$aLinks = StringSplit(StringReplace($sLinks, @CR, ""), @LF)
For $i = 1 To $aLinks[0]
Dim $listitem[$aLinks[0] + 1]
$sourcecontroll = _INetGetSource ($aLinks[$i])
;msgbox (16,"",$sourcecontroll)
If StringInStr ($sourcecontroll,"html") Then
    $Sourcetitle =_INetGetSource ("http://www.xxxxxxx.com.php?url=" & $aLinks[$i])
    $Onlinetitle = StringTrimLeft($Sourcetitle,StringInStr($Sourcetitle,'/',0,-1))
    ;$listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & $Onlinetitle & "|" & "Online",$List)
    ;GUICtrlSetState($listitem[$i], $GUI_CHECKED)
    $gui3 = $gui3 + 25
    GUICtrlCreateCheckbox ($aLinks[$i] & "            " & $Onlinetitle & "            " & "Online", 10, $gui3, 300, 20) ;16
    GUICtrlSetState ( -1, $GUI_CHECKED )
EndIf
If Not StringInStr ($sourcecontroll,"html") Then
    ;$listitem[$i] = GUICtrlCreateListViewItem ($aLinks[$i] & "|" & "//" & "|" & "Offline",$List) 
    ;GUICtrlSetState($listitem[$i],$GUI_nofocus);this don't work
    $gui3 = $gui3 + 25
    GUICtrlCreateCheckbox ($aLinks[$i] & "            " & "//" & "            " & "Offline", 10, $gui3, 300, 20) ;16
    GUICtrlSetState ( -1, $GUI_UNCHECKED + $GUI_DISABLE)
EndIf
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Add
        For $i = 1 To $aLinks[0]
            If GUICtrlRead ($i + 11) = 1 then
            $ArrayOL[$j]=$aLinks[$i]
            $j=$j+1
            EndIf
        Next
        _ArrayDisplay($ArrayOL)
    Case $Select
        For $x = 12 To 11 + $aLinks[0]
        if guictrlgetstate ($x) = 80 then GUICtrlSetState ( $x, $GUI_CHECKED)
    Next
    Case $Deselect
        For $y = 12 To 11 + $aLinks[0]
       GUICtrlSetState ( $y, $GUI_UNCHECKED)
    Next
        Case $Exit
        Exit
        EndSwitch
        WEnd
EndFunc

Share this post


Link to post
Share on other sites

@andygo

Your code not work again, it checked all check box whether online or offline.Also it show me a "cut link" for esample the file name is : "tryitagain" but it show me "tryitag"...and don't show me the file status (online/offline).

Share this post


Link to post
Share on other sites

i run windows7, here the script works. sry if i couldnt help you

the "cut link" could be if the checkbox-label is too short:

Posted Image

try a higher value.

Share this post


Link to post
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
Sign in to follow this  
Followers 0