Sciter 简单实用说明--初建项目

65 篇文章 6 订阅
61 篇文章 2 订阅

1.下载Sciter SDK,解压

官网下载地址:https://sciter.com/download/


2.打开vs2015以上,点击  新建项目Win32 (MFC也可以操作都差不多,这里用win32)Win32 项目 ,项目名称 MySciter

项目创建后打开项目设置  sciter头文件就是sciter SDK包里面的include文件夹

6.把项目中的MySciter内容用下面的内容替换

#include "stdafx.h"
#include "MySciter.h"
#include "sciter-x-window.hpp"
#include "resources.cpp"

class frame : public sciter::window
{
public:
    frame() : window(SW_TITLEBAR | SW_RESIZEABLE | SW_CONTROLS | SW_MAIN | SW_ENABLE_DEBUG) {}
    /*下面代码是我添加的,getSomeData是添加的脚本回调函数(JS  C++),在脚本回调函数里面,有一句call_function("sendToJs", ret);这个是C++调用脚本(C++  JS)
    */
    BEGIN_FUNCTION_MAP
        FUNCTION_2("getSomeData", getSomeData);
    END_FUNCTION_MAP
    sciter::value  getSomeData(sciter::value param1, sciter::value param2)
    {
        sciter::string str = param1.get<sciter::string>();
        int i = param2.get<int>();
        sciter::value ret = "aaa";
        call_function("sendToJs", ret);
        return ret;
    }
    /*代码添加结束*/
};


int uimain(std::function<int()> run) {
    //sciter::debug_output_console console; - uncomment it if you will need console window
    sciter::archive::instance().open(aux::elements_of(resources)); // bind resources[] (defined in "resources.cpp") with the archive
    frame* pwin = new frame();
    // note: this:://app URL is dedicated to the sciter::archive content associated with the application
    pwin->load(WSTR("this://app/main.htm"));
    pwin->expand();
    return run();
}

7.打开MySciter目录,在下面新建个文件夹 res ,在文件夹内新建个 main.htm 文件,main.htm的具体内容如下

<html>
    <head>
        <title>Test</title>
        <style></style>
        <script type="text/tiscript"></script>
   </head>
   <script type="text/tiscript">
          //通过view.getSomeData来调用C++里面的函数,view是一个全局变量
          $(.test).onClick = function()
         {
             stdout.println("H1被点击1");
             view.getSomeData("pa1",2);
             return true;
         }
       // 函数sendToJs可以供C++来调用
       function sendToJs( str )
       {
            stdout.println("in sendToJs");
            stdout.println(str);
       }
    <body>
         <h1 .test>Hello World!</h1>
    </body>
</html>

8.在项目目录下,新建一个 bat文件,内容如下: 前面的.exe路径是sciter的打包工具可以把html的东西都打包进软件。
C:\Users\Bin\Desktop\sciter-sdk-master\bin\packfolder.exe res resources.cpp -v "resources"

9.运行bat,会在把项目里的res文件夹内的东西,打包成一个资源文件再当前的项目里面 resources.cpp,在项目内,添加这个文件

10.到Sciter的解压目录下,进入include文件夹,把里面的sciter-win-main.cpp拷贝到我们MySciter项目文件内,并在项目中添加此文件

11.把sciter-sdk\bin\64或32的dll复制到项目bin目录下需要跟当前软件再同一目录;

12.编译运行。

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值