summaryrefslogtreecommitdiffstats
path: root/Examples/WhisperDesktop/Utils/PendingState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/WhisperDesktop/Utils/PendingState.cpp')
-rw-r--r--Examples/WhisperDesktop/Utils/PendingState.cpp40
1 files changed, 40 insertions, 0 deletions
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<HWND> editors, std::initializer_list<HWND> 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