473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Application Icon and resources

Hi:

I am new to .net stuff and to make the matter worst, I am converting
from Borland to Microsoft world. So I am having real hard time
figuring things out in VC++ .net. (I am using VS 2008)

here is my questions:
1 - How do I get access to Application Icon at runtime. Lets say I
want to change the Icon that is displayed on the taskbar button on the
fly depending on some condition in the process.
2 - I see that there still is a .rc file in the "Solution" and I can
add images and icons and ... to it. How can I extract these things at
runtime. In the API world I would just call LoadIcon or LoadString
or ... How do I do these in C++.net?

Thank you
Sam
Aug 19 '08 #1
1 1607
On Aug 19, 4:05*pm, sfir...@gmail.com wrote:
Hi:

I am new to .net stuff and to make the matter worst, I am converting
from Borland to Microsoft world. So I am having real hard time
figuring things out in VC++ .net. (I am using VS 2008)

here is my questions:
1 - How do I get access to Application Icon at runtime. Lets say I
want to change the Icon that is displayed on the taskbar button on the
fly depending on some condition in the process.
2 - I see that there still is a .rc file in the "Solution" and I can
add images and icons and ... to it. How can I extract these things at
runtime. In the API world I would just call LoadIcon or LoadString
or ... How do I do these in C++.net?

Thank you
Sam
I found the answer myself:

using namespace System::Runtime::InteropServices;

[DllImport("user32.dll")]
extern IntPtr LoadIconW(void* hInst, wchar_t* sID);


// Get the instance handle
IntPtr hinst =
Marshal::GetHINSTANCE(System::Reflection::Assembly ::GetExecutingAssembly()-
>GetModules()[0]);
// Get the icon as unmanaged
IntPtr hic(1); // in my case the Icon ID in the resource file was 1

hic = LoadIconW(hinst.ToPointer(), (wchar_t*)hic.ToPointer());

// import the unmanaged icon into the managed side
this->Icon = ::Icon::FromHandle(hic);
Aug 21 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
4
by: Terry | last post by:
There are a number of things about using unmanaged resources in Windows Forms programming that is unclear to me. In C++, if you loaded an icon resource using "ExtractIcon()", the resource was...
3
by: Wayne | last post by:
I currently have an app whose Icon I am setting. I want to set the icons in my forms at run time to that of the application icon. How do I retrieve the application Icon so that I can use it for my...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
0
by: Jordi Gou | last post by:
Hello. I want to develop an application that let me update a resource of another one. I developed a method to update strings of the string tables resources and to update bitmaps resources. My...
9
by: Max | last post by:
Hello, Using VB.NET, I can activate an application by entering: AppActivate(intProcessID), where intProcessID is the process ID of a running application. Is it possible to set the size and...
2
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging...
3
by: QLD_AU | last post by:
Is their a way in a VB.Net application to set all sub form icons to the main form ? or even set all icons to the Application icon, without having to reference the icon as a filename ? With...
4
by: randy1200 | last post by:
I have a Windows application that previously had the company logo "MyCompany.ico" added to the upper left-most corner. The company has since issued a new version of "MyCompany.ico" that looks...
2
by: James Arnold | last post by:
Is there any way to set the forms icon to one stored in the resources at design time? Currently I am using the following code in the FormLoad event to set it at run time: Me.Icon =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.