IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Discussion :

api windows en langage c


Sujet :

Windows

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Août 2007
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 13
    Par défaut api windows en langage c
    j'ai une 1 ere fennetre pour identifiacation c a dire entre le mot de passe et je vendredi avoir un truc pour lorcque je valide mon mot passe le fennetre d'identification dispare et une nouvelle fennetre apparaitre ,


    je connait le truc de creatwind mais je cherche le stype qui permet de rendre
    apres en click sur valide ... la 1 ere fennetre dspari sur mon code le fennetre d'identification reste .


    vooila mon code complie

    code c

    main.c
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    #include "config.h"
    
    /*******************************************************************************/
    int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        MSG msg;
        WNDCLASS wc;
    
    	HMENU hMenu,hSMQuit, hSMAproy;//declaration des menu
    
        wc.style = 0;
        wc.lpfnWndProc = Proc_Win_Main;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = hinstance;
        wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
        wc.lpszMenuName =  NULL;
        wc.lpszClassName = "MainWinClass";
    
    
        if(!RegisterClass(&wc)) return FALSE;
    	
    	//sous Menu Quit
    	hSMQuit = CreateMenu();
        AppendMenu(hSMQuit, MF_STRING, IDM_QUIT, "Quitter");
    	
    	//sous Aproy
    	hSMAproy = CreateMenu();
        AppendMenu(hSMAproy, MF_STRING, IDM_APROPO, "Apros de notre application");
    
    	//MENU vide
        hMenu  = CreateMenu();
    	//Ajout du menu fichier
        AppendMenu(hMenu,MF_POPUP,(UINT)hSMQuit,"Fichier");
    	//Ajout du menu '?'
    	AppendMenu(hMenu,MF_POPUP,(UINT)hSMAproy,"?");
    	
    
    	hwndMAIN = CreateWindow("MainWinClass", "gestion d'abcence", WS_SYSMENU,\
    		80, 40, 260, 220, NULL, hMenu, hinstance, NULL);
    	
        if (!hwndMAIN) return FALSE;
    
        ShowWindow(hwndMAIN, nCmdShow);
        UpdateWindow(hwndMAIN);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return msg.wParam;
    }
    /*******************************************************************************/
    /*
     *  Main window-------------------------------------------------->Main window
     */
    //Fonction de gestion de la fonctions principale
    LRESULT CALLBACK Proc_Win_Main(HWND hwndMAIN, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_Main(hwndMAIN);
    		return 0;
    		//------------
    	case WM_COMMAND:
    		Events_Wnd_Main(hwndMAIN, wParam, lParam);
    		return 0;
    		//------------
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    		//------------
    	default:
    		return DefWindowProc(hwndMAIN, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre principale
    void Remplie_Wnd_Main(HWND hwnd)
    {
    	int y=20, x=20, mov=50;//position
    	int with=100, height=25;//tailles
    	HWND cmdPING;
    //	HWND cmdTRACERT;
    	HWND cmdIPCONFIG;
    //	HWND cmdNETSTAT;
    //	HWND cmdROUTE;
    //	HWND cmdARP;
    //	HWND cmdNBTSTAT;
    //	HWND cmdNSLOOKUP;
    //	HWND cmdHOSTNAME;
    //	HWND cmdFINGER;
    //	HWND cmdNETMON;
    
    	HWND lblPING;
    /*	HWND lblTRACERT;
    	HWND lblIPCONFIG;
    	HWND lblNETSTAT;
    	HWND lblROUTE;
    	HWND lblARP;
    	HWND lblNBTSTAT;
    	HWND lblNSLOOKUP;
    	HWND lblHOSTNAME;
    	HWND lblFINGER;
    	HWND lblNETMON;*/
    
        cmdPING = CreateWindow("button", "PING",
                  WS_CHILD | WS_VISIBLE , x, y+15, with, height, hwnd, (HMENU)ID_PUSHBUTTON_PING, NULL, NULL);
    	
    	cmdIPCONFIG = CreateWindow("button", "IPCONFIG",
                  WS_CHILD | WS_VISIBLE , x, y+mov+10, with, height, hwnd, (HMENU)ID_PUSHBUTTON_IPCONFIG, NULL, NULL);
    	
    
         lblPING = CreateWindow("Edit", "PING",
                  WS_CHILD | WS_VISIBLE|ES_PASSWORD|BS_AUTOCHECKBOX|ES_UPPERCASE|WS_BORDER , x+110, 33, with, height, hwnd, NULL, NULL, NULL);
    	group1 = CreateWindow("button","entre votre mot de passe", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 10,6, 232,70, 
    				hwnd,0, NULL,NULL);
    	/*group2 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, x+107, 25, with+5, height+10, 
    				hwnd,0, NULL,NULL);*/
    
    
    	
    }
    //fonction qui gère les evenements de l'application
    void Events_Wnd_Main(HWND hwnd, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwnd, WM_CLOSE,0,0);
    		break;
    	case IDM_APROPO :
    		MessageBox(hwnd,"application developpe par fikri","",MB_OK);
    		break;
    	case ID_PUSHBUTTON_PING :
    		Event_Button_Ping();
    		break;
    	case ID_PUSHBUTTON_IPCONFIG :
    		Event_Button_Ipconfig();
    		break;
    	}
    }
    //Events for button ping
    void Event_Button_Ping()
    {
    	WNDCLASS wcPing;
    	wcPing.style = 0;
    	wcPing.lpfnWndProc = Proc_Win_Ping;
    	wcPing.cbClsExtra = 0;
    	wcPing.cbWndExtra = 0;
    	wcPing.hInstance = NULL;
    	wcPing.hIcon = NULL;
    	wcPing.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wcPing.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    	wcPing.lpszMenuName =  NULL;
    	wcPing.lpszClassName = "PingWinClass";
    	RegisterClass(&wcPing);
    	hwndPING = CreateWindow("PingWinClass", "PING", WS_SYSMENU, 160, 60, 600, 500, hwndMAIN, NULL, hinst, NULL);
    	ShowWindow(hwndPING, SW_SHOW);
    }
    //Events for button ipconfig
    void Event_Button_Ipconfig()
    {
    	WNDCLASS wcIpconfig;
    	wcIpconfig.style = 0;
    	wcIpconfig.lpfnWndProc = Proc_Win_Ipconfig;
    	wcIpconfig.cbClsExtra = 0;
    	wcIpconfig.cbWndExtra = 0;
    	wcIpconfig.hInstance = NULL;
    	wcIpconfig.hIcon = NULL;
    	wcIpconfig.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wcIpconfig.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    	wcIpconfig.lpszMenuName =  NULL;
    	wcIpconfig.lpszClassName = "IpconfigWinClass";
    	RegisterClass(&wcIpconfig);
    	hwndIPCONFIG = CreateWindow("IpconfigWinClass", "IPCONFIG", WS_SYSMENU, 160, 60, 600, 500, hwndMAIN, NULL, hinst, NULL);
    	ShowWindow(hwndIPCONFIG, SW_SHOW);
    }
    
    //Events for button Hostname
    void Event_Button_Hostname()
    {
    	WNDCLASS wcHostname;
    	wcHostname.style = 0;
    	wcHostname.lpfnWndProc = Proc_Win_Hostname;
    	wcHostname.cbClsExtra = 0;
    	wcHostname.cbWndExtra = 0;
    	wcHostname.hInstance = NULL;
    	wcHostname.hIcon = NULL;
    	wcHostname.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wcHostname.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    	wcHostname.lpszMenuName =  NULL;
    	wcHostname.lpszClassName = "HostnameWinClass";
    	RegisterClass(&wcHostname);
    	hwndHOSTNAME = CreateWindow("HostnameWinClass", "HOSTNAME", WS_SYSMENU, 160, 60, 600, 500, hwndMAIN, NULL, hinst, NULL);
    	ShowWindow(hwndHOSTNAME, SW_SHOW);
    }
    /*
     *  Ping window-------------------------------------------------->Ping window
     */
    //Fonction de gestion de la fonctions ping
    LRESULT CALLBACK Proc_Win_Ping(HWND hwndPING, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_Ping(hwndPING);
    		return 0;
    		//--------
    	case WM_COMMAND:
    		Events_Wnd_Ping(hwndPING, wParam, lParam);
    		return 0;
    		//--------
    	case WM_DESTROY:
    		EndDialog(hwndPING,0);
    		return 0;
    		//--------
    	default:
    		return DefWindowProc(hwndPING, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre ping****** A REMPLIER AVEC LES SUPRIME......
    void Remplie_Wnd_Ping(HWND hwndPING)
    {
    	//button ping
    	cmdEnvoi_PING = CreateWindow("button", "ajouter",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 125, 75, 20, hwndPING, (HMENU)ID_PUSHBUTTON_PING, hinst, NULL);
    
    	cmdEnvoi_PING1 = CreateWindow("button", "suprimer",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 175, 75, 20, hwndPING, (HMENU)ID_PUSHBUTTON_PING, hinst, NULL);
    	cmdEnvoi_PING2 = CreateWindow("button", "valider",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 225, 75, 20, hwndPING, (HMENU)ID_PUSHBUTTON_PING, hinst, NULL);
    	cmdEnvoi_PING3 = CreateWindow("button", "lister",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 275, 75, 20, hwndPING, (HMENU)ID_PUSHBUTTON_PING, hinst, NULL);
    	//Edite IpAdress
    	txtIP_PING = CreateWindow("edit", "",WS_CHILD | WS_VISIBLE | \
    		ES_MULTILINE|WS_BORDER|ES_CENTER,  90, 50, 150, 20, hwndPING, NULL, hinst, NULL);
    	SetWindowText(txtIP_PING, "Nom Prénom");
    
        txtIP_PING2 = CreateWindow("edit", "",WS_CHILD | WS_VISIBLE | \
    		ES_MULTILINE|WS_BORDER|ES_NUMBER,  300, 50, 30, 20, hwndPING, NULL, hinst, NULL);
    
    	
       //les group des bouttons
    
    	group2 = CreateWindow("button","a remplire", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 25, 462, 70, 
    				hwndPING, NULL,hinst,NULL);
            
    
    	group3 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 105, 462, 50, 
    				hwndPING, NULL,hinst,NULL);
    
    	group4 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 155, 462, 50, 
    				hwndPING, NULL,hinst,NULL);
        
    	group5 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 205, 462, 50, 
    				hwndPING, NULL,hinst,NULL);
    	group6 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 255, 462, 50, 
    				hwndPING, NULL,hinst,NULL);
       //aide 
    txtResult_PING1 = CreateWindow("Edit", "pour ajouter un nouveau nombre",WS_CHILD | WS_VISIBLE \
    		  |ES_READONLY| WS_BORDER,150, 125, 355, 20, hwndPING, NULL, hinst, NULL);
    
    txtResult_PING2 = CreateWindow("Edit", "pour supprime un nombre",WS_CHILD | WS_VISIBLE \
    		  |ES_READONLY| WS_BORDER,150, 175, 355, 20, hwndPING, NULL, hinst, NULL);
    
    txtResult_PING3 = CreateWindow("Edit", "pour valide l'abcence d'un nombre",WS_CHILD | WS_VISIBLE   \
    		  |ES_READONLY| WS_BORDER,150, 225, 355, 20, hwndPING, NULL, hinst, NULL);
    
    txtResult_PING4 = CreateWindow("Edit", "pour liste tt les nombres",WS_CHILD | WS_VISIBLE   \
    		  |ES_READONLY| WS_BORDER,150, 275, 355, 20, hwndPING, NULL, hinst, NULL);
    
      
    
    
    	//Edit result
    	txtResult_PING = CreateWindow("Edit", "",WS_CHILD | WS_VISIBLE | \
    		WS_VSCROLL | ES_MULTILINE |ES_READONLY| WS_BORDER,10, 320, 575, 105, hwndPING, NULL, hinst, NULL);
    }
    void Events_Wnd_Ping(HWND hwndPING, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	HANDLE F;
    	DWORD FileSize, nbcharRead;
    	PCHAR buffer, buffer2;
    	char entette[200];
    	char ipAdress[17];
    	char Commande[200];
    
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwndPING, WM_CLOSE,0,0);
    		break;
    	case ID_PUSHBUTTON_PING :
    		GetWindowText(txtIP_PING, ipAdress, 16);
    		strcpy(Commande, "ping ");
    		strcat(Commande, ipAdress);
    		strcat(Commande, " > ");
    		strcat(Commande, _filePingResult);
    		strcat(Commande, " 2> ");
    		strcat(Commande, _filePingError);
    		system(Commande);
    		strcpy(entette, "Commande = ");
    		strcat(entette, Commande);
    		strcat(entette, "\n\r");
    		F = CreateFile(_filePingResult, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    		FileSize = GetFileSize(F, NULL);
    		buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
    		buffer2 = (PCHAR)LocalAlloc(LMEM_FIXED, strlen(entette)+1+FileSize);
    		ReadFile(F, buffer, FileSize, &nbcharRead, NULL);
    		buffer[FileSize] = '\0';
    		strcpy(buffer2, entette);
    		strcat(buffer2, buffer);
    		SetWindowText(txtResult_PING, buffer2);
    		LocalFree(buffer);
    		LocalFree(buffer2);
    		CloseHandle(F);
    		break;
    	}
    }
    /*
     *  Ipconfig window<-------------------------------------------------->Ipconfig window
     */
    //Fonction de gestion de la fenetre de ipconfig
    LRESULT CALLBACK Proc_Win_Ipconfig(HWND hwndIPCONFIG, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_Ipconfig(hwndIPCONFIG);
    		return 0;
    		//----------------------------------------------------------------
    	case WM_COMMAND:
    		Events_Wnd_Ipconfig(hwndIPCONFIG, wParam, lParam);
    		return 0;
    		//----------------------------------------------------------------
    	case WM_DESTROY:
    		EndDialog(hwndIPCONFIG,0);
    		return 0;
    		//----------------------------------------------------------------
    	default:
    		return DefWindowProc(hwndIPCONFIG, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre Ipconfig
    void Remplie_Wnd_Ipconfig(HWND hwndIPCONFIG)
    {
    	//button ping
    	cmdEnvoi_IPCONFIG = CreateWindow("button", "Envoyer",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 490, 25, 80, 80, hwndIPCONFIG, (HMENU)ID_PUSHBUTTON_IPCONFIG, hinst, NULL);
    	//Edit result
    	txtResult_IPCONFIG = CreateWindow("Edit", "",WS_CHILD | WS_VISIBLE | WS_HSCROLL | \
    		WS_VSCROLL | ES_MULTILINE | WS_BORDER,10, 250, 575, 200, hwndIPCONFIG, NULL, hinst, NULL);
    }
    void Events_Wnd_Ipconfig(HWND hwndIPCONFIG, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	HANDLE F;
    	DWORD FileSize, nbcharRead;
    	PCHAR buffer, buffer2;
    	char entette[200];
    	char ipAdress[17];
    	char Commande[200];
    
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwndTRACERT, WM_CLOSE,0,0);
    		break;
    	case ID_PUSHBUTTON_IPCONFIG :
    		GetWindowText(txtIP_TRACERT, ipAdress, 16);
    		strcpy(Commande, "ipconfig ");
    		strcat(Commande, " > ");
    		strcat(Commande, _fileIpconfigResult);
    		strcat(Commande, " 2> ");
    		strcat(Commande, _fileIpconfigError);
    		system(Commande);
    		strcpy(entette, "Commande = ");
    		strcat(entette, Commande);
    		strcat(entette, "\n\r");
    		F = CreateFile(_fileIpconfigResult, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    		FileSize = GetFileSize(F, NULL);
    		buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
    		buffer2 = (PCHAR)LocalAlloc(LMEM_FIXED, strlen(entette)+1+FileSize);
    		ReadFile(F, buffer, FileSize, &nbcharRead, NULL);
    		buffer[FileSize] = '\0';
    		strcpy(buffer2, entette);
    		strcat(buffer2, buffer);
    		SetWindowText(txtResult_IPCONFIG, buffer2);
    		LocalFree(buffer);
    		LocalFree(buffer2);
    		CloseHandle(F);
    		break;
    	}
    }
    
    /*
     *  Hostname window-------------------------------------------------->Hostname window
     */
    //Fonction de gestion de la fonctions Hostname
    LRESULT CALLBACK Proc_Win_Hostname(HWND hwndHOSTNAME, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_Hostname(hwndHOSTNAME);
    		return 0;
    		//--------
    	case WM_COMMAND:
    		Events_Wnd_Hostname(hwndHOSTNAME, wParam, lParam);
    		return 0;
    		//--------
    	case WM_DESTROY:
    		EndDialog(hwndHOSTNAME,0);
    		return 0;
    		//--------
    	default:
    		return DefWindowProc(hwndHOSTNAME, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre HOSTNAME
    void Remplie_Wnd_Hostname(HWND hwndHOSTNAME)
    {
    	//button ping
    	cmdEnvoi_HOSTNAME = CreateWindow("button", "Envoyer",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 490, 25, 80, 80, hwndHOSTNAME, (HMENU)ID_PUSHBUTTON_HOSTNAME, hinst, NULL);
    	//Edit result
    	txtResult_HOSTNAME = CreateWindow("Edit", "Cet outil peut vous donner le nom du hote courant",WS_CHILD | WS_VISIBLE | WS_HSCROLL | \
    		WS_VSCROLL | ES_MULTILINE | WS_BORDER,10, 250, 575, 200, hwndHOSTNAME, NULL, hinst, NULL);
    }
    void Events_Wnd_Hostname(HWND hwndHOSTNAME, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	HANDLE F;
    	DWORD FileSize, nbcharRead;
    	PCHAR buffer, buffer2;
    	char entette[200];
    	char Commande[200];
    
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwndPING, WM_CLOSE,0,0);
    		break;
    	case ID_PUSHBUTTON_HOSTNAME :
    		strcpy(Commande, "hostname > ");
    		strcat(Commande, _fileHostanameResult);
    		strcat(Commande, " 2> ");
    		strcat(Commande, _fileHostanameError);
    		system(Commande);
    		strcpy(entette, "Commande = ");
    		strcat(entette, Commande);
    		strcat(entette, "\n\r");
    		F = CreateFile(_fileHostanameResult, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    		FileSize = GetFileSize(F, NULL);
    		buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
    		buffer2 = (PCHAR)LocalAlloc(LMEM_FIXED, strlen(entette)+33+FileSize);
    		ReadFile(F, buffer, FileSize, &nbcharRead, NULL);
    		buffer[FileSize] = '\0';
    		strcpy(buffer2, entette);
    		strcat(buffer2, "\n\r\n\rLe nom de votre hote est : ");
    		strcat(buffer2, buffer);
    		SetWindowText(txtResult_HOSTNAME, buffer2);
    		LocalFree(buffer);
    		LocalFree(buffer2);
    		CloseHandle(F);
    		break;
    	}
    }
    config.h 
    
    
    /***********************************************************************
     * Les bibliothèques standards
     */
    #include <windows.h>
    #include <stdio.h>
    #include <string.h>
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les fichiers utilisés
     */
    #define _filePingResult "./Debug/data/ping_data/result.txt"
    #define _filePingError "./Debug/data/ping_data/error.txt"
    
    #define _fileIpconfigResult "./Debug/data/ipconfig_data/result.txt"
    #define _fileIpconfigError "./Debug/data/ipconfig_data/error.txt"
    
    #define _fileHostanameResult "./Debug/data/ping_data/result.txt"
    #define _fileHostanameError "./Debug/data/ping_data/error.txt"
    
    #define _fileTracertResult "./Debug/data/tracert_data/result.txt"
    #define _fileTracertError "./Debug/data/tracert_data/error.txt"
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les identificateurs des evenements
     */
    #define IDM_QUIT 1
    #define IDM_APROPO 2
    #define ID_PUSHBUTTON_PING 3
    #define ID_PUSHBUTTON_IPCONFIG 4
    #define ID_PUSHBUTTON_TRACERT 5
    #define ID_PUSHBUTTON_NETSTAT 6
    #define ID_PUSHBUTTON_ROUTE 7
    #define ID_PUSHBUTTON_ARP 8
    #define ID_PUSHBUTTON_NBTSTAT 9
    #define ID_PUSHBUTTON_NSLOOKUP 10
    #define ID_PUSHBUTTON_HOSTNAME 11
    #define ID_PUSHBUTTON_FINGER 12
    #define ID_PUSHBUTTON_NETMON 13
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les handels des fenetres
     */
    HINSTANCE hinst;// for application
    //the windows
    HWND hwndMAIN;//main window
    HWND hwndPING;
    HWND hwndTRACERT;
    HWND hwndIPCONFIG;
    HWND hwndNETSTAT;
    HWND hwndROUTE;
    HWND hwndARP;
    HWND hwndNBTSTAT;
    HWND hwndNSLOOKUP;
    HWND hwndHOSTNAME;
    HWND hwndFINGER;
    HWND hwndNETMON;
    HWND group1;
    HWND group2;
    HWND group3;
    HWND txtIP_PING2;
    HWND cmdEnvoi_PING1;HWND cmdEnvoi_PING2;HWND cmdEnvoi_PING3;
    HWND group3;
    HWND group4;HWND group5;HWND group6;
    HWND txtResult_PING1;HWND txtResult_PING2;HWND txtResult_PING3;HWND txtResult_PING4;
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les contrioles communs
     */
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * WINMAIN window
     */
     LRESULT CALLBACK Proc_Win_Main(HWND, UINT, WPARAM, LPARAM);//Proc
     void Events_Wnd_Main(HWND, WPARAM, LPARAM);
     void Remplie_Wnd_Main(HWND);
     void Event_Button_Ping();
     void Event_Button_Ipconfig();
     void Event_Button_Tracert();
     void Event_Button_Hostname();
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * PING window
     */
     HWND cmdEnvoi_PING;
     HWND txtResult_PING;
     HWND txtIP_PING;
     LRESULT CALLBACK Proc_Win_Ping(HWND, UINT, WPARAM, LPARAM);//Proc
     void Remplie_Wnd_Ping(HWND);
     void Events_Wnd_Ping(HWND, WPARAM, LPARAM);
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * IPCONFIG window
     */
     HWND cmdEnvoi_IPCONFIG;
     HWND txtResult_IPCONFIG;
     LRESULT CALLBACK Proc_Win_Ipconfig(HWND, UINT, WPARAM, LPARAM);//Proc
     void Remplie_Wnd_Ipconfig(HWND);
     void Events_Wnd_Ipconfig(HWND, WPARAM, LPARAM);
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * TRACERT window
     */
     HWND cmdEnvoi_TRACERT;
     HWND txtResult_TRACERT;
     HWND txtIP_TRACERT;
     LRESULT CALLBACK Proc_Win_Tracert(HWND, UINT, WPARAM, LPARAM);
     void Remplie_Wnd_Tracert(HWND hwndTRACERT);
     void Events_Wnd_Tracert(HWND hwndTRACERT, WPARAM wParam, LPARAM lParam);
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * HOSTNAME window
     */
     HWND cmdEnvoi_HOSTNAME;
     HWND txtResult_HOSTNAME;
     LRESULT CALLBACK Proc_Win_Hostname(HWND, UINT, WPARAM, LPARAM);
     void Remplie_Wnd_Hostname(HWND hwndTRACERT);
     void Events_Wnd_Hostname(HWND hwndTRACERT, WPARAM wParam, LPARAM lParam);
    il y'a bcp de truc pas finie evite le...

    [-mod- Ajouté les balises code. Je rappelle que c'est obligatoire. Ne concerne pas le langage C. Déplacé.]

  2. #2
    Membre confirmé Avatar de aaron4444
    Inscrit en
    Juin 2006
    Messages
    113
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 113
    Par défaut unh

  3. #3
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 395
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 395
    Par défaut
    1. Ton code C compile peut-être, mais ton français non...
    2. EndDialog() ne doit pas être utilisé avec les fenêtres créées par CreateWindow(). Seules les boîtes de dialogues créées par DialogBoxXxxx() (et sûrement pas CreateDialog() non plus) peuvent profiter de EndDialog()...
    3. T'as beaucoup de variables globales, dis-donc...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  4. #4
    Membre averti
    Inscrit en
    Août 2007
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 13
    Par défaut el baz
    voila j'ai resolut le probleme mais il reste un autre !!!!.


    j'ai sur mon apllication deux fennetres

    fennetre principale ---> qui contient un champ de texte (mot de passe)
    pour ouvrir l'autre fennetre il faut avoir le mot passe.

    voila j'ai eesaye de la faire marche et je n'arreve pas ( en plus je voundrai que comme fennetre principale se despare lorsque j'ai la bonne mot de passe )

    voila mon probleme


    main.c
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    #include "config.h"
    
    /*******************************************************************************/
    int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        MSG msg;
        WNDCLASS wc;
    
    	HMENU hMenu,hSMQuit, hSMAproy;//declaration des menu
    
        wc.style = 0;
        wc.lpfnWndProc = Proc_Win_Main;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = hinstance;
        wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
        wc.lpszMenuName =  NULL;
        wc.lpszClassName = "MainWinClass";
    
    
        if(!RegisterClass(&wc)) return FALSE;
    	
    	//sous Menu Quit
    	hSMQuit = CreateMenu();
        AppendMenu(hSMQuit, MF_STRING, IDM_QUIT, "Quitter");
    	
    	//sous Aproy
    	hSMAproy = CreateMenu();
        AppendMenu(hSMAproy, MF_STRING, IDM_APROPO, "Apros de notre application");
    
    	//MENU vide
        hMenu  = CreateMenu();
    	//Ajout du menu fichier
        AppendMenu(hMenu,MF_POPUP,(UINT)hSMQuit,"Fichier");
    	//Ajout du menu '?'
    	AppendMenu(hMenu,MF_POPUP,(UINT)hSMAproy,"?");
    	
    
    	hwndMAIN = CreateWindow("MainWinClass", "gestion d'abcence", WS_SYSMENU,\
    		70, 30, 260, 220, NULL, hMenu, hinstance, NULL);
    	
        if (!hwndMAIN) return FALSE;
    
        ShowWindow(hwndMAIN, nCmdShow);
        UpdateWindow(hwndMAIN);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return msg.wParam;
    }
    /*******************************************************************************/
    /*
     *  Main window-------------------------------------------------->Main window
     */
    //Fonction de gestion de la fonctions principale
    LRESULT CALLBACK Proc_Win_Main(HWND hwndMAIN, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_Main(hwndMAIN);
    		return 0;
    		//------------
    	case WM_COMMAND:
    		Events_Wnd_Main(hwndMAIN, wParam, lParam);
    		return 0;
    		//------------
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    		//------------
    	default:
    		return DefWindowProc(hwndMAIN, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre principale
    void Remplie_Wnd_Main(HWND hwnd)
    {
    	int y=20, x=20, mov=50;//position
    	int with=100, height=25;//tailles
    	HWND cmdok;
    	HWND lblok;
        HWND Res;
    
    
    
        cmdok = CreateWindow("button", "ok",
                  WS_CHILD | WS_VISIBLE , x, y+25, with, height, hwnd, (HMENU)ID_PUSHBUTTON_ok, NULL, NULL);
    	
        lblok = CreateWindow("Edit", "",
                  WS_CHILD | WS_VISIBLE|ES_PASSWORD|BS_AUTOCHECKBOX|ES_UPPERCASE|WS_BORDER , x+110, 43, with,
    			  height, hwnd, NULL, NULL, NULL);
    
    	group1 = CreateWindow("button","entre votre mot de passe", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 10,16, 232,70, 
    				hwnd,0, NULL,NULL);
    	
        Res = CreateWindow("Edit", "bien a notre application !!!",WS_CHILD | WS_VISIBLE | \
    		WS_VSCROLL | ES_MULTILINE |ES_READONLY|ES_CENTER| WS_BORDER,10, 100, 232, 50, hwnd, NULL, NULL, NULL);
    
    	
    }
    //fonction qui gère les evenements de l'application
    void Events_Wnd_Main(HWND hwnd, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwnd, WM_CLOSE,0,0);
    		break;
    	case IDM_APROPO :
    		MessageBox(hwnd,"application developpe par fikri","",MB_OK);
    		break;
    	case ID_PUSHBUTTON_ok :
    		Event_Button_ok();
    		break;
    		
    	}
    }
    //Events for button ping
    void Event_Button_ok()
    {
    	WNDCLASS wcok;
    	wcok.style = 0;
    	wcok.lpfnWndProc = Proc_Win_ok;
    	wcok.cbClsExtra = 0;
    	wcok.cbWndExtra = 0;
    	wcok.hInstance = NULL;
    	wcok.hIcon = NULL;
    	wcok.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wcok.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    	wcok.lpszMenuName =  NULL;
    	wcok.lpszClassName = "okWinClass";
    	RegisterClass(&wcok);
    
    	hwndok = CreateWindow("okWinClass", "", WS_SYSMENU, 160, 60, 600, 500, hwndMAIN, NULL, hinst, NULL);
        ShowWindow(hwndok, SW_SHOW);
    }
    
    
    
    /*
     *  ok window-------------------------------------------------->ok window
     */
    //Fonction de gestion de la fonctions ok
    
    LRESULT CALLBACK Proc_Win_ok(HWND hwndok, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
        {
    	case WM_CREATE:
    		Remplie_Wnd_ok(hwndok);
    		return 0;
    		//--------
    	case WM_COMMAND:
    		Events_Wnd_ok(hwndok, wParam, lParam);
    		return 0;
    		//--------
    	case WM_DESTROY:
    		EndDialog(hwndok,0);
    		return 0;
    		//--------
    	default:
    		return DefWindowProc(hwndok, uMsg, wParam, lParam);
    	}
    }
    //fonction qui rempli la fenetre ping****** A REMPLIER AVEC LES SUPRIME......
    void Remplie_Wnd_ok(HWND hwndok)
    {
    	
    	//button ping
    	cmdEnvoi_ok = CreateWindow("button", "ajouter",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 125, 75, 20, hwndok, (HMENU)ID_PUSHBUTTON_ok, hinst, NULL);
    
    	cmdEnvoi_ok1 = CreateWindow("button", "suprimer",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 175, 75, 20, hwndok, (HMENU)ID_PUSHBUTTON_ok, hinst, NULL);
    
    	cmdEnvoi_ok2 = CreateWindow("button", "valider",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 225, 75, 20, hwndok, (HMENU)ID_PUSHBUTTON_ok, hinst, NULL);
    
    	cmdEnvoi_ok3 = CreateWindow("button", "lister",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON \
    		, 68, 275, 75, 20, hwndok, (HMENU)ID_PUSHBUTTON_ok, hinst, NULL);
    
    	//Edite IpAdress
    
    	txt_ok = CreateWindow("edit", "",WS_CHILD | WS_VISIBLE | \
    		ES_MULTILINE|WS_BORDER|ES_CENTER,  90, 50, 150, 20, hwndok, NULL, hinst, NULL);
    	SetWindowText(txt_ok, "Nom Prénom");
    
        txt_ok2 = CreateWindow("edit", "",WS_CHILD | WS_VISIBLE | \
    		ES_MULTILINE|WS_BORDER|ES_NUMBER,  300, 50, 30, 20, hwndok, NULL, hinst, NULL);
    
    	
       //les group des bouttons
    
    	group2 = CreateWindow("button","a remplire", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 25, 462, 70, 
    				hwndok, NULL,hinst,NULL);
            
    
    	group3 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 105, 462, 50, 
    				hwndok, NULL,hinst,NULL);
    
    	group4 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 155, 462, 50, 
    				hwndok, NULL,hinst,NULL);
        
    	group5 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 205, 462, 50, 
    				hwndok, NULL,hinst,NULL);
    
    	group6 = CreateWindow("button","", WS_CHILD | WS_VISIBLE | BS_GROUPBOX, 58, 255, 462, 50, 
    				hwndok, NULL,hinst,NULL);
       //aide 
    
    	txtResult_ok1 = CreateWindow("Edit", "pour ajouter un nouveau nombre",WS_CHILD | WS_VISIBLE \
    		  |ES_READONLY| WS_BORDER,150, 125, 355, 20, hwndok, NULL, hinst, NULL);
    
    	txtResult_ok2 = CreateWindow("Edit", "pour supprime un nombre",WS_CHILD | WS_VISIBLE \
    		  |ES_READONLY| WS_BORDER,150, 175, 355, 20, hwndok, NULL, hinst, NULL);
    
    	txtResult_ok3 = CreateWindow("Edit", "pour valide l'abcence d'un nombre",WS_CHILD | WS_VISIBLE   \
    		  |ES_READONLY| WS_BORDER,150, 225, 355, 20, hwndok, NULL, hinst, NULL);
    
    	txtResult_ok4 = CreateWindow("Edit", "pour liste tt les nombres",WS_CHILD | WS_VISIBLE   \
    		  |ES_READONLY| WS_BORDER,150, 275, 355, 20, hwndok, NULL, hinst, NULL);
    
      
    
    
    	//Edit result
    
    	txtResult_ok = CreateWindow("Edit", "",WS_CHILD | WS_VISIBLE | \
    		WS_VSCROLL | ES_MULTILINE |ES_READONLY| WS_BORDER,10, 320, 575, 105, hwndok, NULL, hinst, NULL);
    }
    
    
    void Events_Wnd_ok(HWND hwndok, WPARAM wParam, LPARAM lParam)
    {
    	UINT iId = LOWORD(wParam);
        HWND hCtl = (HWND)lParam;
    	HANDLE F;
    	DWORD FileSize, nbcharRead;
    	PCHAR buffer, buffer2;
    	char entette[200];
    	char ipAdress[17];
    	char Commande[200];
    
    	switch(iId)
    	{
    	case IDM_QUIT :
    		PostMessage(hwndok, WM_CLOSE,0,0);
    		break;
    	case ID_PUSHBUTTON_ok :
    		GetWindowText(txt_ok, ipAdress, 16);
    		strcpy(Commande, "ping ");
    		strcat(Commande, ipAdress);
    		strcat(Commande, " > ");
    		strcat(Commande, _fileokResult);
    		strcat(Commande, " 2> ");
    		strcat(Commande, _fileokError);
    		system(Commande);
    		strcpy(entette, "Commande = ");
    		strcat(entette, Commande);
    		strcat(entette, "\n\r");
    		F = CreateFile(_fileokResult, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    		FileSize = GetFileSize(F, NULL);
    		buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
    		buffer2 = (PCHAR)LocalAlloc(LMEM_FIXED, strlen(entette)+1+FileSize);
    		ReadFile(F, buffer, FileSize, &nbcharRead, NULL);
    		buffer[FileSize] = '\0';
    		strcpy(buffer2, entette);
    		strcat(buffer2, buffer);
    		SetWindowText(txtResult_ok, buffer2);
    		LocalFree(buffer);
    		LocalFree(buffer2);
    		CloseHandle(F);
    		break;
    	}
    }
    
    {
    config.h

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    /***********************************************************************
     * Les bibliothèques standards
     */
    #include <windows.h>
    #include <stdio.h>
    #include <string.h>
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les fichiers utilisés
     */
    #define _fileokResult "./Debug/data/ping_data/result.txt"
    #define _fileokError "./Debug/data/ping_data/error.txt"
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les identificateurs des evenements
     */
    #define IDM_QUIT 1
    #define IDM_APROPO 2
    #define ID_PUSHBUTTON_ok 3
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les handels des fenetres
     */
    HINSTANCE hinst;// for application
    //the windows
    HWND hwndMAIN;//main window
    HWND hwndok;
    HWND group1,group0;
    HWND group2;
    HWND group3;
    HWND txt_ok2;HWND txt_ok;
    HWND cmdEnvoi_ok1;HWND cmdEnvoi_ok2;HWND cmdEnvoi_ok3;
    HWND group3;HWND group4;HWND group5;HWND group6;
    HWND txtResult_ok1;HWND txtResult_ok2;HWND txtResult_ok3;HWND txtResult_ok4;
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * Les contrioles communs
     */
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * WINMAIN window
     */
     LRESULT CALLBACK Proc_Win_Main(HWND, UINT, WPARAM, LPARAM);//Proc
     void Events_Wnd_Main(HWND, WPARAM, LPARAM);
     void Remplie_Wnd_Main(HWND);
     void Event_Button_ok();
    
    
    //----------------------------------------------------------------------
    
    /***********************************************************************
     * ok window
     */
     HWND cmdEnvoi_ok;
     HWND txtResult_ok;
     HWND txt_ok1;
     LRESULT CALLBACK Proc_Win_ok(HWND, UINT, WPARAM, LPARAM);//Proc
     void Remplie_Wnd_ok(HWND);
     void Events_Wnd_ok(HWND, WPARAM, LPARAM);
    //----------------------------------------------------------------------

  5. #5
    Expert éminent
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 395
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 395
    Par défaut
    J'ai la flemme de compiler, alors j'aimerais que tu précises:
    1. Qu'est-ce qui marche exactement ?
    2. Qu'est-ce qui ne marche pas exactement ?
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  6. #6
    Membre averti
    Inscrit en
    Août 2007
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 13
    Par défaut el baz
    voila tt marche tres bien

    mais le probleme c'est lorsque je click sur ok pour avoir la 2eme fenetre la 1ere fenetre reste affiche..


    moi je voudrai que lorsque je click sur OK la 1 ere fenetre dispare et remplece par la 2 eme ..

    j'espire que mon probleme est clair et merci ...

Discussions similaires

  1. Réponses: 29
    Dernier message: 14/01/2013, 10h40
  2. API Windows langage C problème sur mmioCreateChunk
    Par azimut2 dans le forum Windows
    Réponses: 2
    Dernier message: 24/09/2009, 17h53
  3. tutoriel : La programmation de l'API Windows en C++ par Bob
    Par Aurelien.Regat-Barrel dans le forum Windows
    Réponses: 19
    Dernier message: 21/06/2008, 14h34
  4. Réponses: 2
    Dernier message: 04/11/2007, 13h16
  5. Documentation gratuite sur l'API Windows, COM, DCOM, OLE, etc.
    Par Community Management dans le forum Windows
    Réponses: 1
    Dernier message: 16/11/2006, 15h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo