RECHERCHER :
COMMUNAUTE MP
Identifiez vous ...
Devenir Membre
J'ai oublié mon MDP
DOMAINE MP
Bavardages
Langages Généraux
Langages Web
Langages DotNet
Autres langages
Dev. Jeux Video
Sécurité
Sys. Exploitation
Graphismes
Logiciels
Réseaux
Bases de données
Méthodologies
Emplois High-tech
Aide juridique
Articles juridiques
FORUM
Index des forums
Ajouter un sujet
Rechercher sujet
Contact Responsable
Devenir modérateur
CHAT MP IRC
Votre pseudo ...
Serv: irc.irc-land.org
Chan: #MoteurProg
PARTICIPER
Plus de 3500 emplois.
Rechercher un job
Déposez votre CV
Emplois High-tech

Visiteur MP

 GetWindowText

Forum : C++ - CONSOLE
Sous Catégorie : Console
Type du sujet : Sujet Normale
FAQ : FAQ C++ - CONSOLE

SUIVI DES SUJETS PAR MAIL

SUIVI PAR MAIL INACTIF

RESOLUTION DU SUJET SUJET RESOLU
BLOQUAGE DU SUJET SUJET ACTIF
APPARTENANCE A LA FAQ N'APPARTIENT PAS A LA FAQ


PAGE : [1]

POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

FORUM C++ - CONSOLE

PREMIERE PAGE

PAGE PRECEDENTE

Page précedente

Page suivante

PAGE SUIVANTE

DERNIERE PAGE
gustave
Nouveau membre
Inscrit : 13/04/2005
Messages : 15
Message
#61461
Posté le 26/04/05 à 12:06
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 Smiley
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 ------------------------

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 hWndEditMontant
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 -------------------------------------

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Publicité
Inscrit : X
Messages : X
Message
#Aucun

HAUT DE PAGE

  

merrheim
Membre du club
Chef de projet(s) :
- MXClass

Inscrit : 16/12/2004
Messages : 516
Message
#61465
Posté le 26/04/05 à 12:40
Tu sembles récupérer et afficher correctement les données dans tes EDIT
Chez moi le bout de code suivant fonctionnne !

HWND hWndEditDuree=CreateWindowEx(0,"EDIT","",WS_CHILD | WS_VISIBLE | ES_RIGHT | ES_NUMBER, 198,75,50,20,hWnd, (HMENU)ID_EDIT1,hInstance,NULL); int nDuree=10; char szDuree[10]; itoa(nDuree,szDuree,10); SetWindowText(hWndEditDuree,szDuree ); SetFocus( hWndEditDuree); GetWindowText(hWndEditDuree, szDuree,9); nDuree = atoi(szDuree)+1000; itoa(nDuree,szDuree,10); SetWindowText(hWndEditDuree,szDuree );

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
Smiley
__________________________
MXZone 0.2 : AJAX and Web 2.0

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

merrheim
Membre du club
Chef de projet(s) :
- MXClass

Inscrit : 16/12/2004
Messages : 516
Message
#61471
Posté le 26/04/05 à 13:20
Non le message EN_CHANGE est bien généré voilà un programme qui marche et oblige un édit à être inférieur à 100

#include <windows.h> #include <stdio.h> #define ID_DUREE 500 int nDuree=10; char szDuree[10]; HINSTANCE hInst; HWND hWndEditDuree,hlabel; HWND hWnd; LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_COMMAND : switch(LOWORD(wParam)) { case ID_DUREE : if (HIWORD(wParam) == EN_CHANGE) { GetWindowText(hWndEditDuree, szDuree,9); nDuree = atoi(szDuree); if(nDuree >= 101) { MessageBox(hwnd,"Durée maximum : 100","Info",MB_OK); nDuree = 100; itoa( nDuree, szDuree,10); SetWindowText(hWndEditDuree,szDuree); } } break; } } return DefWindowProc(hwnd, message, wParam, lParam); } void wndclassInit(WNDCLASS *WndClass, HINSTANCE hInst) { WndClass->style = 0; WndClass->lpfnWndProc = WindowProcedure; WndClass->cbClsExtra = 0; WndClass->cbWndExtra = 0; WndClass->hInstance = hInst; WndClass->hCursor = LoadCursor(0, IDC_ARROW); WndClass->lpszMenuName = 0; WndClass->hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); WndClass->hIcon = NULL; WndClass->lpszClassName = "ESSAI"; } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR cmdParam, int cmdShow) { WNDCLASS wndClass; MSG msg; int status; hInst = hInstance; wndclassInit(&wndClass, hInst); RegisterClass(&wndClass); hWnd = CreateWindowEx(0,"ESSAI", "", WS_OVERLAPPED|WS_MINIMIZEBOX|WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, NULL, NULL, hInst, NULL); hWndEditDuree=CreateWindowEx(0,"EDIT","",WS_CHILD | WS_VISIBLE | ES_RIGHT | ES_NUMBER, 198,75,50,20,hWnd, (HMENU)ID_DUREE,hInstance,NULL); nDuree=10; itoa(nDuree,szDuree,10); SetWindowText(hWndEditDuree,szDuree ); SetFocus( hWndEditDuree); ShowWindow(hWnd,cmdShow); while ((status = GetMessage(&msg, NULL, 0, 0))) { if (status == -1) return -1; TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }

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

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

gustave
Nouveau membre
Inscrit : 13/04/2005
Messages : 15
Message
#61477
Posté le 26/04/05 à 14:11
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 Smiley )

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
Smiley


#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 -------------------------------------

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

merrheim
Membre du club
Chef de projet(s) :
- MXClass

Inscrit : 16/12/2004
Messages : 516
Message
#61532
Posté le 26/04/05 à 19:35
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é

while(GetMessage(&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); }

a+
bon travail
__________________________
MXZone 0.2 : AJAX and Web 2.0

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

gustave
Nouveau membre
Inscrit : 13/04/2005
Messages : 15
Message
#61575
Posté le 27/04/05 à 09:04
merci beaucoup ! Smiley
c'est bien ça, ça c'est une journée qui commence bien :P:

encore merci @+

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 
POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

PREMIERE PAGE

PAGE PRECEDENTE Page précédente

Page suivante

PAGE SUIVANTE DERNIERE PAGE

FORUM C++ - CONSOLE



    PAGE : [1]



.: Site Web développé par Julien Pichot et l'équipe MPWG avec www.evolvia-web.com :.