From: Pierre Baillet Date: 2003-01-07T08:05:19+09:00 Subject: Re: [BUG][FOX] iconlist and multiple icon usage Hello again, I worked like a charm, thanks a lot for your help, Lyle ! On Tue, Jan 07, 2003, Lyle Johnson wrote: > > The problem is that you're trying to use an icon before its server-side > representation has been created. For more information about this issue, > see this entry from the FOX FAQ: > > http://www.fox-toolkit.org/faq.html#ILLEGALICON > > The quick fix for your program is to just add the line: > > icon.create > > immediately after the line in Foo#redraw_list that instantiates the new > FXPNGIcon, i.e. > > def redraw_list > @iconlist.clearItems > # display empty boxes > icon = FXPNGIcon.new(getApp(), @@folder_data) > icon.create > (1..3).each{ |f| > item = FXIconItem.new(f.to_s, icon ) > @iconlist.appendItem(item) > } > end > > >Apart from reinstancing an icon every time, is there a solution to have > >icons used more than once on with FOX? > > As a matter of fact you only need *one* copy of this icon object, and > can share it amongst all of the list items. If I were to modify your > example program, it would look like this: > > class Foo < FXMainWindow > [ ...>8... snip ...8<... ] > > Apart from moving the app-related stuff out of your main window class, > the important thing to note is that there is only *one* icon object > (@folder_icon) that is shared by all of the list items. It gets created > when the main window (Foo) object is created (see Foo#create). > -- Pierre Baillet Il faut pomper pour vivre et donc vivre pour pomper. Devise Shadok