Windows Mobile之Hello World

暂时告别Symbian,告别MTK,开始拥抱Windows Mobile,低调、虔诚的开始WM开发学习之旅。

First,say Hello World!(以下摘自SDK Help文档)

 

IDE:vs2005
SDK:WM 6.0
To create a Windows Application project
  1. On the File menu, point to New, and then select Project.

  2. In the Project Types pane, expand the Visual C++ branch and select Smart Device.

  3. In the Templates pane, choose Win32 Smart Device Project.

  4. In the Name box, name the project something unique to indicate the application's purpose. In the Location box, enter the directory in which you want to save your project, or click the Browse button to navigate to it.

  5. The Win32 Smart Device Project Wizard will appear. Select Next to select the platforms you wish to support.

  6. Select the platforms you wish to support with your application. For this walkthrough, select Windows Mobile 6 SDK for Pocket PC and add it to the Selected SDKs. Remove any other platforms from the Selected SDKs list. Select Next.

  7. This step of the wizard allows you to select additional Application Settings. Make sure Windows Application is selected and then click Finish.

The Win32 Smart Device Project will be created and the .cpp file will be displayed in the IDE.

To compile and link the application
  1. Replace the TODO comment in the WM_PAINT event handler with the following lines of code:

     Code
      case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
                
        int bReturn;
        TCHAR szHelloStr[50];
    
        StringCchCopy(szHelloStr, 50, L"Hello World!");
    
        // Set text color.
        SetTextColor (hdc, RGB(0,0,0));
    
        bReturn = ExtTextOut (hdc, 10, 10, 0, NULL,             
                              szHelloStr, lstrlen(szHelloStr), NULL);
    
                
        EndPaint(hWnd, &ps);
      break;
  2. From the Solution Configurations dropdown, located in the toolbar, select Debug.

  3. From the Target Device dropdown, located in the toolbar, select your device to test the application on. For this walkthrough, select Windows Mobile 6 for Pocket PC Emulator.

  4. Build your project by selecting Build Solution from the Build menu. Check the results of the build in the Output window. Fix errors as needed until the project builds successfully.

 

概括之:

1、建立Smart win application工程

2、在对应的.cpp文件中的WM_PAINT 事件中加入代码

 

 Code
  case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps);
            
    int bReturn;
    TCHAR szHelloStr[50];

    StringCchCopy(szHelloStr, 50, L"Hello World!");

    // Set text color.
    SetTextColor (hdc, RGB(0,0,0));

    bReturn = ExtTextOut (hdc, 10, 10, 0, NULL,             
                          szHelloStr, lstrlen(szHelloStr), NULL);

            
    EndPaint(hWnd, &ps);
  break;

 

3、保存,调试,运行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值