Jump to content
Sign in to follow this  

Load Custum icons to Toolbar

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


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

Opt('MustDeclareVars', 1)

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)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

Any idea for help

Edited by aymhenry

Share this post

Link to post
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_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.


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

Share this post

Link to post
Share on other sites

Thank you for your support.

I've read your idea, the problem is solved.

The question now, why   _GUICtrlToolbar_AddBitmap is not working?

Is it a bug?

Share this post

Link to post
Share on other sites

I assume an icon not being a bitmap is the problem... I think there are ways to convert between the two, but I'm not the person to ask about that.

Glad to hear it's solved though :graduated:

Yes, there are ways to convert between the two

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...