wxLua: problem with icon from ressource file

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Jan 23, 2014 1:11 am

wxLua: problem with icon from ressource file

Postby antiker » Mon Oct 26, 2015 4:03 pm


Environment: wxLua on Windows 7 x64 system

Description: I use a '.dll' resource file for my icons. The '.o' object file for this resource was created with windres with the following icons:

Code: Select all

1 ICON DISCARDABLE "icon_16x16.ico"
2 ICON DISCARDABLE "icon_32x32.ico"
3 ICON DISCARDABLE "icon_48x48.ico"
4 ICON DISCARDABLE "icon_64x64.ico"
5 ICON DISCARDABLE "icon_96x96.ico"

This object file was finally builded to a '.dll' with g++

And here is my problem:

Lua code:

Code: Select all

-- file path
file_icons = CLIB_PATH .. "icons.dll"

-- icons
ico_16 = wx.wxIcon( file_icons .. ";0", wx.wxBITMAP_TYPE_ICO, 16, 16 )
ico_32 = wx.wxIcon( file_icons .. ";1", wx.wxBITMAP_TYPE_ICO, 32, 32 )
ico_48 = wx.wxIcon( file_icons .. ";2", wx.wxBITMAP_TYPE_ICO, 48, 48 )
ico_64 = wx.wxIcon( file_icons .. ";3", wx.wxBITMAP_TYPE_ICO, 64, 64 )
ico_96 = wx.wxIcon( file_icons .. ";4", wx.wxBITMAP_TYPE_ICO, 96, 96 )

-- test 1: display icon with 32x32
bmp_32 = wx.wxBitmap()
bmp_32:CopyFromIcon( ico_32 )
X, Y = bmp_32:GetWidth(), bmp_32:GetHeight()
control = wx.wxStaticBitmap( panel, wx.wxID_ANY, wx.wxBitmap( bmp_32 ), wx.wxPoint( 20, 10 ), wx.wxSize( X, Y ) )

--> RESULT: the icon with 32x32 is displayed without problems

-- test 2: display icon with 64x64
bmp_64 = wx.wxBitmap()
bmp_64:CopyFromIcon( ico_64 )
X, Y = bmp_64:GetWidth(), bmp_64:GetHeight()
control = wx.wxStaticBitmap( panel, wx.wxID_ANY, wx.wxBitmap( bmp_64 ), wx.wxPoint( 20, 50 ), wx.wxSize( X, Y ) )

--> RESULT: no icon, the panel will remain empty, nothing to see but no interpreter errors so far

In the official specs for wxIcon i can't find anything about a 32x32 limitation. So why will the 64x64 icon not displayed? Is there an alternative method to display a larger icon with 64x64 from my ressource file on my wxPanel?

Part Of The Furniture
Part Of The Furniture
Posts: 1548
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxLua: problem with icon from ressource file

Postby PB » Mon Oct 26, 2015 4:46 pm

Disclaimer: I know nothing about Lua or wxLua.

I admit I also don't remember much about loading icons by index as I usually use wxICON() macro, but I guess that part (0 vs 1 based index in DLL vs code) is OK. I would still try using wxBITMAP_TYPE_ICO_RESOURCE if the source file is .DLL and not .ICO but it looks as it works for you.

Anyway, for starters, I recommend checking ico_64:IsOK() after loading the icon from the resource and bmp_64:IsOk() after bmp_64:CopyFromIcon() to see if the icon and bitmap are OK. If they are I would check if the sizes they return and you pass to wxStaticBitmap are what you expect.

Return to “General Development”

Who is online

Users browsing this forum: No registered users and 5 guests