From 292361139a681a1425de600601be26c2bd7dd935 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 8 May 2026 08:40:01 +0200 Subject: [PATCH 1/3] EgtExecutor (ModelessDialog) : - primo commit. --- AuxDialogBox.cpp | 90 +++++++ AuxDialogBox.h | 31 +++ EXE_GdbObjSelection.cpp | 19 ++ EgtExecutor.rc | Bin 19652 -> 27184 bytes EgtExecutor.vcxproj | 2 + EgtExecutor.vcxproj.filters | 6 + LUA_General.cpp | 503 +++++++++++++++++++++++++++++++++++- resource.h | 64 ++++- 8 files changed, 702 insertions(+), 13 deletions(-) create mode 100644 AuxDialogBox.cpp create mode 100644 AuxDialogBox.h diff --git a/AuxDialogBox.cpp b/AuxDialogBox.cpp new file mode 100644 index 0000000..f8f6907 --- /dev/null +++ b/AuxDialogBox.cpp @@ -0,0 +1,90 @@ +//---------------------------------------------------------------------------- +// EgalTech 2026-2026 +//---------------------------------------------------------------------------- +// File : AuxDialogBox.cpp Data : 24.04.26 Versione : 3.1d4 +// Contenuto : Funzioni DialogBox. +// +// +// Modifiche : 24.04.26 RE Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "AuxDialogBox.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EgtStringConverter.h" + +using namespace std ; + +#pragma comment( lib, "Comctl32.lib") + +HWND phDlgModeless = nullptr ; +int nDlgModelessItem = -1 ; + +//----------------------------------------------------------------------------- +bool +UpdateIdsModelessDialog( HWND phDlgModeless, int nDlgModelessItem) +{ + // se DialogBox Modeless non inizializzato, esco + if ( phDlgModeless == nullptr) + return false ; + // se Id del controllo da aggiornare non valido, esco + if ( nDlgModelessItem == -1) + return false ; + + // recupero tutti gli elementi selezionati + string sIds ; + int nId = ExeGetFirstSelectedObj() ; + while ( nId != GDB_ID_NULL) { + sIds.append( ToString( nId) + string{","}) ; + nId = ExeGetNextSelectedObj() ; + } + if ( ! sIds.empty()) + sIds.pop_back() ; + + // aggiorno il contenuto nel dialogo + return ( SetDlgItemText( phDlgModeless, nDlgModelessItem, stringtoW( sIds))) ; +} + +//----------------------------------------------------------------------------- +LRESULT CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + if ( msg == WM_GETDLGCODE) + return DLGC_WANTALLKEYS ; + + if ( msg == WM_KEYDOWN && wParam == VK_RETURN) { + // dwRefData contiene l'ID dell'EDIT + int nEditId = int( dwRefData) ; + HWND hwndDlg = GetParent(hwnd); + if ( hwndDlg == nullptr) + return FALSE ; + // recupero il testo dell'EDIT corretto + string sIds ; + AtoWEX<128> wsEdit( "") ; + if ( GetDlgItemText( hwndDlg, nEditId, LPWSTR( wsEdit), 128) > 0) + sIds = wstrztoA( wsEdit) ; + // deseleziono tutto + ExeDeselectAll() ; + // seleziono gli ID contenuti + if ( ! sIds.empty()) { + STRVECTOR vsIds; + Tokenize( sIds, ",", vsIds) ; + for ( auto& s : vsIds) { + int nId = GDB_ID_NULL ; + if ( FromString( s, nId) && nId != GDB_ID_NULL) + ExeSelectObj( nId) ; + } + } + // aggiorno la grafica ed esco + ExeDraw() ; + return TRUE ; + } + + return ( DefSubclassProc(hwnd, msg, wParam, lParam)) ; +} diff --git a/AuxDialogBox.h b/AuxDialogBox.h new file mode 100644 index 0000000..25466fc --- /dev/null +++ b/AuxDialogBox.h @@ -0,0 +1,31 @@ +//---------------------------------------------------------------------------- +// EgalTech 2026-2026 +//---------------------------------------------------------------------------- +// File : AuxDialogBox.h Data : 24.04.2026 Versione : 3.1d4 +// Contenuto : Prototipi funzioni DialogBox. +// +// +// +// Modifiche : 22.04.26 RE Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "stdafx.h" +#include "resource.h" +#include "/EgtDev/Include/ExeExecutor.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include + +//---------------------------------------------------------------------------- +// Identificativo della finestra ModeLess corrente ( nullptr se non esiste) +extern HWND phDlgModeless ; +extern int nDlgModelessItem ; + +// Funzione per passaggi di parametri tra Selezione DB e dialogo non modale +bool UpdateIdsModelessDialog( HWND phDlgModeless, int UpdateIdsModelessDialog) ; + +//Funzione per selezionare gli Id presenti all'interno dei un EditText +LRESULT CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) ; diff --git a/EXE_GdbObjSelection.cpp b/EXE_GdbObjSelection.cpp index 4f9441f..2123095 100644 --- a/EXE_GdbObjSelection.cpp +++ b/EXE_GdbObjSelection.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "EXE.h" #include "EXE_Macro.h" +#include "AuxDialogBox.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtStringConverter.h" @@ -76,6 +77,9 @@ ExeSelectObj( int nId) " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return bOk ; } @@ -100,6 +104,9 @@ ExeDeselectObj( int nId) " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return bOk ; } @@ -139,6 +146,9 @@ ExeSelectAll( bool bOnlyIfVisible) " -- bOk=1" ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return true ; } @@ -160,6 +170,9 @@ ExeDeselectAll( void) " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return bOk ; } @@ -186,6 +199,9 @@ ExeSelectGroupObjs( int nGroupId) " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return bOk ; } @@ -209,6 +225,9 @@ ExeDeselectGroupObjs( int nGroupId) " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } + // verifico se presente un dialogo modeless per aggiornare i valori + if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1) + UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ; // restituisco risultato return bOk ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 481350afd9da57bac1cefe39811a63356f5a28a3..913688662fe41513f8ddd3e3d11b08495d5a91ac 100644 GIT binary patch delta 2922 zcma)8O-~bH5S~&$08_OZN`OQWl@=_}?Z@s`gHR|SP&I;bFh(SX5E23^=*6>%H-$NQ zH1TGFm|jdgVLW*7qVW&-3ylB3nZBLfzS7-oHf^^1KJ(1H&oiBUzrG3W{R-{vhU3$) z4lA$*%dknGZb-m9Y{3$JR_WIrT3zLPj848N-#_&IGCmkSeyj*3n1V&P4ke8Ao{!j& zgCxPzU_-V%+`AlVt1Qw(15)%bNlRHU@k9KIRUpoFcuG0fC{GWqO+yjJp#V4NdxEIl zSW}Db2$j%Cb>O3xBRD$HiuV$+0fk+pJSs;LGGNkup7JFrIs&a!n7Z`n!9F)S?L?bY zZv)Xg{cdo^38vjQ5{y6lV?$CnN3b}qRKcacyX3~R@)Dn+y9SEKXGu4n#gh13L(+9S zwOci@c4NZfnZejO*}F6bSCFdJ4j-pSE((gRH3-3#Ds%Z4+mwM6zO}mWl=Z|xvjT!v zX6on_T(AZmGjfeh;$7?w5lMERypuhe!j{e-KaBUnIS4ptI=xE zV6DxP(=gI?I>yv6(rG%z(lC-!$JmT%S8HxZDg90S93L7Vqfx&_*9HxJqh{PM!Wg|? zZqs#>2EU^rby1q$Cfrq`p^bkNr}107N8?HdaxsT+iQ4tKGJ#xb#;dx-8Ha14c8}RW zE;aELmpeu3v*iNW)chAVal1a78OX-YiDm}*pq#AFW(BgT_k+|X9ptdh*6L;lvZ=R) zVsm><{Xeti_K_b=__ENc9ZudCGCPrG{4zQdwt(_Bw{2(4;~Y=<8JEA z6d1niH1&Pgb71+d=Y8YTq}>P|T;48jhN2tPD+%fwJ|eHt(RisGo%|R+_!zf~`{ma&*`|M#1@(yl delta 194 zcmdmRh4IKt#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g&mwr3CfkULO+JvwH~ChY#%6 + @@ -249,6 +250,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index e214c45..d88ca92 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -111,6 +111,9 @@ File di intestazione + + File di intestazione + @@ -431,6 +434,9 @@ File di origine\LUA + + File di origine\Global + diff --git a/LUA_General.cpp b/LUA_General.cpp index 5735f6c..facb251 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -18,6 +18,7 @@ #include "LUA.h" #include "GenTools.h" #include "resource.h" +#include "AuxDialogBox.h" #include "/EgtDev/Include/ExeExecutor.h" #include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EGkStringUtils3d.h" @@ -1212,22 +1213,39 @@ LuaReleaseMutex( lua_State* L) } //------------------------------------------------------------------------------- -const int MAX_CTRLS = IDC_TEXT8 -IDC_TEXT1 + 1 ; +// =================================== DIALOG =================================== +// Variabili Globali const int OFFS_CTRLS = 40 ; -enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4} ; -static int s_nCtrls = 0 ; -static string s_sCaption ; -static string s_sText[MAX_CTRLS] ; -static string s_sEdit[MAX_CTRLS] ; -static int s_nType[MAX_CTRLS] ; +enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4, CTRL_BUTTON = 5} ; static COLORREF s_CustomColors[16] = {12632256} ; // 16 colori GRAY static bool s_bCustomColorsInit = false ; // flag di inizializzazione colori const char* SEC_SCENE = "Scene" ; const char* KEY_CUSTOMCOLORS = "CustomColors" ; +// Dialogo Modale +const int MAX_CTRLS = IDC_TEXT8 - IDC_TEXT1 + 1 ; +static int s_nCtrls = 0 ; +static string s_sCaption ; +static string s_sText[MAX_CTRLS] ; +static string s_sEdit[MAX_CTRLS] ; +static int s_nType[MAX_CTRLS] ; + +// Dialogo non modale +const int MAX_CTRLS_ML = IDC_TEXT_ML_8 - IDC_TEXT_ML_1 + 1 ; +static int s_nCtrls_ML = 0 ; +static string s_sCaption_ML ; +static string s_sText_ML[MAX_CTRLS_ML] ; +static string s_sEdit_ML[MAX_CTRLS_ML] ; +static int s_nType_ML[MAX_CTRLS_ML] ; +struct DialogContext { + lua_State* L ; // stato Lua per Click bottone OK + int nCallBackFun ; // indice di funzione CallBack +} ; +static string s_sIdSel_ML ; + //------------------------------------------------------------------------------- BOOL -CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) +CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { // variabili static locali per mantenere lo stato tra chiamate per selezione colori static COLORREF selectedColor[MAX_CTRLS] = {0} ; // BLACK @@ -1507,6 +1525,408 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam return FALSE ; } +//------------------------------------------------------------------------------- +BOOL +CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + // variabili static locali per mantenere lo stato tra chiamate per selezione colori + static COLORREF selectedColor[MAX_CTRLS_ML] = {0} ; // BLACK + static HBRUSH hColorBrush[MAX_CTRLS_ML] = {NULL} ; // non definito + + switch ( message) { + case WM_INITDIALOG : + { + // imposto il contesto per recuperalo in futuro ( per la funzione di CallBack Lua) + SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam) ; + + // colore di default + COLORREF defaultColor = RGB( 255, 0, 0) ; + // inizializzazione colori e brush + for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) { + selectedColor[i] = defaultColor ; + if ( hColorBrush[i] != NULL) + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ; + } + // dati del dialogo + HWND hwndOwner = GetParent( hwndDlg) ; + if ( hwndOwner == nullptr) + hwndOwner = GetDesktopWindow() ; + RECT rcOwner, rcDlg ; + GetWindowRect( hwndOwner, &rcOwner) ; + GetWindowRect( hwndDlg, &rcDlg) ; + // determino la posizione dell'ultima riga di dati da visualizzare + HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT_ML_1 + Clamp( s_nCtrls_ML, 1, MAX_CTRLS_ML) - 1) ; + RECT rcLR ; + GetWindowRect( hwndLR, &rcLR) ; + POINT ptLR{ rcLR.left, rcLR.top} ; + ScreenToClient( hwndDlg, &ptLR) ; + // centro e scalo il dialogo + int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre + SetWindowPos( hwndDlg, HWND_TOP, + ( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2, + ( rcOwner.top + rcOwner.bottom - nNewH) / 2, + ( rcDlg.right - rcDlg.left), + nNewH, 0) ; + // riposiziono il bottone Ok + HWND hwndOk = GetDlgItem( hwndDlg, IDOK_ML) ; + RECT rcOk ; + GetWindowRect( hwndOk, &rcOk) ; + POINT ptOk{ rcOk.left, rcOk.top} ; + ScreenToClient( hwndDlg, &ptOk) ; + SetWindowPos( hwndOk, hwndDlg, ptOk.x, ptLR.y + OFFS_CTRLS, 0, 0, SWP_NOSIZE | SWP_NOZORDER) ; + // riposiziono il bottone Cancel + HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL_ML) ; + RECT rcCl ; + GetWindowRect( hwndCl, &rcCl) ; + POINT ptCl{ rcCl.left, rcCl.top} ; + ScreenToClient( hwndDlg, &ptCl) ; + SetWindowPos( hwndCl, hwndDlg, ptCl.x, ptLR.y + OFFS_CTRLS, 0, 0, SWP_NOSIZE | SWP_NOZORDER) ; + // stile finestra + LONG style = GetWindowLong( hwndDlg, GWL_STYLE) ; + style |= WS_SYSMENU ; + SetWindowLong( hwndDlg, GWL_STYLE, style) ; + } + + // assegno titolo del dialogo + SetWindowText( hwndDlg, stringtoW( s_sCaption_ML)) ; + + // assegno testi e valori di default e nascondo linee dei controlli non usati + for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) { + if ( i < s_nCtrls_ML) { + + // imposto il testo nella riga corrente + SetDlgItemText( hwndDlg, IDC_TEXT_ML_1 + i, stringtoW( s_sText_ML[i])) ; + + // --- se CheckBox + if ( s_sEdit_ML[i].find( "CK:") == 0) { + bool bChecked = false ; + FromString( s_sEdit_ML[i].substr( 3), bChecked) ; + CheckDlgButton( hwndDlg, IDC_CHECK_ML_1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + s_nType_ML[i] = CTRL_CHECK ; + } + + // --- se ComboBox + else if ( s_sEdit_ML[i].find( "CB:") == 0) { + string sList = s_sEdit_ML[i].substr( 3) ; + STRVECTOR vsVal ; + Tokenize( sList, ",", vsVal) ; + int nSel = 0 ; + HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i) ; + for ( int j = 0 ; j < ssize( vsVal) ; ++ j) { + string sItem ; + if ( vsVal[j][0] == '*') { + nSel = j ; + sItem = vsVal[j].substr( 1) ; + } + else + sItem = vsVal[j] ; + ComboBox_AddString( hwndCBox, stringtoW( sItem)) ; + } + ComboBox_SetCurSel( hwndCBox, nSel) ; + int nEditHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, (WPARAM)-1, 0)) ; + int nItemHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, 0, 0)) ; + int nTotalHeight = nEditHeight + nItemHeight * ( ssize( vsVal) + 1) ; + RECT rc ; GetWindowRect( hwndCBox, &rc) ; + HWND parent = GetParent(hwndCBox) ; MapWindowPoints( NULL, parent, (LPPOINT)&rc, 2) ; + SetWindowPos( hwndCBox, NULL, rc.left, rc.top, rc.right - rc.left, nTotalHeight, SWP_NOZORDER) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo CheckBox + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + s_nType_ML[i] = CTRL_COMBO ; + } + + // --- se ColorPicker + else if ( s_sEdit_ML[i].find( "CP:") == 0) { + string sVal = s_sEdit_ML[i].substr( 3) ; + Color CColor ; + if ( ! FromString( sVal, CColor)) + CColor = INVISIBLE ; + selectedColor[i] = RGB( CColor.GetIntRed(), CColor.GetIntGreen(), CColor.GetIntBlue()) ; + if ( hColorBrush[i] != NULL) + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ; + // recupero i valori dei colori personalizzati dal file .ini + if ( ! s_bCustomColorsInit) { + // recupero il file Ini + string sIniFile = ExeGetIniFile() ; + if ( ! sIniFile.empty()) { + string sCustomVals = GetPrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, "", sIniFile.c_str()) ; + STRVECTOR vsWinColors ; Tokenize( sCustomVals, ",", vsWinColors) ; + for ( int j = 0 ; j < ssize( vsWinColors) && j < 16 ; ++ j) { + unsigned int unVal ; + if ( FromString( vsWinColors[j], unVal)) { + unsigned int unR = unVal & 0xFF ; + unsigned int unG = ( unVal >> 8) & 0xFF ; + unsigned int unB = ( unVal >> 16) & 0xFF ; + s_CustomColors[j] = RGB( unR, unG, unB) ; + } + } + } + s_bCustomColorsInit = true ; + } + // nascondo qualsiasi tipo di componente + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + + // margini per dimensione del rettangolo preview pickColor + const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog + const int PREVIEW_HEIGHT = 20 ; // altezza del rettangolo + const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima + + // creazione della static preview + HWND hwndPreview = NULL ; + HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i) ; + RECT rcEdit ; GetClientRect( hwndDlg, &rcEdit) ; // coordinate client del dialog + if ( hwndEdit != nullptr && GetWindowRect( hwndEdit, &rcEdit)) { + // converti rcLabel in coordinate client + POINT ptEdit = { rcEdit.left, rcEdit.top } ; + ScreenToClient( hwndDlg, &ptEdit) ; + int x = ptEdit.x ; + int y = ptEdit.y ; + int width = rcEdit.right - rcEdit.left ; + if ( width < PREVIEW_MIN_WIDTH) + width = PREVIEW_MIN_WIDTH ; + hwndPreview = CreateWindowEx( 0, L"STATIC", NULL, + WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER, + x, y, width, PREVIEW_HEIGHT, + hwndDlg, ( HMENU)( IDC_COLOR1 + i), + GetModuleHandle( NULL), NULL) ; + } + // pulizia elementi testuali + if ( hwndPreview) { + SetWindowText( hwndPreview, L"") ; + SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ; + InvalidateRect( hwndPreview, NULL, TRUE) ; + UpdateWindow( hwndPreview) ; + } + s_nType_ML[i] = CTRL_COLOR ; + } + + // --- se Button di selezione + else if ( s_sEdit_ML[i].find( "BT:") == 0) { + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo la Combo + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo la Check + SetDlgItemText( hwndDlg, IDC_BUTTON_ML_1 + i, stringtoW( string{ "N"})) ; // modalità non Selezione + // associo alla casella di testo la funzione di KeyPress su Enter + HWND hEdit = GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i) ; + if ( hEdit != nullptr) + SetWindowSubclass( hEdit, UpdateSelectionModelessDialog, 1, (DWORD_PTR)( IDC_EDIT_ML_1 + i)) ; + s_nType_ML[i] = CTRL_BUTTON ; + } + + // --- se Testo + else { + SetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, stringtoW( s_sEdit_ML[i])) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + s_nType_ML[i] = CTRL_EDIT ; + } + } + // se numero di controllo superiore al massimo, non visualizzo nullo ( in questo caso aggiungere elementi a Dialog in .rc) + else { + // nascondo tutto + ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT_ML_1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; + s_nType[i] = CTRL_NONE ; + } + } + break ; + + case WM_CTLCOLORSTATIC : + { + HDC hdcStatic = ( HDC)wParam ; + HWND hwndCtrl = ( HWND)lParam ; + int ctrlId = GetDlgCtrlID( hwndCtrl) ; + if ( ctrlId >= IDC_COLOR1 && ctrlId <= IDC_COLOR8) { + int idx = ctrlId - IDC_COLOR1 ; + if ( hColorBrush[idx] == NULL) + hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ; + SetBkMode( hdcStatic, OPAQUE) ; + SetBkColor( hdcStatic, selectedColor[idx]) ; + return ( INT_PTR)hColorBrush[idx] ; + } + } + break ; + + case WM_COMMAND : { + int id = LOWORD( wParam) ; + int code = HIWORD( wParam) ; + + // --- se click di un Button di selezione + if ( id >= IDC_BUTTON_ML_1 && id < IDC_BUTTON_ML_1 + MAX_CTRLS_ML) { + int nBtnId = id ; + int nEditId = IDC_EDIT_ML_1 + ( id - IDC_BUTTON_ML_1) ; + // se il bottone premuto è lo stesso, allora termina le selezione degli Ids + if ( nDlgModelessItem == nEditId) { + SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "N"})) ; + nDlgModelessItem = -1 ; + } + // se nuovo buttone premuto + else { + // se esisteva una selezione precedente, questa viene annullata + if ( nDlgModelessItem != -1) { + // recupero il Button di selezione precedente e modifico il suo testo + int nPrevBtnId = IDC_BUTTON_ML_1 + ( nDlgModelessItem - IDC_EDIT_ML_1) ; + SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "N"})) ; + } + // la selezione passa al comando corrente + nDlgModelessItem = nEditId ; + SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "S"})) ; + } + // per semplicità, deseleziono tutto + ExeDeselectAll() ; + ExeDraw() ; + } + // --- se comando di Preview per brush di colori mediante click del mouse + else if ( code == STN_CLICKED && id >= IDC_COLOR1 && id <= IDC_COLOR8) { + int idx = id - IDC_COLOR1 ; + HWND hwndPreview = GetDlgItem( hwndDlg, IDC_COLOR1 + idx) ; + if ( ! hwndPreview) + return TRUE ; + // apertura ChooseColor (usa hwndDlg come owner) + CHOOSECOLOR cc = {} ; + cc.lStructSize = sizeof( cc) ; + cc.hwndOwner = hwndDlg ; + cc.lpCustColors = s_CustomColors ; + cc.rgbResult = selectedColor[idx] ; + cc.Flags = CC_FULLOPEN | CC_RGBINIT ; + if ( ChooseColor( &cc)) { + selectedColor[idx] = cc.rgbResult ; + // salvo nel file Ini i nuovi colori personalizzati + string sIniFile = ExeGetIniFile() ; + if ( ! sIniFile.empty()) { + string sOut = "" ; + for ( int j = 0 ; j < ssize( s_CustomColors) && j < 16 ; ++ j) + sOut += ToString( ( unsigned int)s_CustomColors[j]) + "," ; + sOut.pop_back() ; + WritePrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, sOut.c_str(), sIniFile.c_str()) ; + } + if ( hColorBrush[idx] != NULL) + DeleteObject( hColorBrush[idx]) ; + hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ; + InvalidateRect(hwndPreview, NULL, TRUE) ; + UpdateWindow( hwndPreview) ; + } + return TRUE ; + } + + switch ( LOWORD( wParam)) { + case IDOK_ML : { + // recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) + DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ; + if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) { + + // recupero la CallBack + lua_rawgeti( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ; + // definisco una tabella per tutti i valori Lua da restituire + lua_newtable( ctx->L) ; + + // recupero i valori degli Item + for ( int i = 0 ; i < s_nCtrls_ML ; ++ i) { + AtoWEX<128> wsEdit( "") ; + s_sEdit_ML[i] = "" ; + + switch ( s_nType_ML[i]) { + case CTRL_CHECK : + s_sEdit_ML[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK_ML_1 + i) == BST_CHECKED ? "1" : "0") ; + break ; + case CTRL_COMBO : + if ( GetDlgItemText( hwndDlg, IDC_COMBO_ML_1 + i, LPWSTR( wsEdit), 128) > 0) + s_sEdit_ML[i] = wstrztoA( wsEdit) ; + break ; + case CTRL_EDIT : + if ( GetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, LPWSTR( wsEdit), 128) > 0) + s_sEdit_ML[i] = wstrztoA( wsEdit) ; + break ; + case CTRL_COLOR : + { + COLORREF col = selectedColor[i] ; + BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ; + char buf[16] ; + sprintf_s( buf, sizeof( buf), "%u,%u,%u", r, g, b) ; + s_sEdit_ML[i] = buf ; + } + break ; + case CTRL_BUTTON : + if ( GetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, LPWSTR( wsEdit), 128) > 0) + s_sEdit_ML[i] = wstrztoA( wsEdit) ; + break ; + } + } + + // Ogni valore letto viene inserito all'interno della Table creata in precedenza e passata alla CallBack di lua + int nIndex = 1 ; + for ( const string& sVal : s_sEdit_ML) { + lua_pushstring( ctx->L, sVal.c_str()) ; + lua_rawseti( ctx->L, -2, nIndex ++) ; + } + // chiamo la CallBack + lua_pcall( ctx->L, 1, 0, 0) ; + // libero la memoria + luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ; + delete ctx ; + ctx = nullptr ; + } + + // rimuovo finestra e annullo il contesto + DestroyWindow( hwndDlg) ; + phDlgModeless = nullptr ; + nDlgModelessItem = -1 ; + return TRUE ; + } + [[fallthrough]] ; + case IDCANCEL_ML : { + // pulizia brush colori + for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) { + if ( hColorBrush[i] != NULL) { + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = NULL ; + } + } + // recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo + DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ; + if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) { + luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ; + delete ctx ; + ctx = nullptr ; + } + // rimuovo finestra e annullo il contesto + DestroyWindow( hwndDlg) ; + phDlgModeless = nullptr ; + nDlgModelessItem = -1 ; + return TRUE ; + } + } + } + break ; + case WM_CLOSE : { + // recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo + DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ; + if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) { + luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ; + delete ctx ; + ctx = nullptr ; + } + // rimuovo finestra e annullo il contesto + DestroyWindow( hwndDlg) ; + phDlgModeless = nullptr ; + nDlgModelessItem = -1 ; + return TRUE ; + } + } + return FALSE ; +} + //------------------------------------------------------------------------------- static int LuaDialogBox( lua_State* L) @@ -1546,6 +1966,71 @@ LuaDialogBox( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaDialogBoxModeless( lua_State* L) +{ + // 1 .. 9 parametri : sCaption, { sText, sDefault}, ... + LuaCheckParam( L, 1, s_sCaption_ML) + s_nCtrls_ML = 0 ; + for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) { + STRVECTOR vData ; + if ( LuaGetParam( L, 2 + i, vData) && ssize( vData) >= 2) { + s_sText_ML[i] = Trim( vData[0]) ; + s_sEdit_ML[i] = Trim( vData[1]) ; + ++ s_nCtrls_ML ; + } + else + break ; + } + // se abilitata UI, lancio dialogo + if ( ExeGetEnableUI()) { + // se dialogo già presente, errore ( per ora una sola finestra non modale per volta) + if ( phDlgModeless != nullptr) { + LuaSetParam( L, false) ; + return 1 ; + } + // definisco il contesto per il dialogo + DialogContext* ctx = new DialogContext() ; + if ( ctx != nullptr) { + // recupero la funzione di CallBack per restituire i valori presenti nella DialogBoxModeless + // questa funzione deve essere l'ultimo parametro + int nCallBackRef = LUA_NOREF ; + int nLastPar = lua_gettop( L) ; + if ( lua_isfunction( L, nLastPar)) { + lua_pushvalue( L, nLastPar) ; // copio la funzione + ctx->nCallBackFun = luaL_ref( L, LUA_REGISTRYINDEX) ; // salvo nel registro + ctx->L = L ; // salvo lo State Lua + // lancio dialogo + HWND hTopWnd = ExeGetMainWindowHandle() ; + nDlgModelessItem = -1 ; + phDlgModeless = ( CreateDialogParam( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUADLG_ML), hTopWnd, + (DLGPROC)DialogBoxModelessProc, (LPARAM)ctx)) ; + if ( phDlgModeless != nullptr) { + // se dialogo creato, porto la finestra in primo piano + ShowWindow( phDlgModeless, SW_SHOW) ; + SetForegroundWindow( phDlgModeless) ; + } + else { + delete ctx ; + LuaSetParam( L) ; + } + } + else { + delete ctx ; + LuaSetParam( L) ; + } + } + else + LuaSetParam( L) ; + } + else + LuaSetParam( L) ; + + LuaClearStack( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGeneral( LuaMgr& luaMgr) @@ -1607,6 +2092,6 @@ LuaInstallGeneral( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCreateMutex", LuaCreateMutex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtReleaseMutex", LuaReleaseMutex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ; - + bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBoxModeless", LuaDialogBoxModeless) ; return bOk ; } diff --git a/resource.h b/resource.h index 8891cf6..3cb9bcb 100644 --- a/resource.h +++ b/resource.h @@ -1,10 +1,13 @@ //{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by EgtExecutor.rc +// File di inclusione generato con Microsoft Visual C++. +// Utilizzato da EgtExecutor.rc // #define VS_VERSION_INFO 1 + #define IDD_LUADLG 101 #define IDD_LUASCENE 102 +#define IDD_LUADLG_ML 103 + #define IDC_TEXT1 1001 #define IDC_TEXT2 1002 #define IDC_TEXT3 1003 @@ -13,6 +16,7 @@ #define IDC_TEXT6 1006 #define IDC_TEXT7 1007 #define IDC_TEXT8 1008 + #define IDC_EDIT1 1011 #define IDC_EDIT2 1012 #define IDC_EDIT3 1013 @@ -21,6 +25,7 @@ #define IDC_EDIT6 1016 #define IDC_EDIT7 1017 #define IDC_EDIT8 1018 + #define IDC_COMBO1 1021 #define IDC_COMBO2 1022 #define IDC_COMBO3 1023 @@ -29,6 +34,7 @@ #define IDC_COMBO6 1026 #define IDC_COMBO7 1027 #define IDC_COMBO8 1028 + #define IDC_CHECK1 1031 #define IDC_CHECK2 1032 #define IDC_CHECK3 1033 @@ -37,6 +43,7 @@ #define IDC_CHECK6 1036 #define IDC_CHECK7 1037 #define IDC_CHECK8 1038 + #define IDC_COLOR1 1041 #define IDC_COLOR2 1042 #define IDC_COLOR3 1043 @@ -45,15 +52,64 @@ #define IDC_COLOR6 1046 #define IDC_COLOR7 1047 #define IDC_COLOR8 1048 + #define IDC_PICTURE1 1101 +#define IDC_TEXT_ML_1 2001 +#define IDC_TEXT_ML_2 2002 +#define IDC_TEXT_ML_3 2003 +#define IDC_TEXT_ML_4 2004 +#define IDC_TEXT_ML_5 2005 +#define IDC_TEXT_ML_6 2006 +#define IDC_TEXT_ML_7 2007 +#define IDC_TEXT_ML_8 2008 + +#define IDC_EDIT_ML_1 2011 +#define IDC_EDIT_ML_2 2012 +#define IDC_EDIT_ML_3 2013 +#define IDC_EDIT_ML_4 2014 +#define IDC_EDIT_ML_5 2015 +#define IDC_EDIT_ML_6 2016 +#define IDC_EDIT_ML_7 2017 +#define IDC_EDIT_ML_8 2018 + +#define IDC_COMBO_ML_1 2021 +#define IDC_COMBO_ML_2 2022 +#define IDC_COMBO_ML_3 2023 +#define IDC_COMBO_ML_4 2024 +#define IDC_COMBO_ML_5 2025 +#define IDC_COMBO_ML_6 2026 +#define IDC_COMBO_ML_7 2027 +#define IDC_COMBO_ML_8 2028 + +#define IDC_CHECK_ML_1 2031 +#define IDC_CHECK_ML_2 2032 +#define IDC_CHECK_ML_3 2033 +#define IDC_CHECK_ML_4 2034 +#define IDC_CHECK_ML_5 2035 +#define IDC_CHECK_ML_6 2036 +#define IDC_CHECK_ML_7 2037 +#define IDC_CHECK_ML_8 2038 + +#define IDC_BUTTON_ML_1 2041 +#define IDC_BUTTON_ML_2 2042 +#define IDC_BUTTON_ML_3 2043 +#define IDC_BUTTON_ML_4 2044 +#define IDC_BUTTON_ML_5 2045 +#define IDC_BUTTON_ML_6 2046 +#define IDC_BUTTON_ML_7 2047 +#define IDC_BUTTON_ML_8 2048 + +#define IDOK_ML 2051 +#define IDCANCEL_ML 2052 + // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1030 +#define _APS_NEXT_CONTROL_VALUE 1072 #define _APS_NEXT_SYMED_VALUE 115 #endif #endif From d569c7d8ee33dee907ae6d0ef36332d5045321de Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 19 Jun 2026 09:37:02 +0200 Subject: [PATCH 2/3] EgtExecutor (ModelessDialog) : - aggiunti e aggiornati file persi durante merge. --- EXE_Trimming.cpp | 4 ++-- EgtExecutor.rc | Bin 27404 -> 19652 bytes Lua_Trimming.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index f8141aa..7688b52 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -1435,7 +1435,7 @@ Exe5AxTrimmingModifyToolDir( int nCrvId, int nPathId, int nTrimLayId, const INTV // --------------------------------------------------------------------------- int -ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol) +ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol, int nType) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -1454,7 +1454,7 @@ ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int n Point3d ptE2 ; pSyncEnd->GetEndPoint( ptE2) ; BIPOINT bpIsoEnd( ptS2, ptE2) ; - PtrOwner pNewSurf( RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, dLinTol)) ; + PtrOwner pNewSurf( RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, dLinTol, nType)) ; if ( IsNull( pNewSurf)) return GDB_ID_NULL ; int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pNewSurf)) ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 1c3dd1e7c989f5f0803101cf0af77a13fa2da44b..2091984143131fae29b68207b42954263a259443 100644 GIT binary patch delta 163 zcmeCV#&~2VF-#kYs4<^Sij;3#i6so=>iU@rmGsw|HWa~LWz z1Kwm$HCyZ!Uia8dycXeiHtE9}5;h&125Tt2+|&q}z68vjNDTgYVT%v)QMG_P6x6fNubIG{R-H^Zbr-mqHPT($hoBTrB_G|4Htx`1ri=DX)#vNy{kDNs8tEYvFQ|$Lo~I}& z|HUh$u{^vib-<@m6;_Nvm%%L{hNz{?xFMl==?E=~w*xv$*@!BMY^a07@Vq#ru42ZN zo0q?njjPXh>ET5^!t}ZQ9$pk649`6$Jh?98ufmIb{uu2yz0v(l5fj&y8K=&k6pl66u;a}Noa@~UZ@Wq3o3e>9xSmmj`n+T|zvzu{p z%89!QnoohcQAQLwqJ=6gW~ho2)W6EF;aL|!JtwOek_z>ij44SNT2Wr9ewtSDx``uN zVKv)b8N+FQ7q8nm*HzYy{ZV68R$&Wlj9q4z@Vdax<1c(&;9oJib?1zbdnUZk>XJ?& zQiu0r0be})Ke@bJM~l=ELtW@lEgYS3|GtWmI%2*H9dBlASJESu#Hc4Fs_b?pBT|W< z5AsMwuf%!Tu2hOt5-$MCiMqs5n)3T(Mk0C5 zT|{mYGFD2#aqHYqTb&KO1U%nldJ>Pq44dDQvBva}D3&cGYC3yOcI>Roy>QrpaV>(s zxq2W!e0^Tvu=V*TiQ`OwK6g&HzgQ3BTRuB~j`i6`tBE+gu8qQmvScq$%qjM>+Mx0u DI~Vf{ diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp index 239fe5b..afb8451 100644 --- a/Lua_Trimming.cpp +++ b/Lua_Trimming.cpp @@ -375,8 +375,10 @@ LuaRegolarizeSurfaceLocally( lua_State* L) LuaCheckParam( L, 4, nSyncEndId) double dLinTol ; LuaCheckParam( L, 5, dLinTol) - - int nId = ExeRegolarizeSurfaceLocally( nParentId, nSurfId, nSyncStartId, nSyncEndId, dLinTol) ; + int nType = 0 ; + LuaCheckParam( L, 6, nType) + + int nId = ExeRegolarizeSurfaceLocally( nParentId, nSurfId, nSyncStartId, nSyncEndId, dLinTol, nType) ; LuaSetParam( L, nId) ; return 1 ; } From e9439f04aaa4fed0cd5ecb408900d69fec45156b Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 19 Jun 2026 10:45:31 +0200 Subject: [PATCH 3/3] EgtExecutor (ModeLessDialog) : - prima versione di dialogo non modale. --- EgtExecutor.rc | Bin 19652 -> 26486 bytes LUA_General.cpp | 28 ++++++++++++++-------------- resource.h | 21 ++++++++++----------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 2091984143131fae29b68207b42954263a259443..dafe5c633997435c2161ec4dafa8728db39cf937 100644 GIT binary patch delta 2295 zcmb7Gzi-n}5WcjcG*N?)(i9a07*$Q0(l&PN#7+PeClo{#T0uZ!i#o6&1|+63vLkU5 z15zg#Sbz*nFtJjJjfJB830;^Nxby4zM{#RMPkD)w@B8lEcXu!T_B!)tH}j#iihG?? zsC6bz^x+P4FAytu5Ry z7mI>4z>HvLGhKA6v#+ufs8w?KaA9UyLHi`fl1kX2&kfLNcOVZrI)z#xvgQ*Ng?E!k ziNqZKtprg`BB-c!u+ors7XvaA6j?cvaO52BTn@10xh ztZyy{bUQ?^C7X77MY|-CIhI7W!j|Dn{n~j!aWSP!RDJ58<51u75&W$}m|pq@wObUy z1}TK&#rYq>{)_XkM(p1$<+lD`@bXn!N*U=s}-en{W@m*tc+}vEpmQdN-m*tTQ8O#QHy?Mr@VS zY0QhKN7Qgcl_RP=qRJ6{kf^eqm23EhqFSshIb|K{m!!lmzcku;@@llgH<*JT%k@Mi*Fc!!bvh!tIVS delta 32 ocmex%j`7G$#tmxrleJVgZT=C#!!+4ORBW?Dj33kHUvV`Y0OorQ1^@s6 diff --git a/LUA_General.cpp b/LUA_General.cpp index facb251..5f48984 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -1605,7 +1605,7 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA CheckDlgButton( hwndDlg, IDC_CHECK_ML_1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ; ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo - ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione s_nType_ML[i] = CTRL_CHECK ; } @@ -1635,7 +1635,7 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA SetWindowPos( hwndCBox, NULL, rc.left, rc.top, rc.right - rc.left, nTotalHeight, SWP_NOZORDER) ; ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo CheckBox - ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione s_nType_ML[i] = CTRL_COMBO ; } @@ -1672,7 +1672,7 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check - ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione // margini per dimensione del rettangolo preview pickColor const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog @@ -1709,10 +1709,10 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA } // --- se Button di selezione - else if ( s_sEdit_ML[i].find( "BT:") == 0) { - ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo la Combo - ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo la Check - SetDlgItemText( hwndDlg, IDC_BUTTON_ML_1 + i, stringtoW( string{ "N"})) ; // modalità non Selezione + else if ( s_sEdit_ML[i].find( "BS:") == 0) { + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo la Combo + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo la Check + SetDlgItemText( hwndDlg, IDC_BUTTON_SEL_ML_1 + i, stringtoW( string{ "-"})) ; // modalità non Selezione // associo alla casella di testo la funzione di KeyPress su Enter HWND hEdit = GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i) ; if ( hEdit != nullptr) @@ -1725,7 +1725,7 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA SetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, stringtoW( s_sEdit_ML[i])) ; ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check - ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione s_nType_ML[i] = CTRL_EDIT ; } } @@ -1736,7 +1736,7 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL_ML_1 + i), SW_HIDE) ; s_nType[i] = CTRL_NONE ; } } @@ -1763,12 +1763,12 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA int code = HIWORD( wParam) ; // --- se click di un Button di selezione - if ( id >= IDC_BUTTON_ML_1 && id < IDC_BUTTON_ML_1 + MAX_CTRLS_ML) { + if ( id >= IDC_BUTTON_SEL_ML_1 && id < IDC_BUTTON_SEL_ML_1 + MAX_CTRLS_ML) { int nBtnId = id ; - int nEditId = IDC_EDIT_ML_1 + ( id - IDC_BUTTON_ML_1) ; + int nEditId = IDC_EDIT_ML_1 + ( id - IDC_BUTTON_SEL_ML_1) ; // se il bottone premuto è lo stesso, allora termina le selezione degli Ids if ( nDlgModelessItem == nEditId) { - SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "N"})) ; + SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "-"})) ; nDlgModelessItem = -1 ; } // se nuovo buttone premuto @@ -1776,8 +1776,8 @@ CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARA // se esisteva una selezione precedente, questa viene annullata if ( nDlgModelessItem != -1) { // recupero il Button di selezione precedente e modifico il suo testo - int nPrevBtnId = IDC_BUTTON_ML_1 + ( nDlgModelessItem - IDC_EDIT_ML_1) ; - SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "N"})) ; + int nPrevBtnId = IDC_BUTTON_SEL_ML_1 + ( nDlgModelessItem - IDC_EDIT_ML_1) ; + SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "-"})) ; } // la selezione passa al comando corrente nDlgModelessItem = nEditId ; diff --git a/resource.h b/resource.h index 3cb9bcb..e010631 100644 --- a/resource.h +++ b/resource.h @@ -3,7 +3,6 @@ // Utilizzato da EgtExecutor.rc // #define VS_VERSION_INFO 1 - #define IDD_LUADLG 101 #define IDD_LUASCENE 102 #define IDD_LUADLG_ML 103 @@ -91,14 +90,14 @@ #define IDC_CHECK_ML_7 2037 #define IDC_CHECK_ML_8 2038 -#define IDC_BUTTON_ML_1 2041 -#define IDC_BUTTON_ML_2 2042 -#define IDC_BUTTON_ML_3 2043 -#define IDC_BUTTON_ML_4 2044 -#define IDC_BUTTON_ML_5 2045 -#define IDC_BUTTON_ML_6 2046 -#define IDC_BUTTON_ML_7 2047 -#define IDC_BUTTON_ML_8 2048 +#define IDC_BUTTON_SEL_ML_1 2041 +#define IDC_BUTTON_SEL_ML_2 2042 +#define IDC_BUTTON_SEL_ML_3 2043 +#define IDC_BUTTON_SEL_ML_4 2044 +#define IDC_BUTTON_SEL_ML_5 2045 +#define IDC_BUTTON_SEL_ML_6 2046 +#define IDC_BUTTON_SEL_ML_7 2047 +#define IDC_BUTTON_SEL_ML_8 2048 #define IDOK_ML 2051 #define IDCANCEL_ML 2052 @@ -107,9 +106,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_RESOURCE_VALUE 109 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1072 +#define _APS_NEXT_CONTROL_VALUE 1073 #define _APS_NEXT_SYMED_VALUE 115 #endif #endif