Jump to content

Load Custum icons to Toolbar


aymhenry
 Share

Recommended Posts

I’ve made a lot of trails to load custom icons to toolbar.My aim is to include the icons in the same exe file.

The result is blank square in icon place

Here is the code:-

#AutoIt3Wrapper_Res_Icon_Add=ICO_00.ICO
#AutoIt3Wrapper_Res_Icon_Add=ICO_01.ICO

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiToolBar.au3>
 

Opt('MustDeclareVars', 1)
_Main()

Func _Main()
    Global Enum $idNew = 1000, $idOpen


    Local $hGUI, $hToolbar, $hNormal
    Local $hGUI = GUICreate("Toolbar", 400, 300)
    Local $hToolbar = _GUICtrlToolbar_Create($hGUI)


    _GUICtrlToolbar_AddBitmap($hGUI, 1, @ScriptFullPath, -5)

    _GUICtrlToolbar_AddButton($hToolbar, $idNew, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idOpen, 1)
    
    GUISetState()
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

Any idea for help

Edited by aymhenry
Link to comment
Share on other sites

Off the top of my head I would use an image list...

himglist = _GUIImageList_Create

i = _GUIImageList_AddIcon (you can use @ScriptFullPath for this)

... Add all the icons to the image list

_GUICtrlToolbar_SetImageList

_GUICtrlToolbar_AddButton (i is the image index)

... Add all the buttons

Of course, the right way to do it is have a bitmap strip, and have a mask as well (or make sure you have a good background colour so you can make that transparent).

I remember looking at this a while ago, so I'll have to dig up some old code for you :graduated: One thing that I do recommend is having a way that works both uncompiled and compiled. Usually that means using a dummy exe or dll with the resources (I have an empty template dll that I re use, adding the resources using reshacker). That way you won't have to go through the job of compiling just to test.

Mat

Edit: Just to make doubly sure... You do know a strip is the best way to go about this, try using reshacker on Wordpad for an example (usually in C:\Program Files\Windows NT\Accessories\Wordpad).

Edited by Mat
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...