DWT Forms Icons

Frank Benoit keinfarbton at googlemail.com
Sun Sep 7 17:11:53 PDT 2008

Tim M schrieb:
> Hi I decided to port one of my programs from dfl to dwt and haven't
> yet been liking it one bit. My program went from 339K to 2.81M, the
> code is much more complex, at lot more imports and takes longer to
> compile its taken me a long time and a lot of confusion and I still
> don't see the point of listeners when in dfl all i have to do is:
> myButton.click ~= &generateKey; It seems like a step backwards or
> wrong direction for me and I spent nearly a whole day trying to get
> my icon display.

I think its worth that.
What you get with DWT is cross plattform and a fast growing code base.
That would not be possible if those functionality would be implemented
by that few people. Porting is a much easier task.

Instead of implementing listener classes you can use the dgListener
template function.
myButton.addListener(DWT.Selection, dgListener( (Event e){ /+ ... +/ });

In comparison to a direct delegate the dgLister has the advantage that
it can be curried with additional arguments.

myButton.addListener(DWT.Selection, dgListener( (Event e, MyType myval
){ /+ ... +/ }, val);

'val' is now stored in the internal generated Listener class and passed
to the delegate as the myval argument.

> Anyway I compile the program and link it with the resource and the
> icon is visible on the taskbar but i couldn't get it to display in
> the top left corner of the app. I've tried a lot and I think it has
> something to do with dwtx.jface.resources but i couldn't figure it
> out. Please help.

With resource you mean a windows resource?
DWT does not make use of that resources. The Java original does not
compile to exe files, so there are no linked resources.
To set the window icon see Shell.setImage(s)

For more help, please post a reduced simple compilable example code
(perhaps screenshot) that demonstrates the problem.

More information about the Digitalmars-d-dwt mailing list