From b1a11c4eaf18a7a5bf491e1623b835884a2e86d2 Mon Sep 17 00:00:00 2001 From: DarioS Date: Tue, 17 Jan 2023 11:29:59 +0100 Subject: [PATCH] EgtExecutor 2.5a3 : - aggiunta funzione ExeMessageBox. --- EXE_General.cpp | 12 ++++++++++++ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_General.cpp | 40 +++++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/EXE_General.cpp b/EXE_General.cpp index 2fa231d..43028a0 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -536,6 +536,18 @@ ExeGetEnableUI( void) return s_bEnableUI ; } +//----------------------------------------------------------------------------- +int +ExeMessageBox( const string& sText, const string& sTitle, int nType) +{ + int nRes = 0 ; + if ( ExeGetEnableUI()) { + HWND hTopWnd = ExeGetMainWindowHandle() ; + nRes = MessageBox( hTopWnd, stringtoW( sText), stringtoW( sTitle), nType | MB_TASKMODAL) ; + } + return nRes ; +} + //----------------------------------------------------------------------------- bool ExeSetProcessEvents( pfProcEvents pFun) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index a456b14b32ffc8f2ccd53b8c9a447f14bd2ad4e9..dfeadd62d1e5f4edb13b337dcdf603ac84416474 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK diff --git a/LUA_General.cpp b/LUA_General.cpp index f017b00..39f21b0 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -493,7 +493,7 @@ LuaGetEnableUI( lua_State* L) static int LuaOutBox( lua_State* L) { - // 2 o 3 parametri : stringa, titolo [, icona] + // 2, 3 o 4 parametri : sOut, sTitle [, sIcon] [, sButtons] string sOut ; LuaCheckParam( L, 1, sOut) string sTitle ; @@ -510,16 +510,34 @@ LuaOutBox( lua_State* L) nIcon = MB_ICONINFORMATION ; else if ( sIcon == "QUESTION") nIcon = MB_ICONQUESTION ; + string sButtons ; + LuaGetParam( L, 4, sButtons) ; + int nButtons = MB_OKCANCEL ; + ToUpper( sButtons) ; + if ( sButtons == "OK") + nButtons = MB_OK ; + else if ( sButtons == "OKCANCEL") + nButtons = MB_OKCANCEL ; + else if ( sButtons == "ABORTRETRYIGNORE") + nButtons = MB_ABORTRETRYIGNORE ; + else if ( sButtons == "YESNOCANCEL") + nButtons = MB_YESNOCANCEL ; + else if ( sButtons == "YESNO") + nButtons = MB_YESNO ; + else if ( sButtons == "RETRYCANCEL") + nButtons = MB_RETRYCANCEL ; + else if ( sButtons == "CANCELTRYCONTINUE") + nButtons = MB_CANCELTRYCONTINUE ; LuaClearStack( L) ; - // se abilitata UI, emetto la finestra di dialogo - int nRes = IDCANCEL ; - if ( ExeGetEnableUI()) { - HWND hTopWnd = ExeGetMainWindowHandle() ; // FindTopWindow() ; - nRes = MessageBox( hTopWnd, stringtoW( sOut), stringtoW( sTitle), - MB_OKCANCEL | nIcon | MB_TASKMODAL) ; - } - // risultato (Ok->true, Cancel->false) - LuaSetParam( L, ( nRes == IDOK)) ; + // emetto finestra di dialogo (solo se ablitata UI) + int nRes = ExeMessageBox( sOut, sTitle, nButtons | nIcon) ; + // risultato + if ( nRes == IDOK || nRes == IDRETRY || nRes == IDYES || nRes == IDTRYAGAIN) + LuaSetParam( L, true) ; + else if ( nRes == IDNO || nRes == IDCONTINUE || nRes == IDIGNORE) + LuaSetParam( L, false) ; + else + LuaSetParam( L) ; return 1 ; } @@ -1150,7 +1168,7 @@ LuaDialogBox( lua_State* L) // se abilitata UI, lancio dialogo if ( ExeGetEnableUI()) { // lancio dialogo - HWND hTopWnd = ExeGetMainWindowHandle() ; // FindTopWindow() ; + HWND hTopWnd = ExeGetMainWindowHandle() ; bool bOk = ( DialogBox( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUADLG), hTopWnd, (DLGPROC)DialogBoxProc) == IDOK) ; // restituzione parametri if ( bOk) {