Among the tools we usually use, such as QQ, thunder, and various spaces, we provide some skin replacement functions, allowing us to choose a variety of interfaces we like. This article will make a simple skin replacement for window programs commonly used in Vs, using a DLL file for implementation.
First, we need to load a DLL file named irisskin2.dll and add irisskin2.dll to the application through "add reference" to call this DLL. Add a skinengine control in the toolbar. You can add a tab in the toolbar, for example, name it skin, right-click it, and find the skinengine control in the. netframework component of the selected item.
At this time, we can see that there is a skinengine control in the toolbar.
In addition, we also need a skin file, which is usually suffixed with. SSK or. skn. You can use either of the following methods to add a file named SSK in Bin/debug. This method is relatively simple. You only need to add such code to the program and it will be OK.
This. skinengine1.skinfile = "MSN. SSK ";
The file name can be any existing file name. As long as it exists in debug.
Another method is to use memorystream. It is implemented through a simple function.
Private void setskinfile (byte [] bytes)
{
Memorystream = new memorystream (bytes );
Skinengine1.skinstream = memorystream;
}
When using this function, you need to call this function, such as setskinfile (properties. Resources. wave1). To use the resources file, you must add the corresponding resources to the resource. The specific method is as follows:
Select resources in properties and add resources to add corresponding SSK resources.
The code for the entire window is as follows:
Using system;
Using system. Windows. forms;
Using system. IO;
Namespace skin
{
Public partial class form1: Form
{
Private int num = 0;
Private memorystream;
Public form1 ()
{
Initializecomponent ();
Setskinfile (properties. Resources. wave1 );
}
// Here, the constant skin replacement function is implemented through buttons, mainly for
// Several skin files are recycled
Private void button#click (Object sender, eventargs E)
{
Num = (Num ++) % 6 + 1;
This. skinengine1.skinfile = num + ". SSK ";
}
Private void setskinfile (byte [] bytes)
{
Memorystream = new memorystream (bytes );
Skinengine1.skinstream = memorystream;
}
}
}
The running effect of the above program is as follows:
In this way, as long as we have corresponding skin files, we can add them to the desired window to beautify the window.
Specific source code can be downloaded here for free: http://download.csdn.net/source/2862647