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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "resource.h"
#include "MultipleRequest.h"
#include "workspacemanager.h"
static CMultipleParams g_Params;
//-----------------------------------------------------------------------------
// Purpose:
// Input : hwndDlg -
// uMsg -
// wParam -
// lParam -
// Output : static BOOL CALLBACK
//-----------------------------------------------------------------------------
static BOOL CALLBACK MultipleRequestDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg)
{
case WM_INITDIALOG:
// Insert code here to put the string (to find and replace with)
// into the edit controls.
// ...
{
g_Params.PositionSelf( hwndDlg );
SetDlgItemText( hwndDlg, IDC_PROMPT, g_Params.m_szPrompt );
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
SetFocus( GetDlgItem( hwndDlg, IDC_INPUTSTRING ) );
SendMessage( GetDlgItem( hwndDlg, IDC_INPUTSTRING ), EM_SETSEL, 0, MAKELONG(0, 0xffff) );
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_YESALL:
EndDialog( hwndDlg, CMultipleParams::YES_ALL );
break;
case IDC_YES:
EndDialog( hwndDlg, CMultipleParams::YES );
break;
case IDC_NOSINGLE:
EndDialog( hwndDlg, CMultipleParams::NO );
break;
case IDC_NOALL:
EndDialog( hwndDlg, CMultipleParams::NO_ALL );
break;
//case IDCANCEL:
// EndDialog( hwndDlg, CMultipleParams::CANCEL );
// break;
}
return TRUE;
}
return FALSE;
}
static int g_MRContext = 1;
static int g_MRCurrentContext;
static int g_MRLastResult = -1;
void MultipleRequestChangeContext()
{
++g_MRContext;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *view -
// *actor -
// Output : int
//-----------------------------------------------------------------------------
int _MultipleRequest( CMultipleParams *params )
{
int retval = -1;
if ( g_MRCurrentContext == g_MRContext &&
g_MRLastResult != -1 )
{
if ( g_MRLastResult == CMultipleParams::YES_ALL )
{
retval = 0;
}
if ( g_MRLastResult == CMultipleParams::NO_ALL )
{
retval = 1;
}
}
if ( retval == -1 )
{
g_Params = *params;
retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
MAKEINTRESOURCE( IDD_MULTIPLEQUESTION ),
(HWND)GetWorkspaceManager()->getHandle(),
(DLGPROC)MultipleRequestDialogProc );
*params = g_Params;
}
g_MRCurrentContext = g_MRContext;
g_MRLastResult = retval;
switch ( retval )
{
case CMultipleParams::YES_ALL:
case CMultipleParams::YES:
return 0;
case CMultipleParams::NO_ALL:
case CMultipleParams::NO:
return 1;
default:
case CMultipleParams::CANCEL:
return 2;
}
Assert( 0 );
return 1;
}
int MultipleRequest( char const *prompt )
{
CMultipleParams params;
memset( ¶ms, 0, sizeof( params ) );
Q_strcpy( params.m_szDialogTitle, g_appTitle );
Q_strncpy( params.m_szPrompt, prompt, sizeof( params.m_szPrompt ) );
return _MultipleRequest( ¶ms );
}
|