bonjour tout le monde, je sui en train de faire un petit programme sous dev-c++, mais je n'arrive pas à récupéré et d'ailleur à modifier au clavier le contenu d'une EditBox.
A mon avis c'est une erreur à la con autour de GetWindowText, mais je ne la trouve pas, si quelqu'un la voit ce serai cool de me la montrer
merci
voila la partie en question
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
//-------------------Box pour la durée d'une opération ------------------------
A mon avis tu ne génères pas l'événement EN_CHANGE mais je n'en suis pas sûr.
Il manque peut être un flag ENM_CHANGE
Bonne chance
__________________________ MXZone 0.2 : AJAX and Web 2.0
Ton code devrait donc marcher !
Donne la totalité du source (entre les balises code) et on trouvera l'erreur.
xm
__________________________ MXZone 0.2 : AJAX and Web 2.0
ok voici la totalité du code, c'est juste un exemple de dev que j'ai modifier avec l'aide de tutoriaux ( je débute en c orienté objet )
Pourl'instant il n'y a que de quoi faire l'interface avec l'utilisateur, mais je mettrais tout le progamme en ligne
( je ne sai pas si un programme de comptage du rythme cardiaque interressera quelqu'un mais il y aura une parti connectio USB qui pourra peut-être intéresser du monde.)
si d'ailleurs vous voyant des trucs améliorables, je prends toutes les remarques avec plaisir
#include <windows.h>
#include<myconio.h>
#include<stdio.h>
#include<stdlib.h>
#include "main.h"
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the classname into a global variable */
char szClassName[] = "programme de comptage du rythme cardiaque";
HINSTANCE hThisInstance;
HWND hWndStaticIntituleDuree;
HWND hWndStaticIntituleIntervalle;
HWND hWndStaticIntituleNbAcquisitions;
HWND hWndEditDuree;
HWND hWndEditIntervalle;
HWND hWndEditNbAcquisitions;
static char szDuree[10];
static int nDuree = 10;
static char szIntervalle[10];
static int nIntervalle = 10;
static char szNbAcquisitions[10];
static int nNbAcquisitions = 10;
//---------ma version de dev-c++ ne prennant pas en compte la fonction itoa,----
//------ j'en ai trouvé une de remplacement ------------------------------------
#define BUFSIZE (sizeof(int) * 8 + 1)
char *itoa(int num, char *buf, int base)
{
int i=2, uarg;
char *tail, *head = buf, tempbuf[BUFSIZE];
if (base > 36 || base < 2)
base = 10;
tail = &tempbuf[BUFSIZE - 1];
*tail-- = '\0';
if (base == 10 && num < 0)
{
*head++ = '-';
uarg = -num;
}
else
uarg = num;
if (uarg)
{
for (i = 1; uarg; ++i)
{
div_t r;
r = div (uarg, base);
*tail-- = (char)(r.rem + ((r.rem > 9) ?
('A' - 10) : '0'));
uarg = r.quot;
}
}
else *tail-- = '0';
memcpy (head, ++tail, i);
return buf;
}
//------------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
HMENU menu;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_WARNING);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
if (!RegisterClassEx (&wincl)) return 0 ;
hwnd = CreateWindowEx(
0,
szClassName,
"Programme de détermination du rythme cardiaque",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
ShowWindow(hwnd, nFunsterStil);
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
SetMenu(hwnd, menu);
while(GetMessage(&messages, NULL, 0, 0))
{
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
//-------------------Box pour la durée d'une opération ------------------------
hWndStaticIntituleDuree = CreateWindowEx(0, "STATIC", "durée : ",
WS_CHILD | WS_VISIBLE | SS_LEFT,
190,30,70,16,hwnd, (HMENU)IDS_STATIC ,
hThisInstance, NULL);
hWndStaticIntituleDuree = CreateWindowEx(0, "STATIC", "min",
WS_CHILD | WS_VISIBLE | SS_LEFT,
335,30,40,16,hwnd, (HMENU)IDS_STATIC ,
hThisInstance, NULL);
hWndEditDuree = CreateWindowEx(0, "EDIT", "",
WS_CHILD | WS_VISIBLE | ES_RIGHT | ES_NUMBER,
245,30,90,16,hwnd, (HMENU)IDE_DUREE ,
hThisInstance, NULL);
//On affiche la durée par défaut (10)
*itoa(nDuree, szDuree, 10 );
SetWindowText(hWndEditDuree,szDuree );
SetFocus( hWndEditDuree);
//-------------------Box pour l'intervalle entre deux opérations ---------------
hWndStaticIntituleIntervalle = CreateWindowEx(0, "STATIC", "intervalle : ",
WS_CHILD | WS_VISIBLE | SS_LEFT,
170,90,90,16,hwnd, (HMENU)IDS_STATIC ,
hThisInstance, NULL);
hWndStaticIntituleIntervalle = CreateWindowEx(0, "STATIC", "min",
WS_CHILD | WS_VISIBLE | SS_LEFT,
335,90,40,16,hwnd, (HMENU)IDS_STATIC ,
hThisInstance, NULL);
hWndEditIntervalle = CreateWindowEx(0, "EDIT", "",
WS_CHILD | WS_VISIBLE | ES_RIGHT | ES_NUMBER,
245,90,90,16,hwnd, (HMENU)IDE_INTERVALLE ,
hThisInstance, NULL);
//On affiche l'intervalle par défaut (10)
*itoa(nIntervalle, szIntervalle, 10 );
SetWindowText(hWndEditIntervalle, szIntervalle);
SetFocus( hWndEditIntervalle);
//-------------------Box pour le nombre d'opérations ------------------------
hWndStaticIntituleNbAcquisitions = CreateWindowEx(0, "STATIC", "nb d'acquisitions : ",
WS_CHILD | WS_VISIBLE | SS_LEFT,
165,150,130,16,hwnd, (HMENU)IDS_STATIC ,
hThisInstance, NULL);
hWndEditNbAcquisitions = CreateWindowEx(0, "EDIT", "",
WS_CHILD | WS_VISIBLE | ES_RIGHT | ES_NUMBER,
295,150,40,16,hwnd, (HMENU)IDE_ACQUISITIONS ,
hThisInstance, NULL);
//On affiche le nombre d'acquisitions par défaut (10)
*itoa(nNbAcquisitions, szNbAcquisitions, 10 );
SetWindowText(hWndEditNbAcquisitions, szNbAcquisitions);
SetFocus( hWndEditNbAcquisitions);
} //----------fin WM_CREATE --------------------------------------------
case WM_COMMAND :
{
switch(LOWORD(wParam))
{case IDE_DUREE :
if (HIWORD(wParam) == EN_CHANGE)
{
GetWindowText(hWndEditDuree, szDuree,9);
nDuree = atoi(szDuree);
// Dépassement de saisie dans l'EDIT
if(nDuree >= 101)
{
MessageBox(hwnd,"Durée maximum : 100","Info",MB_OK);
nDuree = 100;
*itoa( nDuree, szDuree,10);
SetWindowText(hWndEditDuree,szDuree);
}
}
break;
case IDM_FILENEW:
case IDM_FILESAVE:
MessageBox( hwnd, (LPSTR) "...",
(LPSTR) szClassName,
MB_ICONINFORMATION | MB_OK );
return 0;
case IDM_HELPHELP:
WinHelp( hwnd, (LPSTR) "HELPFILE.HLP",
HELP_HELPONHELP, 0L );
return 0;
case IDM_FILEEXIT:
SendMessage( hwnd, WM_CLOSE, 0, 0L );
return 0;
case IDM_HELPABOUT:
MessageBox (NULL, "About..." , "", 1);
return 0;
}
break;
} //----------fin de WM_COMMAND ---------------------------------------
case WM_CLOSE:
{
int nQuit = MessageBox(hwnd, "Vous voulez réellement quitter",
"information", MB_YESNO | MB_ICONQUESTION);
if(nQuit == IDNO) {return 0;}
DestroyWindow( hwnd );
break;
}
case WM_DESTROY:
PostQuitMessage (0);
return 0;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
} // --------------fin de Window Procedure -------------------------------------
Ton erreur semble provenir de ta boucle de traitement des messages il faut utiliser TranslateMessage avant d'utiliser DispatchMessage
voilà le bout de code corrigé