美文网首页
2020-09-28

2020-09-28

作者: vmnabix | 来源:发表于2020-09-28 10:59 被阅读0次

windows 平台 创建第一个sciter程序

准备工作

创建工程

11.png 2.png

导入源码文件

文件名为main.cpp

#include "sciter-x.h"
#include "sciter-x-window.hpp"

class frame : public sciter::window {
public:
    frame() : window(SW_TITLEBAR | SW_RESIZEABLE | SW_CONTROLS | SW_MAIN | SW_ENABLE_DEBUG) {}

    // passport - lists native functions and properties exposed to script:
    SOM_PASSPORT_BEGIN(frame)
        SOM_FUNCS(
            SOM_FUNC(nativeMessage)
        )
        SOM_PASSPORT_END

        // function expsed to script:
        sciter::string  nativeMessage() { return WSTR("Hello C++ World"); }

};

#include "resources.cpp" // resources packaged into binary blob.

int uimain(std::function<int()> run) {

    sciter::archive::instance().open(aux::elements_of(resources)); // bind resources[] (defined in "resources.cpp") with the archive

    sciter::om::hasset<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"));
    //or use this to load UI from  
    //  pwin->load( WSTR("file:///home/andrew/Desktop/Project/res/main.htm") );

    pwin->expand();

    return run();
}

配置工程

  • 配置window环境变量

    在WIndows10系统环境变量中增加一个变量SCITERSDK,并指向sciter-sdk目录

    SCITERSDK = D:\sciter-sdk

  • 配置vs2017 属性

    添加头文件 $(SCITERSDK)/include

    如下图:

3.png ​ 4.png
  • 将 sciter-sdk/include/sciter-win-main.cpp 文件添加到项目

UI 设置

  • 创建res/main.htm 文件

    <html>
        <head>
            <title>Test</title>
            <style></style>
            <script type="text/tiscript"></script>
        </head>
        <body>
          Hello World!
        </body>
    </html>
    

运行工程

  • 在项目根目录下添加 pack-resources.bat . 然后保存运行

    %SCITERSDK%\bin\packfolder.exe res resources.cpp -v "resources"
    
  • 程序运行是需要sciter.dll的支持,从sciter-sdk的bin.win\x32目录中拷贝这个文件,到.exe 程序目录下

将pack-resources.bat调用添加为VS中的项目编译步骤

$(SCITERSDK)\bin.win\packfolder.exe $(ProjectDir)res $(ProjectDir)resources.cpp -v "resources"
5.png

相关文章

网友评论

      本文标题:2020-09-28

      本文链接:https://www.haomeiwen.com/subject/ytlduktx.html