summaryrefslogtreecommitdiffstats
path: root/Examples/WhisperDesktop/Utils/PendingState.cpp
blob: 404ae4e6634dd572aa5d830c01667de490f82c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 );
}