From 941aa1287a871f8abc40f59777063d0912771d65 Mon Sep 17 00:00:00 2001 From: Paravis Date: Sun, 8 Nov 2026 23:37:35 +0300 Subject: [PATCH] Make dialogs modal and topmost --- README.md | 2 ++ src/boot.cpp | 9 ++++++++- src/main.cpp | 13 ++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 632498c..3ea7d0b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ build\Release\Change_BootLoader.exe устанавливаемого загрузчика остаётся чуть ярче. - Повторный запуск запрещён: второй экземпляр активирует уже открытое окно и сразу завершается. +- Все предупреждения — модальные: блокируют главное окно и показываются + поверх него. - Отладочный лог по умолчанию выключен. `PARAVIS_DEBUG_LOG=1` включает запись в `%TEMP%\cbl_cpp_debug.log`. - Действие «GRUB2 Legacy» использует те же команды bootice `/sectors`, что и diff --git a/src/boot.cpp b/src/boot.cpp index 0e84452..5d6e5f6 100644 --- a/src/boot.cpp +++ b/src/boot.cpp @@ -7,7 +7,14 @@ void App::ShowMessage(const std::wstring& text, UINT flags) { bool previous = modal; modal = true; - MessageBoxW(hwnd, text.c_str(), L"Change BootLoader", flags); + EnableWindow(hwnd, FALSE); + InvalidateRect(hwnd, nullptr, FALSE); + UpdateWindow(hwnd); + SetForegroundWindow(hwnd); + MessageBoxW(hwnd, text.c_str(), L"Change BootLoader", + flags | MB_SETFOREGROUND | MB_TOPMOST); + EnableWindow(hwnd, TRUE); + SetForegroundWindow(hwnd); modal = previous; InvalidateRect(hwnd, nullptr, FALSE); } diff --git a/src/main.cpp b/src/main.cpp index cc76f5c..1132f19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -258,6 +258,10 @@ void App::Paint(HDC dc) border = ColorFromHex(CLR_BUSY_BORDER); text = ColorFromHex(CLR_BUSY_TEXT); } + } else if (modal) { + background = ColorFromHex(CLR_BUSY_BG); + border = ColorFromHex(CLR_BUSY_BORDER); + text = ColorFromHex(CLR_BUSY_TEXT); } FillRectColor(memory, x - 1, y - 1, bw + 2, bh + 2, border); @@ -386,7 +390,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int) SetForegroundWindow(existing); } else { MessageBoxW(nullptr, L"Change BootLoader уже запущен.", - kWindowTitle, MB_ICONINFORMATION | MB_OK); + kWindowTitle, + MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); } CloseHandle(instanceMutex); return 0; @@ -398,7 +403,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int) std::wstring exeDir = GetExeDir(); if (exeDir.size() < 2 || exeDir[1] != L':') { MessageBoxW(nullptr, L"Не удалось определить диск установщика.", - kWindowTitle, MB_ICONERROR | MB_OK); + kWindowTitle, + MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); return 1; } @@ -413,7 +419,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int) if (!FileExists(app.bootice) || !FileExists(app.boot + L"\\NOT.DEL")) { std::wstring text = L"Этот диск не является сборкой Paravis " L"(нет bootice.exe или NOT.DEL):\r\n" + app.disk; - MessageBoxW(nullptr, text.c_str(), kWindowTitle, MB_ICONERROR | MB_OK); + MessageBoxW(nullptr, text.c_str(), kWindowTitle, + MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); return 0; }