From 8c4603c73675958efc960fbd4bb599a2909d106a Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 16 Jan 2023 14:52:43 +0100 Subject: Source codes --- Examples/WhisperDesktop/Utils/PendingState.cpp | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Examples/WhisperDesktop/Utils/PendingState.cpp (limited to 'Examples/WhisperDesktop/Utils/PendingState.cpp') diff --git a/Examples/WhisperDesktop/Utils/PendingState.cpp b/Examples/WhisperDesktop/Utils/PendingState.cpp new file mode 100644 index 0000000..404ae4e --- /dev/null +++ b/Examples/WhisperDesktop/Utils/PendingState.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" +#include "PendingState.h" + +void PendingState::initialize( std::initializer_list editors, std::initializer_list pending ) +{ + editorsWindows = editors; + wasEnabled.resize( editorsWindows.size() ); + pendingWindows = pending; +} + +void PendingState::setPending( bool nowPending ) +{ + if( nowPending ) + { + for( size_t i = 0; i < editorsWindows.size(); i++ ) + { + BOOL e = IsWindowEnabled( editorsWindows[ i ] ); + if( e ) + { + wasEnabled[ i ] = true; + EnableWindow( editorsWindows[ i ], FALSE ); + } + else + wasEnabled[ i ] = false; + } + } + else + { + for( size_t i = 0; i < editorsWindows.size(); i++ ) + { + if( !wasEnabled[ i ] ) + continue; + EnableWindow( editorsWindows[ i ], TRUE ); + } + } + + const int show = nowPending ? SW_NORMAL : SW_HIDE; + for( HWND w : pendingWindows ) + ::ShowWindow( w, show ); +} \ No newline at end of file -- cgit v1.2.3