After you understand how C-level extensibility works in Dreamweaver and its dependency on certain data types and functions, it’s useful to know how to build a library and call a function.

The following example requires the following five files, located in the Dreamweaver-application-folder/ Tutorial_assets/Extending folder as archives for both the Macintosh and Windows platforms:

  • The mm_jsapi.h header file includes definitions for the data types and functions that are described in C-level extensibility and the JavaScript interpreter.
  • The mm_jsapi_environment.h file defines the MM_Environment.h structure.
  • The MMInfo.h file provides access to the Design Notes API.
  • The Sample.c example file defines the computeSum() function.
  • The Sample.mak make file lets you build the Sample.c source file into a DLL with Microsoft Visual C++; Sample.mcp is the equivalent file for building a Mach-O Bundle with Metrowerks CodeWarrior and Sample.xcode is the equivalent file for Apple Xcode. If you use another tool, you can create the makefile.

Build the DLL in Windows using VS.Net 2003

  1. Use File > Open, and select Sample.mak with Files Of Type set to All Files (*.*). (VS.Net 2003 does not open MAK files directly). You are then prompted to verify that you want to convert the project to the new format.
  2. Select Build > Rebuild Solution.

When the build operation finishes, the Sample.dll file appears in the folder that contains Sample.mak (or one of its subfolders).

Build the DLL in Windows using Microsoft Visual C++

  1. In Microsoft Visual C++, select File > Open Workspace, and select Sample.mak.
  2. Select Build > Rebuild All.

When the build operation finishes, the Sample.dll file appears in the folder that contains Sample.mak (or one of its subfolders).

Build the shared library on the Macintosh using Metrowerks CodeWarrior 9 or later

  1. Open Sample.mcp.
  2. Build the project (Project > Make) to generate a Mach-O Bundle.

When the build operation finishes, the Sample.bundle file appears in the folder that contains Sample.mcp.

Note:The Mach-O Bundle that is generated can only be used in Dreamweaver 8 and later. Earlier versions of Dreamweaver do not recognize it.

Build the shared library on the Macintosh using Apple Xcode 1.5 or later

  1. Open Sample.xcode.
  2. Build the project (Build > Build) to generate a Mach-O Bundle.

When the build operation finishes, the Sample.bundle file appears in the build folder that is next to the Sample.xcode file.

Note:The Mach-O Bundle that is generated can only be used in Dreamweaver 8 and later. Earlier versions of Dreamweaver do not recognize it.

Call the computeSum() function from the Insert Horizontal Rule object

  1. Create a folder called JSExtensions in the Configuration folder within the Dreamweaver application folder.
  2. Copy Sample.dll (Windows) or Sample.bundle (Macintosh) to the JSExtensions folder.
  3. In a text editor, open the HR.htm file in the Configuration/Objects/Common folder.
  4. Add the line alert(Sample.computeSum(2,2)); to the objectTag() function, as shown in the following example:
    function objectTag() {
    // Return the html tag that should be inserted
    alert(Sample.computeSum(2,2));
    return "<HR>";
    }
  5. Save the file and restart Dreamweaver.

To execute the computeSum() function, select Insert > HTML > Horizontal Rule.

A dialog box that contains the number 4 (the result of computing the sum of 2 plus 2) appears.


标题:Calling a C function from JavaScript

原址:http://helpx.adobe.com/dreamweaver/extend/calling-c-function-javascript.html

Dreamweaver 扩展开发: Calling a C++ function from JavaScript的更多相关文章

  1. Dreamweaver 扩展开发:C-level extensibility and the JavaScript interpreter

    The C code in your library must interact with the Dreamweaver JavaScript interpreter at the followin ...

  2. Dreamweaver 扩展开发:文档路径等信息的处理

    //browseFile(fieldToStoreURL){ //getFullPath(filePathURL){ //getSimpleFileName() { //fixUpPath(docUR ...

  3. Dreamweaver扩展注意事项

    对Dreamweaver扩展做了一些整理. 扩展开发扩展(Extension),是应用程序给用户预留的二次开发接口.Dreamweaver提供了对菜单,插入栏(Insertbar),浮动框等GUI部件 ...

  4. postgres扩展开发

    扩展开发的基本组成 demo--1.0.sql demo.c demo.control Makefile demo.c当中包含了自定义函数的实现,纯C语言,目录下可包含多个.c文件.demo-1.0. ...

  5. Chrome扩展开发之二——Chrome扩展中脚本的运行机制和通信方式

    目录: 0.Chrome扩展开发(Gmail附件管理助手)系列之〇——概述 1.Chrome扩展开发之一——Chrome扩展的文件结构 2.Chrome扩展开发之二——Chrome扩展中脚本的运行机制 ...

  6. PHP扩展开发相关总结

    1.线程安全宏定义 在TSRM/TSRM.h文件中有如下定义 #define TSRMLS_FETCH() void ***tsrm_ls = (void ***) ts_resource_ex(0, ...

  7. Chrome浏览器扩展开发系列之十四

    Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59      阅读:1361      评论:0      收藏:0    ...

  8. Chrome扩展开发之三——Chrome扩展中的数据本地存储和下载

    目录: 0.Chrome扩展开发(Gmail附件管理助手)系列之〇——概述 1.Chrome扩展开发之一——Chrome扩展的文件结构 2.Chrome扩展开发之二——Chrome扩展中脚本的运行机制 ...

  9. Chrome扩展开发之四——核心功能的实现思路

    目录: 0.Chrome扩展开发(Gmail附件管理助手)系列之〇——概述 1.Chrome扩展开发之一——Chrome扩展的文件结构 2.Chrome扩展开发之二——Chrome扩展中脚本的运行机制 ...

随机推荐

  1. ASP.NET Core 1.1.0 Release Notes

    ASP.NET Core 1.1.0 Release Notes We are pleased to announce the release of ASP.NET Core 1.1.0! Antif ...

  2. System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。

    在NHibernate数据库查询中出现了这个错误,由于是数据库是mysql的,当定义的字段为char(36)的时候就会出现这个错误. [解决方法] 将char(36) 改成varchar(40)就行了 ...

  3. Zabbix基本配置及监控主机

    监控主机一版需要在被监控的主机上安装Zabbix Agent 监控主机 安装zabbix-agent 首先需要在被监控的主机上安装agent,可以下载预编译好的RPM进行安装,下载地址:http:// ...

  4. ShenNiu.MVC管理系统

    本篇将要和大家分享的是一个简单的后台管理系统,这里先发个地址http://www.lovexins.com:8081/(登陆账号:youke,密码:123123:高级用户账号:gaoji,密码:123 ...

  5. mybatis plugins实现项目【全局】读写分离

    在之前的文章中讲述过数据库主从同步和通过注解来为部分方法切换数据源实现读写分离 注解实现读写分离: http://www.cnblogs.com/xiaochangwei/p/4961807.html ...

  6. 缓存、队列(Memcached、redis、RabbitMQ)

    本章内容: Memcached 简介.安装.使用 Python 操作 Memcached 天生支持集群 redis 简介.安装.使用.实例 Python 操作 Redis String.Hash.Li ...

  7. C#使用GET、POST请求获取结果

    C#使用GET.POST请求获取结果,这里以一个简单的用户登陆为例. 1. 使用GET请求获取结果 1.1 创建LoginHandler.aspx处理页面 protected void Page_Lo ...

  8. React Native 之 Text的使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  9. ReactiveCocoa代码实践之-UI组件的RAC信号操作

    上一节是自己对网络层的一些重构,本节是自己一些代码小实践做出的一些demo程序,基本涵盖大多数UI控件操作. 一.用UISlider实现调色板 假设我们现在做一个demo,上面有一个View用来展示颜 ...

  10. windows 7(32/64位)GHO安装指南(U盘引导篇)~

    上一篇我们说了怎么制作U盘启动盘,那么这一篇让我们来看看如何进行正确的U盘引导启动. 现在的个人计算机一般分为台式机和笔记本,由于各厂商的喜好不同(开玩笑的啦),所以对于主板的BIOS设置各所不同.进 ...