Use the skin control to implement skin replacement in vs2010

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.