Where are the default icons of components in C# stored? - c#

I will like to load the timer icon in main form icon, but can't find where it is stored.
So my question is: In which dll are icons of components stored (where is the timer icon stored)?

The icons you are referring to are embedded into the .NET Framework assemblies as resources. You can get various images and icons from here.

Related

When creating a custom file extension, is it possible to assign it an icon different from the application icon?

Hello wonderful people!
I have created some code for an application which upon startup, simply makes sure the registry has a key for my own file extension (or I guess 'class', as Windows calls it). It allows me to double-click a file with said extension and have it open with my program. Simple.
My query is this; is it possible for me to change the icon for this file class, to be different from the icon of my application? I would prefer to have some different icons for the various file extensions I'm registering, much in the same way that Photoshop for example gives a different icon for .PSD files than the actual application icon.
In simpler terms, I would like to mimic this behaviour but with my own icons and application:
Photoshop (the actual application):
Photoshop Document file:
I am working in C# and WPF. And I should also specify that the solution I'm looking for should be able to work in a scenario where I was to send my application to someone else to install on their computer; they should be able to see all the icons as described. I'd kindly request that in your answers you provide code examples, as I am not particularly familiar with working directly with the registry.
I should also specify that my application does have an icon, and this is currently what the custom filetype displays in Windows Explorer.

How to set a little icon on files under windows?

i would to set dynamically a little icon on the files (maybe on folders too) that i lock with my app.
I saw it with google app for synchronize, a little "refresh icon" appears to symbolize they are in synchronization, and i want make the same thing with my app that lock temporarely files to prevent changement meanwhile it works on it.
I Imagine it must use c++ api for Windows ?
It needs to change all the icon or with windows 10 you can add by a layer another icon ?
How to change dynamically an icon files ?
thanks.
Informations:
Environnement: Windows10.
Target: Files icon.
Language: c#, maybe
c++ api windows.
You can assign icons to the members of the file type by implementing
an icon handler. An icon handler is a type of Shell extension handler
that allows you to dynamically assign icons to the members of a file
type.
Refer to "How to Create Icon Handlers".
Similar topic: "How to create a IconHandler used by the shell in c++?"

What icon should be set as form's icon?

I have a WinForms application. I've set up the executable's icon (with at least 16x16 and 32x32 formats) in project settings and it is successfully shown in Explorer and elsewhere for .exe file.
How can I set this icon as form's icon (Form.Icon property or something)? It may be used in form's header at left and it will be used to show form in taskbar.
As I know, System.Drawing.Icon can't be created with multiple icon formats, but.. when user has his taskbar with 'small icons' enabled, the icon for taskbar should be 16x16. When this option is disabled, it should be 32x32. If icon has wrong size, the windows will scale it and it will look terrible.
Icon.ExtractAssociatedIcon gives me only one format (32x32). P/Invoking ExtractIconEx gives me both formats (16x16 and 32x32), but I unable to combine it in one System.Drawing.Icon instance to set to Form.Icon.
Of course, I can set the icon with form's properties from .ico file, but it will give me the resource duplication: one icon is stored in PE as executable's icon and another is stored as .NET resource.
Again, the question is: what settings I should use to make the exe's icon to be form's icon and work as it should with any taskbar settings?
It seems like the default icon handling routines in Windows and .Net don't extract multisize icons from modules well. The Icon class has tricky usage where it pulls in all the data from an icon file and then only uses one size, and you can create a new Icon object from that original Icon for a different size and it will share the data and extract the nearest size. Unfortunately methods to easily work with multi size icons aren't really included.
Here is code that will let you do what you want from Code Project, written for exactly your purpose: assigning the multisize icon from the EXE file to your forms.
Assigning an applications icon to all the forms in the application
Once you have the library added to your project, you can just assign the singleton property HostIcon to your form's icon property:
this.icon = Cliver.IconRoutines.HostIcon;

How to change desktop/folders Icons size programmatically C#

I'm developing a WPF that needs to make desktop icons and folder icons bigger while the WPF is active
and returns them to their previous state when closing the WPF
basically I want to be able to control the following options programmatically:
Folders icons :
desktop icons:
also how to change folder option to single click mode :
Folder icon settings are often per-folder and you will have a hard time forcing your preferences on them. You can probably find some descriptions of the registry locations and format if you search the internet for "shellbags" but this puts you in undocumented territory.
The desktop icon mode can probably be changed by undocumented/hacky means but you should just let the user do it.
You might be able to change the double-click mode by playing with fDoubleClickInWebView and SHGetSetSettings.

Automatically adjusting winform size and its controls position to various screen sizes and resolutions

I have a winforms application written in Visual Studio 2010, C#. My issue is trying to maintain the application for different screen resolution sizes. I can't scale it, since the layout of each of the controls are optimally suited for the aspect and size of the attached screen. Currently I maintain 3 different code, designer, and resx files for each (WF-1920, WF-1024, WF-800 for a 7", 10", and 24" screen, respectively). In the project, I copy the appropriate winform (cs, designer, resx) to the application solutions folder and rename it to WF.cs, WF-designer.cs, and WF.resx and make my changes, then build the application for each screen size. I have a pre-loader application that checks the screen size and then runs the application exe that is appropriate to it. This obviously, is very difficult to maintain. They all could utilize the same code file controls, methods, and events, but depending on the screen size, some are invisible, and others not used.
How can I have a single code file, that I can use and change the different form layouts without having to copy and rename each time I want to make a change?

Categories