Salut a tous,
Voilà j'ai un petit soucis.
J'ai mon projet en Win32, en Unicode. Je crée ma fenetre, je fais appel à un MainDlgProc pour traiter les msg, je lui demande d'intercepter WM_KEYDOWN et là ! HORREUR !!! je n'y passe pas ! Pas plus avec un WM_CHAR ou même avec un WM_SYSKEYDOWN ... Je ne vois pas d'ou cela peux venir ...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
 
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
	HRESULT hr;
 
	switch( msg ) 
	{
	case WM_INITDIALOG:
		OnInitDialog( hDlg );
		break;
 
	case WM_COMMAND:
		switch( LOWORD(wParam) )
		{
 
		// all open file add a sound in a vector
		case IDC_SOUNDFILE:
			{
				int index = OnOpenEffectFile( hDlg );
				break;
			}
 
		case IDC_MUSICFILE:
			{
				int index = OnOpenMusicFile( hDlg );
				break;
			}
 
		case IDC_DIALOGFILE:
			{
				int index = OnOpenDialogFile( hDlg );
				break;
			}
 
		// all "delete" could verify :
		// - if the number is between 0 and MAXEFFECTS or MAXMUSICS or MAXDIALOGS
		// - if the sound is playing => stop this sound
		// - suppress the sound in the vector
		case IDC_DELETESOUND:
			{
				TCHAR strIndexSound[3] = TEXT("");
				GetDlgItemText( hDlg , IDC_NUMOFSOUND, strIndexSound, 3);
				int index = _tstoi(strIndexSound);
 
				// the number is to hight
				if(index > MAXEFFECTS || index <= 0 || index > vectorSound.size())
				{
					MessageBox( hDlg, L"Error : we can delete this sound.", 
						L"DirectSound Sample", MB_OK | MB_ICONERROR );
					break;
				}
 
				// Ok, here we verify if the sound is playing.
				// WARNING, the index of the sound is in fact index-1 in vector !!!
 
				if(vectorSound[index-1].IsSoundPlaying())
				{
					vectorSound[index-1].Stop();
					vectorSound[index-1].Reset();
				}
 
				// now we can delete this sound.
 
				std::vector<CSound>::iterator i = vectorSound.begin() + index - 1;
				vectorSound.erase(i);
 
				EnableStopUI( hDlg );
				break;
			}
 
		case IDC_DELETEMUSIC:
			{
 
				break;
			}
 
		case IDC_DELETEDIALOG:
			{
				break;
			}
 
		case IDCANCEL:
			EndDialog( hDlg, IDCANCEL );
			break;
 
			// replace by key event
		//case IDC_PLAY:
			// The 'play'/'pause' button was pressed
			//if( FAILED( hr = OnPlaySound( hDlg ) ) )
			//{
			//	DXTRACE_ERR_MSGBOX( TEXT("OnPlaySound"), hr );
			//	MessageBox( hDlg, L"Error playing DirectSound buffer. "
			//		L"Sample will now exit.", L"DirectSound Sample",
			//		MB_OK | MB_ICONERROR );
			//	EndDialog( hDlg, IDABORT );
			//}
			break;
 
		// for the moment, the button "stop" stop all effects, dialogs and musics.
		case IDC_STOP:
			{
				for(std::vector<CSound>::iterator i = vectorSound.begin() ; i != vectorSound.end() ; ++i)
				{
					i->Stop();
					i->Reset();
				}
 
				//for(std::vector<CSound>::iterator i = vectorMusic.begin() ; i != vectorMusic.end() ; ++i)
				//{
				//	i->Stop();
				//	i->Reset();
				//}
 
				//for(std::vector<CSound>::iterator i = vectorDialog.begin() ; i != vectorDialog.end() ; ++i)
				//{
				//	i->Stop();
				//	i->Reset();
				//}
 
				break;
			}
 
		default:
			{
				return FALSE; // Didn't handle message
			}
		}
		break;
 
	case WM_KEYDOWN:
		{
			MessageBox(0,TEXT("Une touche a été appuyée!"),0,0);
			switch(wParam) 
			{
				// vectorSound
			case '&':
				{
					if(vectorSound.size() > 0)
						OnPlaySound( hDlg , 0 );
				}
			case 'é':
				{
					if(vectorSound.size() > 1)
						OnPlaySound( hDlg , 1);
				}
			case '\"':
				{
					if(vectorSound.size() > 2)
						OnPlaySound( hDlg , 2);
				}
			case '\'':
				{
					if(vectorSound.size() > 3)
						OnPlaySound( hDlg , 3);
				}
			case '(':
				{
					if(vectorSound.size() > 4)
						OnPlaySound( hDlg , 4);
				}
			case '-':
				{
					if(vectorSound.size() > 5)
						OnPlaySound( hDlg , 5);
				}
			case 'è':
				{
					if(vectorSound.size() > 6)
						OnPlaySound( hDlg , 6);
				}
			case '_':
				{
					if(vectorSound.size() > 7)
						OnPlaySound( hDlg , 7);
				}
			case 'ç':
				{
					if(vectorSound.size() > 8)
						OnPlaySound( hDlg , 8);
				}
			case 'à':
				{
					if(vectorSound.size() > 9)
						OnPlaySound( hDlg , 9);
				}
				break;
				// vectorMusic
			case 'a':
			case 'b':
			case 'c':
			case 'd':
				{
				}
				break;
				// vectorDialog
			case 'e':
			case 'f':
			case 'g':
			case 'h':
				{
				}
				break;
			default:
				break;
			}
			return 0;
		}
 
	default:
		return FALSE; // Didn't handle message
	}
 
	return TRUE; // Handled message
}
Si quelqu'un avait une idée, je lui en serais tres reconnaissant (j'avais pensé à essayer avec OnKeyDown(..), mais je ne vois pas trop comment ca fonctionne.