Sign in to follow this  
Followers 0
aymhenry

Load Custum icons to Toolbar

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

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:

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  
Followers 0