Jump to content

List View Help


dantay9
 Share

Recommended Posts

I am making a internet filter as an upgrade to the one currently installed with windows and as a learning experience. I have most of the script working fine, but I can't get the list view to work correctly. I am having trouble with deleting an item. I tried to used the _GUICtrlListView_DeleteItemsSelected function to delete the highlighted item, but it isn't working.

$Internet_Properties = GUICreate("Internet Properties", 417, 310)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(10, 10, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

$ContentAdvisor_Tab = GUICtrlCreateTabItem("Content Advisor")
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlCreateLabel('Click "Enable" to enable the internet blocker.', 90, 75, 245, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlCreateIcon("C:\Documents and Settings\Owner\Desktop\WorldStar.ico", 0, 45, 73, 32, 32)
$Title[1] = GUICtrlCreateLabel("Content Advisor", 36, 49, 95, 20)
$Line[1] = GUICtrlCreateLabel("", 135, 57, 252, 1)
$ContentAdvisor_Enable = GUICtrlCreateButton("&Enable", 36, 117, 110, 23)
$ContentAdvisor_Settings = GUICtrlCreateButton("&Settings", 153, 117, 110, 23)
$ContentAdvisor_Sleep_Button = GUICtrlCreateButton("&Sleep Mode", 270, 117, 110, 23)
GUICtrlCreateLabel('Click "Settings" to alter the internal settings.', 90, 91, 272, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")

$ApprovedSites_Tab = GUICtrlCreateTabItem("Approved Sites")
$Title[2] = GUICtrlCreateLabel("Approved Sites", 36, 49, 91, 20)
$Line[2] = GUICtrlCreateLabel("", 130, 57, 257, 1)
GUICtrlCreateLabel('Approved Sites allow the user to access only the sites listed below while the blocker is active. To remove a site from the list, place a check by the site to be removed and click "Remove".', 36, 69, 352, 52)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$ApprovedSites_Input = GUICtrlCreateInput("", 36, 121, 150, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ApprovedSites_AddSite_Button = GUICtrlCreateButton("Add Site", 305, 121, 75, 23)
$ApprovedSites_RemoveSite_Button = GUICtrlCreateButton("Remove Site", 208, 121, 75, 23)
$ApprovedSites_ListView = GUICtrlCreateListView("", 36, 151, 344, 89)
_GUICtrlListView_AddColumn($ApprovedSites_ListView, "Approved Sites", 340, 2)

$BlockedSites_Tab = GUICtrlCreateTabItem("Blocked Sites")
$Line[3] = GUICtrlCreateLabel("", 122, 57, 265, 1)
$Title[3] = GUICtrlCreateLabel("Blocked Sites", 36, 49, 85, 20)
GUICtrlCreateLabel('Blocked sites are always active, even when the advisor is disabled. To allow these sites to be visited, change the settings to sleep mode.', 36, 69, 352, 52)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$BlockedSites_Input = GUICtrlCreateInput("", 36, 121, 150, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$BlockedSites_ListView = GUICtrlCreateListView("", 36, 151, 344, 89)
_GUICtrlListView_AddColumn($BlockedSites_ListView, "Blocked Sites", 340, 2)
$BlockedSites_RemoveSite_Button = GUICtrlCreateButton("Remove Site", 208, 121, 75, 23)
$BlockedSites_AddSite_Button = GUICtrlCreateButton("Add Site", 305, 121, 75, 23)

GUICtrlCreateTabItem("")
$OK_Button = GUICtrlCreateButton("&OK", 88, 276, 75, 23)
$Cancel_Button = GUICtrlCreateButton("&Cancel", 252, 276, 75, 23)

How can I get the highlighted item in the list and then delete it when the remove site button is pressed?

Link to comment
Share on other sites

Get the index to the selected item, then pass it to DeleteItemsSelected.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

As per the help file, once an item is selected pass the list view down.

I assume you create the list view correctly and it displays - Select an item in $ApprovedSites_ListView then do _GUICtrlListView_DeleteItemsSelected($ApprovedSites_ListView)).

Be sure to look at the return value and make sure $ApprovedSites_ListView has something selected. Same goes for $BlockedSites_ListView.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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...