Jump to content

Scrollable checkboxes


this-is-me
 Share

Recommended Posts

Sorry if this has been asked before. I know others have tried, but is there a way to have a dynamically loaded list of checkboxes that can scroll. What I want to do is present the user with a list of files in a directory and heve them uncheck the ones they don't need. Those unchecked items will be deleted. Is this possible?

Who else would I be?
Link to comment
Share on other sites

An example:

Global $TVS_CHECKBOXES = 0x100

GuiCreate("Example")

$tv = GuiCtrlCreateTreeView(10, 10, 200, 200, $TVS_CHECKBOXES)
GUICtrlCreateTreeViewItem("one", $tv)
GUICtrlCreateTreeViewItem("two", $tv)
GUICtrlCreateTreeViewItem("three", $tv)

GuiSetState()
While GuiGetMsg() <> -3
Wend
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Thanks a lot, but two silly questions here... How do I set the state of a treeview item to hidden (or delete it), and does the treeview item only fire an event if it is checked, but not when it is unchecked?

Who else would I be?
Link to comment
Share on other sites

Hope this helps:

GuiCreate("Example")
$tv = GuiCtrlCreateTreeView(10, 10, 200, 200, 0x100);$TVS_CHECKBOXES
Dim $box[11]
For $i = 1 to 10
   $box[$i] = GUICtrlCreateTreeViewItem("item_" & $i, $tv)
Next

GuiCtrlDelete($box[2])
GuiCtrlDelete($box[4])

GuiSetState()
While 1
   $msg = GuiGetMsg()
   If $msg = -3 Then ExitLoop
   If $msg >= $box[1] and $msg <= $box[9] Then
      ToolTip("Click Detected " & $msg-3);minus 3 due to offset because 1 <> $box[1]
      sleep(500)
      ToolTip('')
   EndIf
Wend

$t = ""
For $i = 1 to 10
   If GuiRead($box[$i]) = 1 Then $t = $t & " " & $i
 ;FYI, if an item had been deleted, GuiRead returns 1243832
Next
MsgBox(4096, "Info", "The following items are checked: " & $t)
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • 2 months later...

Cyberslug,

Very interesting example!

But can you tell me why $t does not contain the last checked checkbox when I close the window? Is it a bug?

Kind regards,

Arno Rog

Hope this helps:

GuiCreate("Example")
$tv = GuiCtrlCreateTreeView(10, 10, 200, 200, 0x100);$TVS_CHECKBOXES
Dim $box[11]
For $i = 1 to 10
   $box[$i] = GUICtrlCreateTreeViewItem("item_" & $i, $tv)
Next

GuiCtrlDelete($box[2])
GuiCtrlDelete($box[4])

GuiSetState()
While 1
   $msg = GuiGetMsg()
   If $msg = -3 Then ExitLoop
   If $msg >= $box[1] and $msg <= $box[9] Then
      ToolTip("Click Detected " & $msg-3);minus 3 due to offset because 1 <> $box[1]
      sleep(500)
      ToolTip('')
   EndIf
Wend

$t = ""
For $i = 1 to 10
   If GuiRead($box[$i]) = 1 Then $t = $t & " " & $i
;FYI, if an item had been deleted, GuiRead returns 1243832
Next
MsgBox(4096, "Info", "The following items are checked: " & $t)

<{POST_SNAPBACK}>

Link to comment
Share on other sites

@awrog: only a scripting bug :D

Please replace the line:

If GuiRead($box[$i]) = 1 Then $t = $t & " " & $i

with this:

If BitAnd(GuiCtrlRead($box[$i]),1) Then $t = $t & " " & $i

This is because of the latest item you have clicked -> this is then in 'selected' state -> and so GUICtrlRead returns 1 + 256 (GUI_CHECKED + GUI_FOCUS).

Also in the new beta version the GUIRead ist replaced by GUICtrlRead.

So long... :idiot:

Edited by Holger
Link to comment
Share on other sites

Holger,

I dont know how you guys (guis :D )do it , but it works.

Compliments about this support-forum, it surpasses everything I know!

Arno Rog

@awrog: only a scripting bug :lol:

Please replace the line:

If GuiRead($box[$i]) = 1 Then $t = $t & " " & $i

with this:

If BitAnd(GuiCtrlRead($box[$i]),1) Then $t = $t & " " & $i

This is because of the latest item you have clicked -> this is then in 'selected' state -> and so GUICtrlRead returns 1 + 256 (GUI_CHECKED + GUI_FOCUS).

Also in the new beta version the GUIRead ist replaced by GUICtrlRead.

So long... :idiot:

<{POST_SNAPBACK}>

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