首页 新闻 工控搜 论坛 厂商论坛 产品 方案 厂商 人才 文摘 下载 展览
中华工控网首页
  P L C | 变频器与传动 | 传感器 | 现场检测仪表 | 工控软件 | 人机界面 | 运动控制
  D C S | 工业以太网 | 现场总线 | 显示调节仪表 | 数据采集 | 数传测控 | 工业安全
  电 源 | 嵌入式系统 | PC based | 机柜箱体壳体 | 低压电器 | 机器视觉
WINCE下如何添加CPL应用程序
深圳市盈鹏飞科技有限公司
收藏本文     查看收藏

2 创建Hello World应用工程

       打开wince OS Designe工程,点击文件(F) -> 新建(N)-> Subproject添加子工程,工程类型设置为WCE ApplicationSubproject name命名为Helloworld

       点击下一步(N),选择A typical “Hello world” application,然后点击完成(F)


3 创建HelloCPL控制面板应用工程

点击文件(F) -> 新建(N)-> Subproject添加子工程,工程类型设置为WCE Dynamic-Link Library,工程名为HelloCPL

       然后点击下一步(N),在Auto-generated subproject files页面中选择A Dll that exports some symbols

       这是工程面板中看起来如下:

       双击HelloCPL工程中Source files下的HelloCPL.cpp,将其中的内容替换如下:

       //

// HelloCPL.cpp : Defines the entry point for the DLL

//

 

#include "stdafx.h"    // Auto-generated by wizard.

#include "HelloCPL.h"  // Auto-generated by wizard.

#include "resource.h"  // Auto-generated at compile time

 

#include <tchar.h>     // General text functions.

#include "cpl.h"       // Control Panel support.

#define DEBUG

// Returns the number of characters in an expression.

#define lengthof(exp) ((sizeof((exp)))/sizeof((*(exp))))

 

HMODULE g_hModule = NULL;   // Handle to the DLL.

 

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Main entry point for the Control Panel DLL.

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

extern "C" BOOL APIENTRY DllMain( HANDLE hModule,

                       DWORD  ul_reason_for_call,

                       LPVOID lpReserved )

{

  switch (ul_reason_for_call)

  {

    case DLL_PROCESS_ATTACH:

    {

      g_hModule = (HMODULE) hModule;

    }

    case DLL_THREAD_ATTACH:

    case DLL_THREAD_DETACH:

    case DLL_PROCESS_DETACH:

       break;

    }

    return TRUE;

}

 

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// The entry point to the Control Panel application.

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

extern "C" HelloCPL_API LONG CALLBACK CPlApplet(HWND hwndCPL,

                  UINT message, LPARAM lParam1, LPARAM lParam2)

{

  switch (message)

  {

    case CPL_INIT:

      // Perform global initializations, especially memory

      // allocations, here.

      // Return 1 for success or 0 for failure.

      // Control Panel does not load if failure is returned.

      return 1;

 

    case CPL_GETCOUNT:

      // The number of actions supported by this Control

      // Panel application.

      return 1;

 

    case CPL_NEWINQUIRE:

      // This message is sent once for each dialog box, as

      // determined by the value returned from CPL_GETCOUNT.

      // lParam1 is the 0-based index of the dialog box.

      // lParam2 is a pointer to the NEWCPLINFO structure.

    {

      ASSERT(0 == lParam1);

      ASSERT(lParam2);

 

      NEWCPLINFO* lpNewCplInfo = (NEWCPLINFO *) lParam2;

      if (lpNewCplInfo)

      {

         lpNewCplInfo->dwSize = sizeof(NEWCPLINFO);

         lpNewCplInfo->dwFlags = 0;

         lpNewCplInfo->dwHelpContext = 0;

         lpNewCplInfo->lData = IDI_HELLOWORLD;

 

         // The large icon for this application. Do not free this

         // HICON; it is freed by the Control Panel infrastructure.

         lpNewCplInfo->hIcon = LoadIcon(g_hModule,

                                  MAKEINTRESOURCE(IDI_HELLOWORLD));

 

          LoadString(g_hModule, IDS_APP_TITLE, lpNewCplInfo->szName,

                     lengthof(lpNewCplInfo->szName));

          LoadString(g_hModule, IDS_HELLO, lpNewCplInfo->szInfo,

                     lengthof(lpNewCplInfo->szInfo));

//        LoadString(g_hModule, IDC_HelloWorld, lpNewCplInfo->szInfo,

//                     lengthof(lpNewCplInfo->szInfo));

          _tcscpy(lpNewCplInfo->szHelpFile, _T(""));

          return 0;

      }

      return 1;  // Nonzero value means CPlApplet failed.

    }

 

    case CPL_DBLCLK:

    {

      // The user has double-clicked the icon for the

      // dialog box in lParam1 (zero-based).

      PROCESS_INFORMATION pi = {0};

      if (CreateProcess(_T("\\Windows\\HelloWorld.exe"), NULL, NULL,

                             NULL, FALSE, 0, NULL, NULL, NULL, &pi))

      {

        CloseHandle(pi.hThread);

        CloseHandle(pi.hProcess);

        return 0;

      }

      return 1;     // CPlApplet failed.

    }

 

    case CPL_STOP:

      // Called once for each dialog box. Used for cleanup.

    case CPL_EXIT:

      // Called only once for the application. Used for cleanup.

    default:

      return 0;

  }

 

  return 1;  // CPlApplet failed.

  }  // CPlApplet

      &nbs, p;  本工程用到1个图标资源文件IDI_HELLOWORLD2个字符串资源IDS_APP_TITLEIDS_HELLO


4 向控制面板添加资源文件

       A右键点击HelloCPL -> Source Files,选择Add -> New Item,见下图:

       点击Add后,双击HelloCPL->source files->HelloCPL.rc,见下图

      


B右键点击上图中的HelloCPL.rc,选择Add Resource,弹出下面的对话框,添加ICON

       并修改IconIDIDI_HELLOWORLD.

       C重复步骤B,添加String Table,并修改String Table中的内容如下:

 


5编译控制面板应用程序

A右键点击HelloCPL工程,选择属性,弹出如下窗口

B选择General标签页,在Custom Variable栏点击 按钮打开Custom Variable对话框。

 

C点击NEW打开Environment Variable窗口,Variable Name输入CPLVariable Value输入1。点击OK关闭Environment Variable,再点击OK关闭Custom Variables。这样做的目的是强制工程输出.cpl文件,而不是.dll文件。

D点击C/C++标签页,在Include Directories添加$(_PROJECTROOT)\cesysgen\oak\inc

       确认Additional MacroDefinitions设置为$(CDEFINES) -DHelloCPL_EXPORTS

       修改DLL Entry PointDllmain

      点击OK关闭属性设置对话框。

E修改HelloCPL.bib,替换为如下内容

                           MODULES
                           HelloCPL.cpl $(_FLATRELEASEDIR)\HelloCPL.cpl           NK

F右键点击HelloCPL,然后Build即可生成对应的内核,烧录到系统启动后即可在控制面板中看到Hello Control Panel的图标,双击后即可运行Helloworld.exe



 

状 态: 离线

公司简介
产品目录

公司名称: 深圳市盈鹏飞科技有限公司
联 系 人: 李希岗
电  话: 0086-13602511395
传  真: 0755-82523175,82523176-819
地  址: 深圳市福田区福明路40号,雷圳大厦12A06
邮  编: 518033
主  页:
 
该厂商相关技术文摘:
Wince sqlite3移植
EAC-C925开机画面实现手册
更多文摘...
立即发送询问信息在线联系该技术文摘厂商:
用户名: 密码: 免费注册为中华工控网会员
请留下您的有效联系方式,以方便我们及时与您联络

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 不良信息举报
工控网客服热线:0755-86369299
版权所有 中华工控网 Copyright©2022 Gkong.com, All Rights Reserved