"Original" develop WM application series with C ++ (2) -- call

Source: Internet
Author: User
Tags add time

Develop WM application series Article indexes using C ++

Introduction:

In the previous section, we passed an MFC smart deviceProgramThe project brings everyone into the door of native C ++'s WM development. We learned how to add controls and events to programs and customize their own classes and methods. And how to let the program handle these events. Of course, we do not forget to recommend that you read"This book"Today, as mentioned in the previous section, we are going to make a small program related to WM by making a phone call. It is very easy to ask the program to dial out a number after clicking a button, but it is also basically representative!

However, to make a program call, unless you can have a real device for testing, install a wm6 SDK. It has a cellular simulator, which is good.

For more information, see instructor Li Bo'sArticle: Http://www.cnblogs.com/upto/archive/2007/03/13/mobile-development-tools.html

For more information about the use method, see the article of peterzb's predecessors: http://www.cnblogs.com/peterzb/archive/2009/06/13/1502771.html

UseCall simulatorPlease refer to this article by Teacher Li Bo: http://www.cnblogs.com/upto/archive/2007/02/14/cellular-emulater-in-wm6sdk.html

OK. To do this, you must first sharpen the tool. After preparing for the preliminary work, we can start today's exploration!

Body:

Due to the limitations of the level, we still create an intelligent device application based on the MFC template. The project name is "makecall, vs still generates some source files and header files for us. In the "resource view" window, we can still see our dialog box. I believe you have learned the meaning of these things in various ways before. I will not go into detail here. Open the dialog box resource, drag a button to the form, and change its caption attribute:Make it(Why not do it? This is related to the background of e-paper, which is not harmonious ~ Skipped here ~). Change the caption attribute of the original todo: XXXXX to: We will make a call. Of course, the content is whatever you want.

Here, since the above is: click a button and dial out a number. We naturally add an "event handler" for the "button1" or "make it" button. The method is as follows: Right-click the button and select "add time handler". The configuration is generally set by default!

OK! The method body already exists, and the rest is the method of adding the "call". Do you still remember ?. Net CF, it's too easy to make a phone call,ReferenceMicrosoft. windowsmobile. telephony namespace, and then use the talk method in the phone class to call. Now we are in the C ++ environment. Is that true? Certainly not, but it is similar. We also need to reference a so-called "namespace", but we like to call it"Library files". When we just wanted to reference it, we found that the original method was not feasible. Right-click the menu and there is no "reference-" to add reference ~, There is only one "reference ...". It doesn't matter. Don't change the dressing. Click it boldly ~

Day ~ Completely overwhelmed? Not afraid,We select by sequence number in the figure.In step 4, enter "phone. lib.

Ah, you may ask me, "How do you know why phone. Lib is not an iPhone. Lib ?", In fact, by reading the documentation provided by the wm6 SDK, we can basically see all the main functionsCodeAnd the lib to which it belongs. For details, please check it in private. After filling in the information, we can confirm it.

Here, basically ~ Next, we will add the dialing code for onbnclickedbutton1 in makecalldlg. cpp as follows: Our phonemakecallinfo struct and the phonemakecall method can be found in msdn.

 
Void cmakecalldlg: onbnclickedbutton1 () {phonemakecallinfo callinfo; callinfo. cbsize = sizeof (callinfo); callinfo. dwflags = pmcf_promptbeforecalling; // pmcf_default callinfo. pszdestaddress = l "13411897756"; phonemakecall (& callinfo );}

OK. Finally, remember to go to # include "phone. H" at the top of makecalldlg. cpp! The next step should be smooth compilation. Then we can see that in the simulator, there is a phone number that calls 13411897756!

Summary:

We learned:

    1. Add reference for specific functions of a program
    2. How to call
    3. Modify basic properties of a widget

Problem:

We also see:

    1. Dialing is rigid. You must set numbers flexibly.
    2. ......

Postscript:

In the next section, we will improve this program in the future so that his dialing can support our input and add a function for sending text messages, then we can learn more about the use of controls and methods.

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.