Slt à tous,

Voilà j'ai un code que j'ai fait, et normalement si on cliques sur les boutons, ça lance la fonction Encode() ou Decode() en fonction du bouton cliqué ...


En revanche, le code ne fonctionne pas, j'arrive par contre à gérer les clics sur les boutons sur la fenêtre, sur les boutons aussi (mais pas sur un en particulier) ...


Pouvez-vous m'aider à trouver l'erreur svp ???

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
#include "windows.h"



#define IDC_EDIT_SRC_FILE      0x01
#define IDC_EDIT_DEST_FILE     0x02
#define IDC_BUTTON_ENCODE      0x03
#define IDC_BUTTON_DECODE      0x04

static HWND hEdit_Src_File = NULL; 
static HWND hEdit_Dest_File = NULL; 
static HWND hButton_Src_File = NULL; 
static HWND hButton_Dest_File = NULL; 



 HWND hWnd;
 HINSTANCE hInst;



int Encode()
{
	MessageBox(hWnd, "TEST", "TEST", MB_OK);
	return 0;
}

int Decode()
{
	MessageBox(hWnd, "TEST2", "TEST2", MB_OK);
	return 0;
}



LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) 
{
	switch(message) 
	{
		case WM_COMMAND :
			if ((LOWORD(wParam) == IDC_BUTTON_ENCODE) && (HIWORD(wParam) == BN_CLICKED))
			{
				Encode();
			}
			else if ((LOWORD(wParam) == IDC_BUTTON_DECODE) && (HIWORD(wParam) == BN_CLICKED))
			{
				Decode();
			}
		break;

		case WM_CREATE : 
			 
			hEdit_Src_File = CreateWindow( "EDIT", "", 
			WS_CHILD | WS_VISIBLE | 
			ES_LEFT | WS_BORDER, 
			20, 8, 100, 20, 
			hWnd, 
			NULL, 
			hInst, NULL ); 

			hEdit_Dest_File = CreateWindow( "EDIT", "", 
			WS_CHILD | WS_VISIBLE | 
			ES_LEFT | WS_BORDER, 
			20, 30, 100, 20, 
			hWnd, 
			NULL, 
			hInst, NULL ); 

			hButton_Src_File = CreateWindow( "BUTTON", "Encoder", 
			WS_CHILD | WS_VISIBLE | 
			ES_LEFT | WS_BORDER, 
			20, 50, 100, 20, 
			hWnd, 
			NULL, 
			hInst, NULL ); 

			hButton_Dest_File = CreateWindow( "BUTTON", "Décoder", 
			WS_CHILD | WS_VISIBLE | 
			ES_LEFT | WS_BORDER, 
			140, 50, 100, 20, 
			hWnd, 
			NULL, 
			hInst, NULL );

			break;
			 
		case WM_DESTROY : 
			 
			 PostQuitMessage(0);
			 
			 break;

		case WM_PAINT :
		{
			
			PAINTSTRUCT PaintStruct; 
			
			HDC PaintDC=BeginPaint( hWnd, &PaintStruct ); 
			
			EndPaint( hWnd, &PaintStruct );
		}
		break;
	}
	return DefWindowProc( hWnd, message, wParam, lParam );
}							


			
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpszCmpParam,int nCmdShow) 
{
	WNDCLASS W;
	HWND hWnd;
	LPSTR Name = "Fenêtre Windows";
	MSG msg;
    
	memset( &W, 0, sizeof(WNDCLASS) );

	W.style = CS_HREDRAW | CS_VREDRAW;
	W.hInstance = hInst;
	W.lpszClassName = Name;
	W.hbrBackground =(HBRUSH) COLOR_WINDOW;
	W.lpfnWndProc = WndProc;

	RegisterClass( &W );

	hWnd = CreateWindowEx( 0, Name, Name, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, 0, 0, 300, 300, 
		NULL, NULL, hInst, NULL ); 

	ShowWindow( hWnd, nCmdShow ); 
	UpdateWindow( hWnd );



	
	while( GetMessage( &msg, NULL, 0, 0) ) 
	{
		TranslateMessage( &msg ); 
		DispatchMessage( &msg );
	}
	return msg.wParam; 

}

@+ Merci d'avance ...