EgtExecutor 1.6x5 :

- migliorata in Lua EgtOutBox
- aggiunta in Lua EgtFileDialog
- aggiunta in Lua EgtGetCalcToolDirFromaAngles.
This commit is contained in:
Dario Sassi
2017-01-09 10:17:31 +00:00
parent c0fb5b2010
commit 502571e982
9 changed files with 157 additions and 2 deletions
+50 -2
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "EXE.h"
#include "LUA.h"
#include "GenTools.h"
#include "/EgtDev/Include/ExeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGnStringUtils.h"
@@ -216,7 +217,7 @@ LuaOutLog( lua_State* L)
static int
LuaOutBox( lua_State* L)
{
// 3 o 4 parametri : stringa, titolo, icona [bModal]
// 3 o 4 parametri : stringa, titolo, icona [, bModal]
string sOut ;
LuaCheckParam( L, 1, sOut)
string sTitle ;
@@ -233,7 +234,7 @@ LuaOutBox( lua_State* L)
LuaGetParam( L, 4, bModal) ;
LuaClearStack( L) ;
// emetto la finestra di dialogo
int nRes = MessageBox( nullptr, stringtoW( sOut), stringtoW( sTitle),
int nRes = MessageBox( FindTopWindow(), stringtoW( sOut), stringtoW( sTitle),
MB_OKCANCEL | nIcon | ( bModal ? MB_TASKMODAL : MB_SYSTEMMODAL)) ;
// risultato (Ok->true, Cancel->false)
LuaSetParam( L, ( nRes == IDOK)) ;
@@ -272,6 +273,52 @@ LuaOutText( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaFileDialog( lua_State* L)
{
// 3 parametri : bOpenVsSave, sFile, sFilter
bool bOpenVsSave ;
LuaCheckParam( L, 1, bOpenVsSave)
string sFile ;
LuaCheckParam( L, 2, sFile)
string sFilter ;
LuaCheckParam( L, 3, sFilter)
LuaClearStack( L) ;
// Converto i parametri nel formato wide e cambio L'|' in L'\0' nel filtro
AtoWEX<MAX_PATH> wsFileName( sFile.c_str()) ;
AtoW wsFilter( sFilter.c_str()) ;
for ( wchar_t* pC = wsFilter.m_psz ; *pC != L'\0' ; ++ pC) {
if ( *pC == L'|')
*pC = L'\0' ;
}
// Riempio la struttura dati per il dialogo
OPENFILENAME ofn ;
ZeroMemory( &ofn, sizeof( ofn)) ;
ofn.lStructSize = sizeof( ofn) ;
ofn.hwndOwner = FindTopWindow() ;
ofn.lpstrFilter = LPWSTR( wsFilter) ;
ofn.lpstrFile = LPWSTR( wsFileName) ;
ofn.nMaxFile = MAX_PATH ;
ofn.Flags = OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST ;
// Visualizzo il dialogo
if ( bOpenVsSave) {
ofn.Flags |= OFN_FILEMUSTEXIST ;
if ( GetOpenFileName( &ofn) != FALSE)
LuaSetParam( L, wstrztoA( wsFileName)) ;
else
LuaSetParam( L) ;
}
else {
ofn.Flags |= OFN_OVERWRITEPROMPT ;
if ( GetSaveFileName( &ofn) != FALSE)
LuaSetParam( L, wstrztoA( wsFileName)) ;
else
LuaSetParam( L) ;
}
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaExistsFile( lua_State* L)
@@ -490,6 +537,7 @@ LuaInstallGeneral( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtOutBox", LuaOutBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtProcessEvents", LuaProcessEvents) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOutText", LuaOutText) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtFileDialog", LuaFileDialog) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExistsFile", LuaExistsFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyFile", LuaCopyFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRenameFile", LuaRenameFile) ;