Api + chaines de caractères, concaténation..

Résolu
cs_hoGan Messages postés 20 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 7 décembre 2005 - 1 nov. 2005 à 20:07
cs_hoGan Messages postés 20 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 7 décembre 2005 - 1 nov. 2005 à 23:58
Bonjour,

j'ai un problème lorsque je veux convertir un char en string afin de
procéder à une concaténation (dans le cadre d'une fenêtre api). Le code
suivant ne fonctionne pas, et indique comme erreur "crosses
initialization of `std::string bind' "





#include <string>

#define ID_MAIN_BOUTON 001

using namespace std;

HWND main_list; //handle d'un combobox

HWND edit1; //handle d'un edit

...

...

...

case WM_COMMAND :

switch(LOWORD(wParam))


{




case ID_MAIN_BOUTON :


char texte[50];


GetWindowText(main_list, texte, 50);


string bind;


bind = texte;


bind = bind + "huh";


SetWindowText(edit1,bind.c_str());



Merci

3 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
1 nov. 2005 à 20:54
case ID_MAIN_BOUTON:
{
int n;
char texte[60]: // MULTIPLE DE 4
n = GetWindowText(main_list, texte, 50);
strcpy(texte + n, "huh");
SetWindowText(edit1, texte);
}

ciao...
http://dev.winsysdev.com
BruNews, MVP VC++
3
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
1 nov. 2005 à 20:25
Essaie de déclarer le string en dehors du switch. Je ne vois pas d'autre problème (sinon rajoute des accolades)
0
cs_hoGan Messages postés 20 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 7 décembre 2005
1 nov. 2005 à 23:58
OK BruNews, ça fonctionne ^^

merci beaucoup
0
Rejoignez-nous