Sign in to follow this  
Followers 0
GioVit

How add Images in GuiCtrlCreateTreeViewItem

7 posts in this topic

Sorry for the question but...

I created 2 icons 16 x 16 pixels that represent the state of each TreeViewItem (Selected Unselected) but they are not visibles when I run the script.

Do I have to change the icons size? or

Is there a special "style" I have to set in GUICtrlCreateTreeView?

Share this post


Link to post
Share on other sites



without the script and image files all i can say is look at GUICtrlSetImage in the help


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

without the script and image files all i can say is look at GUICtrlSetImage in the help

#include <GUIConstants.au3>
; == GUI generated with Koda ==

### Koda GUI section start ###
$Form1 = GUICreate("Tutoral", 404, 371, 193, 126)
GUISetBkColor(0x0000FF)
$TreeView1 = GUICtrlCreateTreeView(4, 4, 153, 357, -1, 0)
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_0 = GUICtrlCreateTreeViewItem("Application", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Workbook", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_2 = GUICtrlCreateTreeViewItem("WorkSheet", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_3 = GUICtrlCreateTreeViewItem("Range", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_4 = GUICtrlCreateTreeViewItem("RowColRange", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Cell", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Properties", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_7 = GUICtrlCreateTreeViewItem("PrintSetup", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Selection", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, "sel.ico", -1, 2)
GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$Edit1 = GUICtrlCreateEdit("", 164, 4, 233, 309)
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("&Continue", 172, 328, 105, 33, 0)
$Button2 = GUICtrlCreateButton("&Exit", 292, 328, 105, 33, 0)
GUISetState(@SW_SHOW)
### Koda GUI section end   ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Sorry Gary here is the code and the icons, need to be in the same Folder

sel.ico

unsel.ico

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
; == GUI generated with Koda ==

### Koda GUI section start ###
$Form1 = GUICreate("Tutoral", 404, 371, 193, 126)
GUISetBkColor(0x0000FF)
$TreeView1 = GUICtrlCreateTreeView(4, 4, 153, 357, -1, 0)
GUICtrlSetBkColor(-1, 0x0000FF)
;~ GUICtrlSetImage(-1, "sel.ico", -1, 2)
;~ GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_0 = GUICtrlCreateTreeViewItem("Application", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
;~ GUICtrlSetImage(-1, "unsel.ico", -1, 4)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Workbook", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_2 = GUICtrlCreateTreeViewItem("WorkSheet", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_3 = GUICtrlCreateTreeViewItem("Range", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_4 = GUICtrlCreateTreeViewItem("RowColRange", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_5 = GUICtrlCreateTreeViewItem("Cell", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_6 = GUICtrlCreateTreeViewItem("Properties", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_7 = GUICtrlCreateTreeViewItem("PrintSetup", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$TreeView1_8 = GUICtrlCreateTreeViewItem("Selection", $TreeView1)
GUICtrlSetColor(-1, 0xFFFF00)
;~ GUICtrlSetImage(-1, @ScriptDir & "\sel.ico")
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico")
$Edit1 = GUICtrlCreateEdit("", 164, 4, 233, 309)
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("&Continue", 172, 328, 105, 33, 0)
$Button2 = GUICtrlCreateButton("&Exit", 292, 328, 105, 33, 0)
GUISetState(@SW_SHOW)
### Koda GUI section end   ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you Gafrost,

But...

This also means that I have to change the Icons every time I move to a new TreeViewItem, because it only can show (or have) one icon at time

and my opinion is that there is an inconsitency in Help File for the GUICtrlSetImage function in the "possible values" of "icontype parameter". Because has two options for TreeViewItem (2 and 4) and it has no sense if each item in tree can't update each other automatically.

By the way I Think it can be solved with GUIRegisterMsg, but how you determine the last TreeItem Selected in order to reset its icon to Unsel.ico?

Share this post


Link to post
Share on other sites

Short.

#include <GUIConstants.au3>
; == GUI generated with Koda ==


$Form1 = GUICreate("Tutoral", 404, 371, 193, 126)
GUISetBkColor(0x0000FF)
$TreeView1 = GUICtrlCreateTreeView(4, 4, 153, 357, -1, 0)
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetImage(-1, @ScriptDir & "\sel.ico", 0, 2)
GUICtrlSetImage(-1, @ScriptDir & "\unsel.ico", 0, 4)
GUICtrlSetColor(-1, 0xFFFF00)
$TreeView1_0 = GUICtrlCreateTreeViewItem("Application", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Workbook", $TreeView1)
$TreeView1_2 = GUICtrlCreateTreeViewItem("WorkSheet", $TreeView1)
$TreeView1_3 = GUICtrlCreateTreeViewItem("Range", $TreeView1)
$TreeView1_4 = GUICtrlCreateTreeViewItem("RowColRange", $TreeView1)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Cell", $TreeView1)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Properties", $TreeView1)
$TreeView1_7 = GUICtrlCreateTreeViewItem("PrintSetup", $TreeView1)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Selection", $TreeView1)

$Edit1 = GUICtrlCreateEdit("", 164, 4, 233, 309)
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("&Continue", 172, 328, 105, 33, 0)
$Button2 = GUICtrlCreateButton("&Exit", 292, 328, 105, 33, 0)
GUISetState(@SW_SHOW)
Sleep(2000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

many many thanks

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