Skip to content

Commit

Permalink
增加DuiVision脚本演示工程和对应的演示脚本目录。
Browse files Browse the repository at this point in the history
  • Loading branch information
blueantst committed Feb 12, 2017
1 parent 4f5a285 commit 852ac28
Show file tree
Hide file tree
Showing 15 changed files with 1,284 additions and 0 deletions.
114 changes: 114 additions & 0 deletions DuiVisionScriptDemo/DuiVisionScriptDemo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// DuiVisionScriptDemo.cpp : 定义应用程序的类行为。
//

#include "stdafx.h"
#include "DuiVisionScriptDemo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CDuiVisionScriptDemoApp

BEGIN_MESSAGE_MAP(CDuiVisionScriptDemoApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CDuiVisionScriptDemoApp 构造

CDuiVisionScriptDemoApp::CDuiVisionScriptDemoApp()
{
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的一个 CDuiVisionScriptDemoApp 对象

CDuiVisionScriptDemoApp theApp;


// CDuiVisionScriptDemoApp 初始化

BOOL CDuiVisionScriptDemoApp::InitInstance()
{
CWinApp::InitInstance();

AfxEnableControlContainer();

// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("DuiVisionScriptDemo"));

// 初始化DuiVision界面库,可以指定语言,dwLangID为0表示自动判断当前语言
// 11160是应用程序ID,每个DUI应用程序应该使用不同的ID,ID主要用于进程间通信传递命令行时候区分应用
DWORD dwLangID = 0;
new DuiSystem(m_hInstance, dwLangID, _T("DuiVisionScriptDemo.ui"), 11164, IDD_DUIVISIONAPP_DIALOG, _T(""));

// 加载解释器和主脚本
HINSTANCE hPluginHandle = NULL;
LPVOID pPluginObj = NULL;
#ifdef _DEBUG
CString strDllFile = DuiSystem::Instance()->GetConfig(_T("interpDll_d"));
#else
CString strDllFile = DuiSystem::Instance()->GetConfig(_T("interpDll"));
#endif
CString strInstanceName = DuiSystem::Instance()->GetConfig(_T("interpInstance"));
if(DuiSystem::Instance()->LoadInterpPlugin(strDllFile, strInstanceName, hPluginHandle, pPluginObj))
{
m_hInterpPluginHandle = hPluginHandle;
m_pInterpObject = (IInterp*)pPluginObj;
// 执行主脚本文件
CString strMainScript = DuiSystem::Instance()->GetConfig(_T("mainScript"));
if(strMainScript.IsEmpty())
{
DuiSystem::DuiMessageBox(NULL, _T("没有配置执行的脚本文件!"), _T("错误"), MB_OK|MB_ICONERROR);
}else
{
CString strScriptFile;
if(strMainScript.Find(_T(".tcl")) == -1)
{
strScriptFile = DuiSystem::Instance()->GetXmlFile(strMainScript);
}else
{
strScriptFile = strMainScript;
}
if(strMainScript.Find(_T(":")) == -1)
{
strMainScript = DuiSystem::GetSkinPath() + strMainScript;
}
BOOL bRunRet = m_pInterpObject->RunScriptFile(strMainScript);
CString strResult = m_pInterpObject->GetResult();
if(!bRunRet)
{
DuiSystem::DuiMessageBox(NULL, strResult, _T("运行错误"), MB_OK|MB_ICONERROR);
}
}

// 释放脚本解释器
if(m_pInterpObject != NULL)
{
m_pInterpObject->Release();
m_pInterpObject = NULL;
}

if(m_hInterpPluginHandle != NULL)
{
// 释放有些问题,暂不释放动态库
//FreeLibrary(m_hInterpPluginHandle);
//m_hInterpPluginHandle = NULL;
}
}else
{
DuiSystem::DuiMessageBox(NULL, _T("加载脚本解释器失败!"), _T("错误"), MB_OK|MB_ICONERROR);
}

// 释放DuiVision界面库的资源
DuiSystem::Release();

// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
// 而不是启动应用程序的消息泵。
return FALSE;
}
32 changes: 32 additions & 0 deletions DuiVisionScriptDemo/DuiVisionScriptDemo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// DuiVisionDemo.h : PROJECT_NAME 应用程序的主头文件
//

#pragma once

#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif

#include "resource.h" // 主符号


// CDuiVisionScriptDemoApp:
// 有关此类的实现,请参阅 DuiVisionScriptDemo.cpp
//

class CDuiVisionScriptDemoApp : public CWinApp
{
public:
CDuiVisionScriptDemoApp();

public:
virtual BOOL InitInstance();

public:
HINSTANCE m_hInterpPluginHandle; // 保存解释器插件动态库的句柄
IInterp* m_pInterpObject; // 解释器插件对象

DECLARE_MESSAGE_MAP()
};

extern CDuiVisionScriptDemoApp theApp;
170 changes: 170 additions & 0 deletions DuiVisionScriptDemo/DuiVisionScriptDemo.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// ����(�л����񹲺͹�) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"
"LANGUAGE 4, 2\r\n"
"#pragma code_page(936)\r\n"
"#include ""res\\DuiVisionScriptDemo.rc2"" // �� Microsoft Visual C++ �༭����Դ\r\n"
"#include ""l.CHS\\afxres.rc"" // ��׼���\r\n"
"#endif\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\DuiVisionScriptDemo.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DUIVISIONAPP_DIALOG DIALOGEX 0, 0, 159, 70
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_APPWINDOW
CAPTION "DuiVisionScriptDemo"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
END


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080403a8"
BEGIN
VALUE "CompanyName", ""
VALUE "FileDescription", "DuiVisionScriptDemo"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "DuiVisionScriptDemo.exe"
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "DuiVisionScriptDemo.exe"
VALUE "ProductName", "DuiVisionScriptDemo"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 936
END
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DUIVISIONAPP_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 152
TOPMARGIN, 7
BOTTOMMARGIN, 63
END
END
#endif // APSTUDIO_INVOKED

#endif // ����(�л����񹲺͹�) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE 4, 2
#pragma code_page(936)
#include "res\DuiVisionScriptDemo.rc2" // �� Microsoft Visual C++ �༭����Դ
#include "l.CHS\afxres.rc" // ��׼���
#endif

/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Loading

0 comments on commit 852ac28

Please sign in to comment.