易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript Calls from C++

最近要用到相关技术,先贴在这,有空再翻页。
本文转自:
http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4399
http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4399/JavaScript-Calls-from-C.htm
http://www.codeproject.com/KB/COM/jscalls.aspx

Introduction
Sometimes, when we are using the IE Browser Control inside of a C++ application, we need to access the HTML elements. We can do it by using standard COM objects such as IWebBrowser2 , IHTMLDocument2 , and so forth. By doing this, we easily can implement features such as click button, click anchor, get input string, get HTML text, and so on. Unfortunately, Microsoft did not provide similar objects for JavaScript. In any case, it is possible to make a control for the JavaScript object inside an HTML page by using a traditional COM approach. This article describes the class CWebPage that allows you to do it and a technique to call a JavaScript function from C++ code.
How to Do This
As the result of using the presented class, it will be easy to call any JavaScript function from C++ code. To implement this feature, we should get a pointer to the IHTMLDocument2 interface. If we are using the CHtmlView class from MFC, we can get one by using member function CHtmlView::GetHtmlDocument() . In the case of using the IWebBrowser or IWebBrowser2 components, the function get_Document will bring us the desired interface. Here is an example:
CComPtr<IDispatch> spDisp = CHtmlView::GetHtmlDocument();
m_webPage.SetDocument(spDisp);

The rest of the things will be done by the CWebPage class. Here is an example of a JavaScript call without parameters.
m_webPage.CallJScript("Welcome");
The example of the JavaScript call with two parameters will look like this:
m_webPage.CallJScript("Miltiply","2.34","3.32");
The Class Implementation
class CWebPage
{
public:
CWebPage();
virtual ~CWebPage();
bool SetDocument(IDispatch* pDisp);
LPDISPATCH GetHtmlDocument() const;
const CString GetLastErr


相关文档:

用Javascript以类的方式进行冒泡排序

基本上全部加了注释,一行一注....呵呵
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>数组排序</title>
<mce:style type="text/css"&g ......

关于C/C++函数声明中参数个数的疑问

文章作者:Slyar
先看两个代码,第一个是C程序,第二个是C++程序,除了头文件不同以外其他的都一样。
//demo.c
#include <stdio.h>

int foo();

int main()
{
int a;
foo(a);
return 0;
}

int foo(int a)
{
}//demo.cpp
#include <iostream>

int foo();

int main()
{
in ......

函数的解析之C/C++

      函数是程序的执行模块,是整个项目的细胞,如何组织好每一个函数的结构,如何提高程序的可读性和运行效率,是程序员们不断品味的主体。有时函数的设计能直接体现出程序员对C/C++的理解和感悟。
      C/C++的函数类型不对外乎以下几种,有些描述可能不太贴切:
......

javascript 与 C# 互相调用

很多人都向在服务器
端调用客户端的函数来操作,也就是在asp中调用java
script脚本中已经定义好的脚本函数。经过研究,发现了一些勉强的方法。
1.
用Response.Write方法写入脚本
比如在你单击按钮后,先操作数据库
,完了后显示已经完成,可以在最后想调用的地方写上
Response.Write("<script type='text/j ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号