Changing application ICON -- can't make it happen in .net (This used to be so easy)

  • Thread starter Thread starter Just_a_fan
  • Start date Start date
J

Just_a_fan

It used to be SO EASY to change the application icon. Just imbed an
image and load that with a single statement when you wanted to change
the application ICON.

me.icon=image1.picture

Now, I can't make it happen without loading from an external file. It
did not convert from a working VB6 app. I have read all the helps I can
find on MSDN and still have no idea how to get an ICON file from the
resources file to the application.

One of them mentioned "LoadResPicture". That's not even a valid
command! Maybe on some other version old version, but not these days.

So what hoops do I have to jump through now to so this simple (well, it
used to be simple) task of changing me.icon.

I am doing it now by loading from a file on disk. I would rather not
have excess baggage to distribute. That is another thing I have to
relearn (building and bundling files) and am attacking one problem at a
time.

I think VB9 users are on the "bleeding edge" of technology. I have been
writing VB, commercially, since VB3 and VB-DOS 1 (thankfully, it went
away) and moving from VB6 to 2008.net (yeah, HUGE JUMP!!).

All help and, especially, working code examples appreciated. This,
right now, is a complete mystery. I thought I understood what a
resource file was for but I have missed the boat, somewhere. And the M$
documentation is very lacking.

Mike Morrow
 
It used to be SO EASY to change the application icon. Just imbed an
image and load that with a single statement when you wanted to change
the application ICON.

me.icon=image1.picture

Now, I can't make it happen without loading from an external file. It
did not convert from a working VB6 app. I have read all the helps I can
find on MSDN and still have no idea how to get an ICON file from the
resources file to the application.

One of them mentioned "LoadResPicture". That's not even a valid
command! Maybe on some other version old version, but not these days.

So what hoops do I have to jump through now to so this simple (well, it
used to be simple) task of changing me.icon.

I am doing it now by loading from a file on disk. I would rather not
have excess baggage to distribute. That is another thing I have to
relearn (building and bundling files) and am attacking one problem at a
time.

I think VB9 users are on the "bleeding edge" of technology. I have been
writing VB, commercially, since VB3 and VB-DOS 1 (thankfully, it went
away) and moving from VB6 to 2008.net (yeah, HUGE JUMP!!).

All help and, especially, working code examples appreciated. This,
right now, is a complete mystery. I thought I understood what a
resource file was for but I have missed the boat, somewhere. And the M$
documentation is very lacking.

Mike Morrow

Open up the properties of the application and you should see (now I am using
VS 2005) in the application tab a dropdown for Icon:. Choose from the list
(my resources are shown there) and you have an application Icon.

Hope this helps
Lloyd Sheen
 
I probably was not clear. I am wanting to change it programmatically as
a condition changes.

I can set it at design time but want to change it later from the
resource file.

Thanks,
Mike
 
It used to be SO EASY to change the application icon. Just imbed an
image and load that with a single statement when you wanted to change
the application ICON.

me.icon=image1.picture

You can change the icon as you did it before. Try this:

1) Double click My Project in Solution Explorer
2) Select Resources
3) Click the leftmost button (probably Strings) and change it to Icons
4) Click Add resource
5) Select the icon (it must be an .ico file!)

Now you can use this code:

Me.Icon=My.Resources.<IconName>

-Teemu
 
I probably was not clear. I am wanting to change it programmatically as
a condition changes.

I can set it at design time but want to change it later from the
resource file.

Thanks,
Mike

Sorry I cannot see any way to do this.
LS
 
I probably was not clear. I am wanting to change it programmatically
as a condition changes.

I can set it at design time but want to change it later from the
resource file.

Do you want to change the icon of the open window, or do you want to change
the icon of the executable file on disk?
 
What I want to do is to (VB6 EASY code) "me.icon = image1.image" in .NET

It seems impossible. I had just put this feature in a new VB6 project I
was writing before I "upgraded" to VB9 and it blew out on me.

This means that I want to change the program ICON during execution (this
program runs 24/7 logging information from some hardware) from any of
the ICONs I have stored in the resources file whenever I need to. It is
one way of getting attention when the user might want to be involved
solving a problem.

I can add them in to resources but can find no way (including the
incorrect MSDN documentation) to copy that information into me.icon. I
can load from a disk file but not from the resources and that's supposed
to be the purpose of the resources "file" as I understand it. The
alternative I can see is to package and distribute the .ICO files.
That's a bit silly.

I cannot find out how to access resources at all, yet. MSDN is silent
or wrong. Without a good book or a good help (non-existent), it is very
difficult to do.

<soapbox>I am very surprised how VERY difficult .NET has made the
simplest VB6 tasks!!! And the originally difficult ones are even harder
now. Some stuff is a little better. The screen design features are
nice but what's with allowing multiple items to have the SAME
Tabindex??? Used to be automatically changed. Now not changed. We
have gone backwards on that one. But I gotta use it,
unfortunately...</soapbox>

Maybe someone can write up a few paragraphs on what the resources thingy
is for? So far, it seems quite useless from this answer and others I
have seen. Possibly I am completely misunderstanding its purpose. I
will be reading my .NET 2003 book some more since the 2008 books are
just now coming along and I can't get one yet. I skipped all the .NET
stuff until last week and jumped in cold turkey (stopped using VB6).

Mike
 
I will try this right now. I hope it is this easy. Too bad no one but
you (and now me) knows this including everyone at M$!

Thanks a bunch!!!!! This makes it all easy if it works like this.

Mike
 
I tried it just like you documented it. It worked first try.

Someone should tell M$ about this! So easy. Apparently Resources works
just like I thought it did but have not found the proper code to access
it until now.

You are due one virtual beverage of your choosing. Please enjoy it.

and... THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Mike
 
Here's an oddness I did not expect.

In IDE mode, after I added the icons to the resource, I moved them out
of the directory. The IDE complained. Apparently the resource file is
just a pointer to the file until the build.

After the build, I was able to move the icons out of the bin directory
and all was well.

I will write up a little project and post on P-S-C, maybe today. One
answer I got back from someone else was that "it cannot be done" so I am
not the only one needing to know this tidbit.

Another note, apparently, "My." is new. The .NET 2003 book I have does
not have "My" listed in the index. No wonder I could not figure out how
to do this little task.

Thanks for the help, Teemu !!

Mike
 
Not knowing "My" exists makes it very difficult to find this page. I
searched with everything I could think of and did not get to it.

Yes, they know but it seems to be quite the secret!

When I get a book, it might help. One might be out by now but the rest
are still a couple of months out. Not knowing what to search for makes
it difficult. Same problem with IBM. Excellent books but you had to
know the name of what you want or you can not find it. Excellent
reference books but not good for learning unless you have time to read
cover to cover.

Of course, IBM has good error message. After (how many years?) a long
time in the industry and writing code, I am STILL getting (just last
week) from .NET and/or Windows:

"The file is in use"

Thanks a lot. WHAT FILE?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!

And this message comes out BEFORE my first code line executes so it is
some system file left open. If they would JUST TELL ME THE NAME OF THE
FILE, I could report it and maybe get it fixed.

I expect too much, though... B.G. has 100 Billion dollars and I get
"The file is in use".

Thanks, B.

Mike
 
Another note, apparently, "My." is new. The .NET 2003 book I have does
not have "My" listed in the index. No wonder I could not figure out how
to do this little task.

Thanks for the help, Teemu !!

I'm happy to hear that my advice was useful.

"My" was presented in Visual Basic 2005. There was not any equivalent thing
in old versions. Of course there was a way to do it but it wasn't so simple.

Here is some information about resources in old versions:
http://msdn2.microsoft.com/en-us/library/ms379610(VS.80).aspx

This shows how easy it is nowadays, just type My.Resources...

-Teemu
 
Back
Top