September 26, 2022, 06:51:25 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


icon handle

Started by ExMember001, August 21, 2006, 02:47:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

Which Method or Function give the handle for Cwindow Seticon?

ExMember001

Found it..

Cimage img;
hicon = img.LoadFromFile(path);

kryton9

I'd like to your see code when you have it finished, will be using this to study. What do you do with hicon?

ExMember001

August 22, 2006, 01:52:07 AM #3 Last Edit: August 22, 2006, 02:00:52 AM by krypt
hicon contain the handle to an .ico file (can be other image format too)
you can do lots of thing with that.
what i've done with it is simply add the icon to the window caption of my program
use seticon(hicon); after calling the above to set to the caption

little quick example:

in your sub main() after creating the window or in OnInitDialog() for a dialog

Mywindow win;
Cimage img;
string path;
int hicon;
path = "...\\path to the file";
hicon = img.LoadFromFile(path);
win.seticon(hicon);

kryton9

I see, ok cool, thanks will be neat to play with too!!

Ionic Wind Support Team

Use CIcon instead.

CIcon i;
i.LoadFromFile(path);
win.SetIcon(i.Detach());

Ionic Wind Support Team

ExMember001

interresting,
i was wondering how i can get the handle with Cicon since it was not returning anything ;)
thanx!

Ionic Wind Support Team

Detach removes the handle from the class so it doesn't destroy it when the object is destroyed.  Normally when a class object goes out of scope (by DELETEing it or when a subroutine ends) CIcon will destroy the handle.

By using window.SetIcon(icon.Detach()) you are giving the handle to the window and it is then responsible for freeing the icon when the window closes, which happens automatically.
Ionic Wind Support Team