Similar aspects of MFC and Android Development

Source: Internet
Author: User

I used MFC in college, but it was used in the Lab Course of digital image processing to implement a set of image denoising procedures. in addition, at that time, it was also a framework that was well developed by others. I added some source code for noise-removing algorithms, and I had no in-depth understanding of MFC.

I did mobile phone development last year and had some knowledge of Android. Now I am engaged in MFC again. I saw something similar, so I wrote this article first.

1. Comparison of layout files

The layout files of Android are all under the project directory: Res/layout/*. xml. Of course, this * number represents the name of the file named by the developer.

The layout file of MFC is a strange one. file ending with RC. open Visual Studio and you can see that it contains the dialog, icon, menu, stringtable, and version parts (which may vary depending on the project ). the page layout is under the dialog. from this point of view, the layout file of MFC is not a common layout file, but a summary file of resources required for compilation by some programs, such as buttons, menus, icons, and constants.

2. ICON resources

The icons or images used by Android are stored in the Res/drawable directory. Of course, the earlier versions will split drawable into small icons, medium icons, and large icon folders to adapt to different resolutions.

The ICON resources in MFC are directly placed under the res directory of the project.

3. Some Constants

Android stores the constants used in the XML file specified by the developer under the Res/values directory;

In the RC file of MFC, there is a stringtable that can correspond to the android constant file. However, as I mentioned earlier, the RC file of MFC is a summary file, a little hodgedge.

4. How to find the required controls

Android generates an R. java files. this file contains the ID of some controls used by the program. the corresponding control can be used in the program according to the number and the corresponding layout file. in the android program, you can use findviewbyid to find the corresponding control. The returned result is a view object, which requires a type conversion to convert to the corresponding specific control type, in this way, the control can be operated in the program.

MFC also has a similar mechanism. however, it is in. the RC file generates a resource at the same level. h file. use the getdlgitem () method to obtain the pointer of a control.

5. Set and obtain the value of the text Control

Android directly drops the corresponding. settext method settings and calls the. gettext method to obtain the settings.

A common practice in MFC is to bind the text control with the member attributes of a class. that is, in the dodataexchange method that inherits the subclass from cwnd, use ddx_text (PDX, Control ID, class variable name) to bind the values in the controls on the interface to the class member variables. use updata (true) to fl the text value in the control back to the class member attribute.

6. Events

In Android, setonxxlistner (New View. onxxlistner () {}) is called to increase event processing.

In MFC And end_message_map, Add corresponding events (Component ID, corresponding processing function reference) to increase event processing.

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.