Step-by-step implementation of imitation QQ interface demo program compilation problems and MFC call ringsdk Image Library examples

Source: Internet
Author: User
Tags microsoft website

Many of my friends reported that the sample programs in step-by-step implementation of the QQ interface could not be compiled or compiled, and they hoped to have an MFC project. I would like to answer these questions here.

 

Demo program compilation problems:

 

1. the demo program requires the latest version of ringsdk. Use SVN to update SVN: // svnhost.cn/ringsdkto the latest version. tortoisesvnis recommended. Tortoisesvn: Token Check. input the address SVN: // svnhost.cn/ringsdkto get the latest ringsdk.

 

2. Install Platform SDK, you can go to the Microsoft website or go to the following address: ftp: // platformsdk: platformsdk@61.132.59.166/platform_sdk.zip. If Setup cannot be installed, please install psdk_x86.msi in the setup directory. After installation, select VC menu tools> options ..., in the displayed dialog box, select the directories page. In the show directories for: drop-down box, select include files. In the following list, check that the include directory of the Platform SDK is the first. Add the include directory of the ringsdk to the list, for example:

 

Then, select library files in the show directories for: drop-down box, and confirm that the lib directory of Platform SDK is the first, and add the lib directory of ringsdk to the list. If you want to follow up the ringsdk source code when debugging the program, add the directory under libsrc under ringsdk to the source files list.

 

3. Compile the ringsdk. First open the project in the three subdirectories under the ringsdk/libsrc/freelib directory. This is the three 3rd-party libraries, zlib, PNG, and JPEG libraries. compile the project. Open ringsdk/ringsdk. DSW and compile the ringsdk library.

 

4. Now the environment has been set up. You can compile the sample program under ringsdk/example and the demo program simulating the QQ interface.

 

How does MFC call the ringsdk Image Library:

 

Here is a demo program, MFC project,: http://download.csdn.net/source/2028551

 

First look at the program:

 

 

It is an animation type window. You can drag it with the left button and choose to exit from the shortcut menu. Here are the steps. You can do this without having to go to the demo program.

 

1. Create an mfcdibdemo project in the "Create an MFC" dialog box, and select "use MFC static library.

 

2. Select the VC menu project-> setting ..., general tab, confirm that Microsoft Foundation Classes: the option is use MFC in a static library, then select the C/C ++ tab, catgory: Select Code Generation, then select debug multithreaded or multithreaded in the use run-time library below. The setting is complete.

 

3. Save the above program image locally and add it to the resource. Enter "GIF" as the resource type and enter it together with quotation marks. The resource ID is idg_bkg.

 

4. Create a menu resource, such:

 

Map two menu items. The command functions are onhelp and onexit.

 

5. Added wm_lbuttondown, wm_rbuttondown, wm_mearuseitem, wm_drawitem to cmfcdibdemodlg to process messages.

 

6. Code modification:

 

The first header file of mfcdibdemodlg. h contains the image library and interface library:

 

# Include "ringdib. H"
# Include "ringdows. H"

 

The fcdibdemodlg class adds two member variables:

Ringdib m_dib;
Ringcoolmenu * m_rm;

 

Modify the mfcdibdemodlg. cpp file:

 

Cmfcdibdemodlg: at the end of oninitdialog, // Add the following code to Todo:

 

// This initialization must be performed when MFC calls the ringsdk library. The first parameter should be the main window handle, which can be null. The first parameter must be correctly passed <br/> initringlib (m_hwnd, afxgetresourcehandle (); <br/> dibregformat (GIF); <br/> m_dib.load (makeintresource (idg_bkg), "GIF", GIF ); <br/> m_dib.settarget (m_hwnd); <br/> m_dib.createcoolwindow (); </P> <p> m_rm = new ringcoolmenu; <br/> m_rm-> loadpopup (makeintresource (idr_popmenu); <br/> m_rm-> setxpstyle ();

 

New message code:

Void cmfcdibdemodlg: onlbuttondown (uint nflags, cpoint point) <br/>{< br/> // todo: add your message handler code here and/or call default </P> <p> cdialog: onlbuttondown (nflags, point); <br/> easymove (m_hwnd ); <br/>}</P> <p> void cmfcdibdemodlg: onrbuttondown (uint nflags, cpoint point) <br/>{< br/> // todo: add your message handler code here and/or call default </P> <p> cdialog: onrbuttondown (nflags, point ); </P> <p> m_rm-> popup (m_hwnd); <br/>}</P> <p> void cmfcdibdemodlg: onmeasureitem (INT nidctl, lpmeasureitemstruct) <br/>{< br/> // todo: add your message handler code here and/or call default <br/> If (lpmeasureitemstruct-> ctltype = odt_menu) <br/>{< br/> lpringmenustyle lprms = (lpringmenustyle) lpmeasureitemstruct-> itemdata; <br/> If (lprms) <br/>{< br/> try <br/>{< br/> lprms-> pmenu-> measureitem (lpmeasureitemstruct ); <br/>}< br/> catch (...) <br/>{< br/>}< br/> // cdialog: onmeasureitem (nidctl, lpmeasureitemstruct ); <br/>}</P> <p> void cmfcdibdemodlg: ondrawitem (INT nidctl, lpdrawitemstruct) <br/>{< br/> // todo: add your message handler code here and/or call default <br/> If (lpdrawitemstruct-> ctltype = odt_menu) <br/>{< br/> lpringmenustyle lprms = (lpringmenustyle) lpdrawitemstruct-> itemdata; <br/> If (lprms) <br/>{< br/> try <br/> {<br/> lprms-> pmenu-> draw (lpdrawitemstruct ); <br/>}< br/> catch (...) <br/>{< br/>}< br/> // cdialog: ondrawitem (nidctl, lpdrawitemstruct ); <br/>}</P> <p> void cmfcdibdemodlg: onclose () <br/>{< br/> // todo: add your message handler code here and/or call default <br/> Delete m_rm; <br/> cdialog: onclose (); <br/>}</P> <p> void cmfcdibdemodlg: onexit () <br/>{< br/> // todo: add your command handler code here <br/> postmessage (wm_syscommand, SC _close); <br/>}</P> <p> void cmfcdibdemodlg: onhelp () <br/>{< br/> // todo: add your command handler code here <br/> caboutdlg dlgabout; <br/> dlgabout. domodal (); <br/>}< br/>

 

Note that cdialog: onmeasureitem and cdialog: ondrawitem cannot be called in onmeasureitem and ondrawitem, because MFC will attempt to obtain the menu object of MFC but cannot obtain it, which will lead to illegal operations.

 

7. Complete and compile the program.

 

Note: If you use MFC, you should not use the ringsdk interface library, because it is for Windows and controls, and you want to port the QQ-like interface program to MFC, you should create an MFC window and control by yourself. You can copy the texture code.

 

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.