The implementation of VC imitating the superb QQ Interface
Author: Elio
Source code download
Keywords: VC ++ QQ interface skin swap self-painted controls transparent window Vista style free development kit Source Code Simulation
With the development and popularization of computer technology, computer has gradually entered people's daily life. People use it to learn, entertain, and interact with information. The requirements for various software products have also been improved. In addition to basic functions, it is easy to operate the software and the aesthetics of the interface. It is also an essential factor for successful software. The beautiful and personalized interface is one of the magic weapons for the software to attract and retain users. The communication software QQ/MSN is a typical representative of such products, the following uses VC ++ to simulate the QQ interface for your reference.
I believe you are quite familiar with QQ, so we will use Visual C ++ for implementation. Before that, it is necessary to introduce the general situation to the readers.
In fact, the most important part of the entire process is the custom part of the personalized interface, which is also the most difficult part. Concerning the interface programming knowledge, it is true that this is a relatively large architecture, and we can't simply describe it in a more comprehensive manner through a short length, in addition, the software development industry also has a tendency to shorten the development cycle and improve the development efficiency, so we can use external controls to help us solve this difficulty problem.
Here, we will also briefly introduce the selection of skin replacement controls. Of course, this is just a personal point of view and is only for your reference. Currently, the market provides multiple Skin-changing products (SkinMagic, Skin ++, USkin, AppFace, SkinCrafte, and so on), among which SkinMagic, AppFace, and USkin are relatively sloppy, the effects of some elements on the interface are unsatisfactory. skin ++ and SkinCrafte are doing well in this respect. objectively speaking, Skin ++ is currently an excellent product in China. It consumes more resources than SkinCrafte in Russia, the Russian SkinCrafte performs better in terms of appearance performance than Skin ++, COOL.
However, this implementation has not selected any of the above products, because SkinBeauty is a new one, which is arrogant in terms of performance and appearance, what's more, it claims to provide good keyboard operation support and claim that Vista's glass sand grinding effect can be made in systems such as Win2K and XP.
Of course, these are the so-called comparison results. Another reason for choosing SkinBeauty is that SkinBeauty can use its own skin editing software (SkinBeauty Studio) to implement a set of Window Interfaces containing multiple styles, button style. This does not seem to be available for any of the above products. This is also the requirement of our project (the main interface, the chat dialog box window is different, and there are multiple buttons with different features and other details ).
After a brief description above, we will start to implement it. First, let's look at the target effect,
0. preparations:
Use the corresponding skin editing software SkinBeautyStudio to edit the skin of each element on the interface. Generally, the nice-looking interface is drawn by the image (Here we download the existing BeautyQQ. bsk skin from the main site ). Prepare the downloaded skin replacement Development Library (SkinBeauty. dll, SkinBeauty. lib) and the interface file SkinBeautyExport. h, which will be provided after this article, or downloaded on your own on the www.afe-soft.com.
1. Create a project:
Open VC ++ and use the Wizard to create the MFC-based dialog box project BeautyQQ. The procedure is as follows:
New-> Projects-> MFC AppWizard (exe)-> Dialoag based others are created by default. Modify the dialog box size and title bar name. Compile the dialog box,
Running is basically normal, and the project creation is completed.
2. Load the skin replacement library
After the basic framework is completed, the interface is still very earthy and the running effect is difficult to satisfy. Therefore, we can load the skin replacement library and change the interface appearance of the program.
Put the prepared skinBeauty. dll library in the running directory of the project, and put the SkinBeautyExport. h file and SkinBeauty. lib file in the directory of the project to introduce and call the function interface later. (Generally, DLL library calls are divided into static calls and dynamic calls during program running. For the differences between the two, you can refer to other articles. Here, we will use the static call Method for implementation)
Add the import declaration in the appropriate location. Here we choose to add it in the stdafx. h file:
//inside stdafx.h
//SkinBeauty Lib Call
#include "SkinBeautyExport.h"
#pragma comment(lib,"SkinBeauty.lib")
In the project initialization location (here select the Project Creation instance cpp file, BeautyQQ. the CBeautyQQApp: InitInstance () function of cpp can be loaded here.) Add the code to the skin:
BOOL CBeautyQQApp::InitInstance()
{
CString exeFullPath;
CString strFilename;
int nLen = GetModuleFileName(NULL, exeFullPath,MAX_PATH);
CString strPath(exeFullPath);
strPath = strPath.Left(strPath.ReverseFind('\\'));
strFilename = strPath +_T("\\beautyQQ.bsk");
SkinLoad(THCAR2char(strFilename.GetBuffer(0)));
......
}
As shown above, we first use GetModuleFileName () to obtain the path for loading the skin, and then call the provided function interface SkinLoad () to load the skin swap library. The parameters of the SkinLoad () function are easy to understand, that is, the so-called path of the skin. Its prototype can be found in the header file:
//load the skin with a skin-file from a path.
//[IN]:absolute file path
BOOL SkinLoad(char* szSkinPath);
So far, the skin replacement library has been loaded. Run the command to check whether the effect is too high.
By the way, the official claim that after the SkinLoad () load is called, no uninstallation function needs to be called before exiting the program. The skin replacement engine will automatically implement operations such as database destruction and disassembly, unless you want to remove the appearance of your skin while running the program.
Now that you have completed the display and beautification of the QQ main interface, we will use the VC Wizard to add a dialog box resource, add the corresponding class, and name the CtalkDlg class. Its function is the dialog box of the chat dialog box, that is, when we double-click a user in the user list, a chat window pops up. when we run it, we find that the window background looks exactly the same as the main interface except the size. What should we do? It doesn't matter, because you have edited and prepared the window Skin Resources for another appearance in the skin file. We only need to create this chat dialog box and bind it with this skin resource, reload the initialization function of the CtalkDlg class and add the binding code. The implementation is as follows:
BOOL CTalkDlg: OnInitDialog ()
{
CDialog: OnInitDialog ();
// Bind the dialog box to a resource ID, so that it can be drawn according to the resource definition.
// Bind with the predefine res
BindRes2CtrlbyHWND (103, m_hWnd );
......
}
The above code function will be preinstalled in beautyQQ. the image resource of the defined dialog box in the bak skin is bound to the dialog box. The internal idnumber of the resource is 103 (note that this resource number is defined by the user when editing the skin, generally starting from 101 ). You can see from the preceding BindRes2CtrlbyHWND () function name and parameters. The function is to bind the appearance of the window handle m_hWnd to the skin resource with the resource Id 103. therefore, different windows can display different background skins.
Similar to this function, there are several buttons in the chat dialog box, which have different appearances. We should also bind the desired appearance Skin Resources, so, we can use the following function interfaces:
BindRes2CtrlbyID(106,IDC_BUTTON_TALK_SERACH);
The preceding statement binds the skin whose ID is 106 with the search button whose ID is IDC_BUTTON_TALK_SERACH, this function interface can pre-bind a widget to a specified skin resource before running the program. It provides the control resource ID and skin resource ID. Of course, you can also bind it as a handle. Unlike the preceding BindRes2CtrlbyHWND (), most dialog box windows do not have a fixed control resource ID concept during operation (unlike button, controls, such as edit, can only be bound in the form of real-time handle HWND. The prototype of the previous two resource binding functions can be found in the header file SkinBeautyExport. h, as shown below:
//bind a skin_resource with a Ctrl by Ctrl ID or by handle
//[IN]:user resource define in the skin-file; the ID/handle of Ctrl to be set
void BindRes2CtrlbyID(int nUserResID,DWORD dwCtrlID);
BOOL BindRes2CtrlbyHWND(int nUserResID,HWND hWnd);
Well, after the above description, it is not that difficult to implement QQ menus, user lists, and other functions by referring to the source code of the attachment, you only need to use it like the normal menu and ListCtrl. During running, the skin swap library will automatically beautify their appearance. You can download the source code to see how it is bound.
The entire complex and super-dazzling project is completed by calling two or three third-party interface functions after the Wizard is created. Frankly speaking, the entire skin replacement Development Kit provides very concise interface functions, more than 10, and the functions and usage are quite clear. I believe that you do not need to study more to know how to use them; if you have any questions about these interface functions, refer to the official development documentation.
In fact, the above example is similar to the source code provided by the merchant. I just explained the implementation process and hope it can be used as a reference for the user who made the interface. At first, I was disgusted with the use of the merchant interface skin-changing products. Later, I found that the effect and efficiency were still correct, I wrote an article with the encouragement of the merchants to help them introduce them to readers and exchange them with an Enterprise Edition Development Kit. It can be regarded as "Integrating personal interests with the interests of the masses". It's really good. You can test it. However, I am not satisfied with some users in China. Currently, SkinBeauty's user documentation is written in English and there is no Chinese version. This is inconvenient for some friends who do not move E files.
For interface development, it is recommended to download several skin replacement products to see their performance, such as resource usage, effects, and keyboard operability.
Conclusion
In an era where efficiency is particularly emphasized, you may wish to consider using trusted third-party controls to throw complicated and fixed implementations to them for processing, deepen product function services, and stand on the shoulders of others, optimize itself to go further and higher.
References
- Use skin replacement kit SkinBeauty developer home: www.afe-soft.com
- Development Kit (free version): http://www.afe-soft.com/downloadcenter.htm
- Development Documentation: http://www.afe-soft.com/downloadcenter.htm
(The free version has no Logo and no pop-up window restrictions. This can be convenient for some sharing friends. It is estimated that, of course, if the performance is good, not completely restricted. You still need to obtain the Enterprise Edition .. there is no free lunch in the world?... Haha, it's still not too bad)
Source: http://www.vckbase.com/document/viewdoc? Id = 1841
Compile cannot open file "uafxcwd. lib" in VC 6.0"
Cannot open file "uafxcwd. lib "I collect related solutions online. 1. add uafxcwd to menu project-settneigs-link-Object/Library modules. lib
2.
If it still does not work, select all the installation of vc, instead of the default installation. If it is unicode, you can use the vc disk to fix vc and select related items. I copied the lib in the vc disk to the vc mfc lib instead of re-installing it. I wrote an article but did not save it. This is the second time I wrote the attachment. The "uafxcwd. lib" file is required.
Attachment download:
Uafxcwd. lib
Uafxcwd. lib