IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VC++ .NET Discussion :

WM_KEYDOWN non intercepté


Sujet :

VC++ .NET

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    74
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 74
    Par défaut WM_KEYDOWN non intercepté
    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.

  2. #2
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 392
    Par défaut
    C'est intercepté par le traitement des boîtes de dialogue (Fonction IsDialogMessage(), sans doute appelée dans des fonctions comme DialogBox()).

    Si tu veux que WM_KEYDOWN passe, tu vas devoir renoncer à la fonction DialogBox(), et utiliser à la place CreateDialog() et une boucle de message SANS IsDialogMessage().
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

Discussions similaires

  1. [Selenium Grid] Tests non "interceptés" par les RC
    Par padawan31 dans le forum Test
    Réponses: 0
    Dernier message: 18/03/2011, 10h07
  2. SQL9010 non intercepté
    Par Ferene dans le forum DB2
    Réponses: 3
    Dernier message: 07/05/2009, 12h04
  3. Exception non intercepté
    Par uriotcea dans le forum C++
    Réponses: 5
    Dernier message: 26/05/2008, 13h06
  4. [2.0] Problème évènement non intercepté
    Par luimême dans le forum ASP.NET
    Réponses: 2
    Dernier message: 06/11/2007, 16h59
  5. 'undefined' non interceptable sur 'eval' ?
    Par Johnny Ryall dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 29/06/2005, 11h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo