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 ???
#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;
}
Code:
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 ...
http://www.realtuning.online.fr