Getting application Icon
-
Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso
-
Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso
Dirso wrote:
it will get the application icon (if any) and show it in the top left corner
An application can have many icons, which one do you want?
Dirso wrote:
I saw I few methods but they assume I know the namespace and the icon name
Well, that's because you have to choose between the many potential icons that may exist in your application.
Dirso wrote:
as I told you the form may be used in any application
Actually, you didn't. This is the first time you mentioned that piece of information.
Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog
-
Dirso wrote:
it will get the application icon (if any) and show it in the top left corner
An application can have many icons, which one do you want?
Dirso wrote:
I saw I few methods but they assume I know the namespace and the icon name
Well, that's because you have to choose between the many potential icons that may exist in your application.
Dirso wrote:
as I told you the form may be used in any application
Actually, you didn't. This is the first time you mentioned that piece of information.
Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog
-
Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso
Try putting the following code in the constructor for your form. It should pick up the Icon for any app in which it is included.
this.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);
Henry Minute If you open a can of worms, any valid solution *MUST* involve a larger can!
-
Try putting the following code in the constructor for your form. It should pick up the Icon for any app in which it is included.
this.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);
Henry Minute If you open a can of worms, any valid solution *MUST* involve a larger can!