Loading icons on windows with icon index

How do you load icons on windows in wxRuby? I know in wxWidgets you use
wxIconLocation, but as far as I can see, it is not included in wxRuby.
Any ideas?

Thanks.

Do you mean to load icon to top-left of a window?
every window should have set_icon method to do that

Regards
Hendra

On 27/04/2010 12:38, John B. wrote:

How do you load icons on windows in wxRuby? I know in wxWidgets you use
wxIconLocation, but as far as I can see, it is not included in wxRuby.
Any ideas?

You can load an external icon from a file simple with
Wx::Icon.new(filepath,…)

If you have a Windows icon file containing multiple icons, you should be
able to use Wx::IconBundle.new(filepath,…), then the method
get_icon(i) to access individual icons by index.

hth
alex

Will that load all the icons from the file? It would be better to be
able to just load one. I will be loading the icons from various system
dlls so it wouldn’t make sense to load all of them.

Alex F. wrote:

On 27/04/2010 12:38, John B. wrote:

How do you load icons on windows in wxRuby? I know in wxWidgets you use
wxIconLocation, but as far as I can see, it is not included in wxRuby.
Any ideas?

You can load an external icon from a file simple with
Wx::Icon.new(filepath,…)

If you have a Windows icon file containing multiple icons, you should be
able to use Wx::IconBundle.new(filepath,…), then the method
get_icon(i) to access individual icons by index.

hth
alex

If you wish to load just one Icon, create a method like this:

def load_windows_icon(dll_file,icon_number)
ib = Wx::IconBundle.new(dll_file)
ib.get_icon(icon_number)
end

This will return a Wx::Icon, and the ib will be put on the garbage heap
for
release at the next run of the Garbage Collector. There is no slowing
down
between loading a single icon, and loading multiple Icons through
IconBundle, as wxWidgets will utilize Win32API first, and foremost, for
most
GUI Operations. In the case of IconBundles, it will read the Icon
Header,
be it .ico, .dll, or .exe, and it will parse the most important
information
needed to create the IconBundle class. The actual extraction, and
creation
of the Icon is deferred to when you use the get_icon method on the
IconBundle class. An Icon Resource could have a hundred icons in it,
and it
will not slow down the reading of the data.

hth,

Mario

Alex F. wrote:

If you have a Windows icon file containing multiple icons, you should be
able to use Wx::IconBundle.new(filepath,…), then the method
get_icon(i) to access individual icons by index.

I apologize for asking here what I could discover on my own, but I get
impatient about some things and I won’t have access to a Mac till the
weekend. :slight_smile:

If I have a Windows icon file with multiple icons, will the Mac use
those icons too?

Alternatively, if I were to have a Mac icns file, does it work the same
way you describe when on the Mac (instead of Windows)? And will Windows
be able to access the individual icons in that file or are they
inaccessible to it?

From the suggestion I’ve seen more than once to use .png for icons to
simplify different platform use, I’m guessing these questions will be
answered in the negative. Is the preferred method to use Wx::SetIcons
with various sized png’s if you don’t know on what platform your app
will be used?

Thanks!

Roger S

rsperberg at gmail

OK, thanks. That’s good to know.

Hello Roger,

On Thu, Apr 29, 2010 at 11:54 AM, Roger S.
[email protected]wrote:

I apologize for asking here what I could discover on my own, but I get
impatient about some things and I won’t have access to a Mac till the
weekend. :slight_smile:

Not a problem, we get quite a few questions on here, that people can’t
find
in documentation.

If I have a Windows icon file with multiple icons, will the Mac use
those icons too?

I believe that wxWidgets needs a library in order to load Widows Icon
files
on any other system other then Windows itself.

Alternatively, if I were to have a Mac icns file, does it work the same
way you describe when on the Mac (instead of Windows)? And will Windows
be able to access the individual icons in that file or are they
inaccessible to it?

Mac OS X uses png’s, like Linux does. If you ever look in a .app bundle
folder, you will often find icons are in png.

From the suggestion I’ve seen more than once to use .png for icons to
simplify different platform use, I’m guessing these questions will be
answered in the negative. Is the preferred method to use Wx::SetIcons
with various sized png’s if you don’t know on what platform your app
will be used?

It is best to use PNG’s for icons, simply for the fact that wxWidgets
can
load PNG’s correctly on all 3 platforms. And you will find that if you
load
with Wx::Bitmap, or Wx::Image, you can convert it to an Icon, through
Wx::Icon, which will allow the icon to be created in native format, to
be
used on the platform in question. And infact, any PNG, GIF, JPEG, etc,
etc,
can be converted to a Icon, and used where ever Wx::Icon is required.

Thanks!