Win32: pb et question

o0Leo0o Messages postés 116 Date d'inscription samedi 19 juin 2004 Statut Membre Dernière intervention 20 août 2005 - 26 août 2004 à 16:47
magic_Nono Messages postés 1878 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 16 mars 2011 - 27 août 2004 à 17:23
Voila, donc, en premier, je voulasi vous demander...
Dans une boite de dialogue, si j'utilise la commande while, le programme plante.

C'est normal?

Et en second, je me demande comment écrire dans espace de texte multiligne:
Je m'explique, si j'ai ce morceau de code:

SetDlgItemText(hwnd,IDC_NAME,"qqchose");

"qqchose" s'affiche bien dans la zone de texte, en revanche, si j'ai:
SetDlgItemText(hwnd,IDC_NAME,"qqchose");
SetDlgItemText(hwnd,IDC_NAME,"qqchosedautre");

"qqchosedautre" sera affiché dans la zone de texte, mais "qqchose" n'y sera pas.

J'ai donc essayé de ctte manière:
#define qqchose "qqchose\n"

SetDlgItemText(hwnd,IDC_NAME,qqchose);
SetDlgItemText(hwnd,IDC_NAME,"qqchosedautre");

Toujours le même problème, à votre avis, la commande que j'utilise n'est pas bonne ou alors, ce que je veux faire n'est pas adapté aux boîtes de dialogue?

6 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 août 2004 à 17:17
SetDlgItemText ou SetWindowText remplace texte existant par celui indique.
Utilise SendMessage(hedit, EM_REPLACESEL, 0, (long) sztxt);
exemple ici:
http://www.cppfrance.com/code.aspx?ID=25597

while ne fait rien planter, son mauvais emploi oui.

ciao...
BruNews, Admin CS, MVP VC++
0
o0Leo0o Messages postés 116 Date d'inscription samedi 19 juin 2004 Statut Membre Dernière intervention 20 août 2005
26 août 2004 à 17:52
Ok merci, jvais revoir mes cours sur while alors :p

Hs aux admins CS:
Super idée que de donner la possibilitée aux utilisateurs de consulter les fichiers en ligne.
0
magic_Nono Messages postés 1878 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 16 mars 2011
27 août 2004 à 10:57
Dans une boite de dialogue, si j'utilise la commande while, le programme plante.

C'est normal? => NON
tu doit avoir des allocations ou qqch comme ça....

sinon, parfaitement ok avec BruNews

++

Magic Nono: l'informagicien! 8-)
0
o0Leo0o Messages postés 116 Date d'inscription samedi 19 juin 2004 Statut Membre Dernière intervention 20 août 2005
27 août 2004 à 16:46
Mode boulet: ON

Voila mon code cpp:

#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "resource.h"
#include "aw.h"

#define version					"0.0.0.1"
#define connect0				"Connection en cours...\n"
#define connect1				"Connecté!"
#define proprio					1

HINSTANCE  hInst   = NULL;   
HWND	   hwnd    = NULL;
WNDCLASS   fenetre;
HINSTANCE hinst;
HWND hedname;
HWND hdlg;
HWND hWnd;

char nom[50];
char pass[50];
char univers[50];
char monde[50];

/* Declarations*/
char sortie[11];

BOOL OnCommand(UINT id, HWND hwnd);

HANDLE hIcon; // déclaration du handle de l'icône

LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);

LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{return (DefWindowProc(hwnd, msg, wparam, lparam));} 

LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  
{

switch(msg)
{
case WM_INITDIALOG:
        SendMessage(GetDlgItem(hWnd, IDC_MESSAGE), LB_ADDSTRING, NULL, (LPARAM)(LPCSTR) connect0);
SetDlgItemText(hwnd,IDC_VERSION,version);
    	GetPrivateProfileString("BOT","nom",NULL,nom,sizeof(nom),".\\config.ini");
SetDlgItemText(hwnd,IDC_NAME,nom);
    	GetPrivateProfileString("BOT","pass",NULL,pass,sizeof(pass),".\\config.ini");
    	GetPrivateProfileString("BOT","univers",NULL,univers,sizeof(univers),".\\config.ini");
SetDlgItemText(hwnd,IDC_UNI,univers);
    	GetPrivateProfileString("BOT","monde",NULL,monde,sizeof(monde),".\\config.ini");
SetDlgItemText(hwnd,IDC_MONDE,monde);
/* Permet de cacher ID_CHECKINIENRE*/
EnableWindow(GetDlgItem(hwnd,ID_CHECKINIENRE),FALSE);
break;

case WM_COMMAND: 
{                                                       
OnCommand(LOWORD(wParam), hwnd);

switch(LOWORD(wParam))
{
case WM_DESTROY: 
{
EndDialog(hwnd, FALSE);
break;
}
}
break;
}
        default: 
return FALSE; 
     }
     return TRUE; 
}

int WINAPI WinMain(
     HINSTANCE hInstance,
     HINSTANCE hPrevInst,
     LPSTR lpCmdLine,
     int nCmdShow)

{
fenetre.style			= CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
fenetre.lpfnWndProc		= WindowProc;
fenetre.cbClsExtra		= 0;
fenetre.cbWndExtra		= 0;
fenetre.hInstance		= hInstance;
fenetre.hIcon			= LoadIcon(NULL, IDI_EXCLAMATION);
fenetre.hCursor			= LoadCursor(NULL, IDC_ARROW);
fenetre.hbrBackground	= (struct HBRUSH__ *)GetStockObject(WHITE_BRUSH);
fenetre.lpszMenuName	= NULL;
fenetre.lpszClassName	= "EX-INI";

if (!RegisterClass(&fenetre)) return(0);
hInst = hInstance; 

// Active la boîte de dialogue
DialogBox(hInst, MAKEINTRESOURCE(IDD_MENU), NULL, ( DLGPROC ) DlgProc);

    return (0);
}

BOOL OnCommand(UINT id, HWND hwnd) // fonction gérant le menu
{

switch(id)
{
case ID_QUIT:
EndDialog(hwnd,FALSE);
return 0;

      case ID_PARTIR:
         EndDialog(hwnd,0);
         return TRUE;

  case ID_CONNECT:
 int rc;
char msg[256];
if (rc = aw_init (AW_BUILD)) {
    MessageBox(hwnd,"Impossible d'initialiser l'API","Erreur",MB_OK);
    exit (1);
    }
if (rc = aw_create (univers, 0, 0)) {    MessageBox(hwnd,"Impossible de se connecter à l'univers!","Erreur!",MB_OK);}  
aw_string_set (AW_LOGIN_NAME, nom);
aw_int_set (AW_LOGIN_OWNER, proprio);
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, pass);
aw_string_set (AW_LOGIN_APPLICATION, "Eole");
if (rc = aw_login ())    MessageBox(hwnd,"Impossible de s'identifier!","Erreur",MB_OK);
if (rc = aw_enter (monde)) {    MessageBox(hwnd,"Impossible d'entrer dans le monde spécifié","Erreur",MB_OK);}
aw_int_set (AW_MY_X, 0);
aw_int_set (AW_MY_Z, 0);
aw_int_set (AW_MY_YAW, 0);
if (rc = aw_state_change ()) {    MessageBox(hwnd,"Impossible de se localiser dans le monde spécifié","Erreur",MB_OK);}
printf ("%s\n",aw_string(AW_WORLD_WELCOME_MESSAGE));
while (!aw_wait(-1))
aw_destroy ();
aw_term ();
return TRUE;

  case TEST:

return 0;
}
}


Donc avec ça, le message qui devrait s'afficher ne s'affiche pas :(

Vous voyez mon erreur?
(j'ai vérifié ressource.h pas d'erreur apparante).
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
27 août 2004 à 16:55
if(a = b) EST UNE AFFECTATION ET NON UN TEST.
if(a == b) est un test.

ciao...
BruNews, Admin CS, MVP VC++
0
magic_Nono Messages postés 1878 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 16 mars 2011
27 août 2004 à 17:23
bien vu

Magic Nono: l'informagicien! 8-)
0
Rejoignez-nous