Skin library usage and button image settings

Source: Internet
Author: User

It seems that there are quite a lot of online interface libraries. After my research, I found that the general usage methods are similar.

Currently, several mainstream skin libraries are available:

Libuidk www.iuishop.com)

Skinfeature/skin ++ www.uipower.com/(looks like the same)

Skinsharp www.skinsharp.com/(similar to skinfeature !!!)

Now let's talk about how to use the skin library .........

Most skin libraries must have these three files first. For example, skinfeature must first download three files: skinfeature. dll, skinfeature. Lib, and skinfeature. h.

Put the three files in the working directory, and then add these lines of code to the cxxapp file.

#include "SkinFeature.h"#pragma comment(lib,"SkinFeature.lib")

Import the header file and Lib file, and prepare the skin configuration file. If it is a skinfeature, it is an RSS file.

Put the RSS file in the working directory.

Then call the loadskinfile function.

Initializeskin (); // initialize the environment if (! Loadskinfile (lpctstr ("../skin/guimagic. RSS") {MessageBox (null, _ T ("loading failed"), null, mb_ OK );}

 

In fact, the highest level of skin library is that the interface and logic are completely separated, no matter how your skin is changed, it will not affect your business logic, next, let's talk about how to add images for buttons !!!!!!!

There are several ways to add images to a button. I 'd like to say a few.
Method 1: load resource Images

Load the bitmap to the resource, and set the resource ID to idb_bitmap1.

 HBITMAP hBmp; hBmp = (HBITMAP)::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1)); CButton* pBtn = (CButton*)GetDlgItem(IDC_BUTTON1); pBtn->SetBitmap(hBmp);

If a non-resource image is loaded, the second parameter of loadbitmap must be set to the full path of the image. Remember to set the bitmap attribute to true.

Method 2: subclass

m_btnTest.SubclassDlgItem(IDC_BUTTON1,this);m_btnTest.LoadBitmaps(IDB_BITMAP2);m_btnTest.SizeToContent();

Call subclassdlgitem to subclass the window. Remember to set ower draw to true.

Method 3: Use cbitmapbutton

1. In the MFC dialog project, add a button in a dialog, Set ID to idc_button_test, caption to button_test, and select the owner draw attribute in the style. (Note the relationship between caption naming and ID naming)

2. Add a button image to the resource.

Assume that the image is as follows:

Button image when test_up.bmp is normal

Button image when test_down.bmp is clicked

Test_focused.bmp

Image after the test_disable.bmp button expires

Set its ID to (note that both the left and right sides must contain double quotation marks)

"Button_testu"

"Button_testd"

"Button_testf"

"Button_tests"

3. In the code file corresponding to dialog, modify the type of the button to cbitmapbutton.

For example:

Cbitmapbutton m_btntest;

Add an image loading method in oninitdialog ()

M_btntest.autoload (idc_button_test, this); // map the image to the control using the ID

Compile and run.

Finally, the skinfeature skin library file is attached. dll, Lib, and H files are included in the skinfeature skin library for download.
The next goal is to simulate a tree-like control similar to QQ. The ultimate goal is to develop software that can communicate within the lan. Stay tuned to my blog !!!!!!

Related Article

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.