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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "resource.h"
#include "ChoiceProperties.h"
#include <mxtk/mx.h>
#include "mdlviewer.h"
static CChoiceParams g_Params;
static void PopulateChoiceList( HWND wnd, CChoiceParams *params )
{
HWND control = GetDlgItem( wnd, IDC_CHOICE );
if ( !control )
return;
SendMessage( control, CB_RESETCONTENT, 0, 0 );
int c = params->m_Choices.Count();
if ( params->m_nSelected == -1 )
params->m_nSelected = 0;
if ( params->m_nSelected >= 0 && params->m_nSelected < c )
{
SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_Choices[ params->m_nSelected ].choice );
}
for ( int i = 0; i < c; i++ )
{
char const *text = params->m_Choices[ i ].choice;
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)text );
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : hwndDlg -
// uMsg -
// wParam -
// lParam -
// Output : static BOOL CALLBACK
//-----------------------------------------------------------------------------
static BOOL CALLBACK ChoicePropertiesDialogProc( 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 );
PopulateChoiceList( hwndDlg, &g_Params );
SetDlgItemText( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt );
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
char selected[ MAX_CHOICE_TEXT_SIZE ];
selected[ 0 ] = 0;
HWND control = GetDlgItem( hwndDlg, IDC_CHOICE );
if ( control )
{
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( selected ), (LPARAM)selected );
}
g_Params.m_nSelected = -1;
int c = g_Params.m_Choices.Count();
for ( int i = 0; i < c; i++ )
{
char const *text = g_Params.m_Choices[ i ].choice;
if ( stricmp( text, selected ) )
{
continue;
}
g_Params.m_nSelected = i;
break;
}
EndDialog( hwndDlg, 1 );
}
break;
case IDCANCEL:
EndDialog( hwndDlg, 0 );
break;
}
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *view -
// *actor -
// Output : int
//-----------------------------------------------------------------------------
int ChoiceProperties( CChoiceParams *params )
{
g_Params = *params;
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
MAKEINTRESOURCE( IDD_CHOICEDIALOG ),
(HWND)g_MDLViewer->getHandle(),
(DLGPROC)ChoicePropertiesDialogProc );
*params = g_Params;
return retval;
}
|