2020-09-28

2020-09-28  本文已影响0人  vmnabix

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();
}

配置工程

3.png ​ 4.png

UI 设置

运行工程

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

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

猜你喜欢

热点阅读