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

Dev-C++ Discussion :

Problème de Création d'une fenetre fille à partir de fenetre principale


Sujet :

Dev-C++

  1. #1
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut Problème de Création d'une fenetre fille à partir de fenetre principale
    Bonjour pour les Développeurs...

    Aprés la création de ma fenetre principale ainsi que les boutons, je trouve une difficulté pour crée une fenetre fille de telle facon lors d'un clique sur une bouton elle affiche une autre fenetre(cad fenetre fille) et ainsi de suite..

    L'Environnement est windows, compilateur Dev C++, language C.

    Mon code est:

    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
    #LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        static HFONT hFont;
        static LOGFONT lf;
        static BOOL EditNotChg = TRUE;        
        static HBRUSH EditBrush;
        static COLORREF BkEditcolor;
        static COLORREF TextColor = 0;
     
    	static HWND hEdit;	
    	static HWND hbtn1;
    	static HWND hbtn2;
    	static HWND hbtn3;
    	static HWND hbtn4;
    	static HWND hbtn5;
    	static HWND hbtn6;
    	static HWND hbtn7;
    	static HWND hbtn8;
    	static HWND hbtn9;
    	static HWND hbtn10;
    	static HWND hbtn11;
    	static HWND hbtn12;
    	static HWND hbtn13;
     
     
    	switch (uMsg)
    	{
    	case WM_CREATE:
    		{
    			HFONT hFont;
    			hEdit = CreateWindow("edit", "Texte",
    			 WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL,
    			 40,40, 0, 0, hwnd, NULL, NULL, NULL
    			 );
    			/*permet de récupérer des objets initialisés au démarrage de Windows, tel des pinceaux, crayons..*/
    			hFont = GetStockObject(ANSI_FIXED_FONT);/*changer le police de caractère*/
    			SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);/*mêmes paramètres que PostMessage et dans le même ordre//envoie le message directement à la procédure de fenêtre sans passer par la file d'attente*/
     
     
                 ZeroMemory(&lf, sizeof(LOGFONT));
                 lstrcpy(lf.lfFaceName,"Courier");
                 lf.lfHeight = 10;
                 hFont = CreateFontIndirect(&lf);
     
     
                 SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);
                 SendMessage(hEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN,
                                                                    MAKELONG(5, 5));
        	}
     
             SendMessage(hEdit, EM_SETMARGINS,
    		 EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5)
    		 );/*pour mettre ses marges interieures droite et gauche à 5 pixels*/
     
             //EXEC SQL CONNECT TO spernet [AS nom_connexion] [USER utilisateur];
     
        	hbtn1 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE|ES_WANTRETURN | ES_MULTILINE   ,
    	    3,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn2 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    	    103,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn3 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		203,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn4 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
            303,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn5 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    	    403,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn6 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    	    503,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn7 = CreateWindow("button", "Login", WS_CHILD | WS_VISIBLE ,
    		3,3, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn8 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,52, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn9 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,87, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn10 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,122, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn11 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,157, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn12 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,192, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		hbtn13 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE ,
    		3,227, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		return 0;
                // IDM_ABOUT
    	        case WM_COMMAND:
    	        	if(LOWORD(wParam)== IDM_OPEN)
    	         	{
                     OPENFILENAME ofn;
                     CHAR szFile[MAX_PATH]={0};
     
                       ZeroMemory(&ofn, sizeof(OPENFILENAME));
                         ofn.lStructSize = sizeof(OPENFILENAME);
                           ofn.hwndOwner = hwnd;
                            ofn.lpstrFile = szFile;
                             ofn.nMaxFile = MAX_PATH;
                              ofn.lpstrFilter =
                               "Fichier texte\0*.txt\0Fichier Word 2003\0*.doc\0Fichier Word 2007\0*.docx\0";
                    ofn.nFilterIndex = 1;
                    ofn.Flags =OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
     
                               if (GetOpenFileName(&ofn)==TRUE)
                                  {
                                    HANDLE hf;
                                      DWORD FileSize,nbcharRead ;
                                       CHAR *buffer;
     
                                        hf = CreateFile(szFile, GENERIC_READ, 0,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                                         FileSize = GetFileSize(hf, NULL);
                                         buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
                                         ReadFile(hf, buffer, FileSize, &nbcharRead, NULL) ;
                                         buffer[FileSize] = 0;
                                           SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer);
                                             LocalFree(buffer);
                                               CloseHandle(hf);
                                   }
                      }
     
                      if(LOWORD(wParam) == IDM_SAVE)
                  {
                    OPENFILENAME ofn;
                    CHAR szFile[260]={0};
     
                    ZeroMemory(&ofn, sizeof(OPENFILENAME));
    #ifdef OPENFILENAME_SIZE_VERSION_400
                    ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
    #else
                    ofn.lStructSize = sizeof(OPENFILENAME);
    #endif
                    ofn.hwndOwner = hwnd;
                    ofn.lpstrFile = szFile;
                    ofn.nMaxFile = sizeof(szFile);
                    ofn.lpstrFilter =
                               "Fichier texte\0*.txt\0Fichier Word 2003\0*.doc\0Fichier Word 2007\0*.docx\0";
                    ofn.nFilterIndex = 1;
                    ofn.Flags =
                           OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
                    if (GetSaveFileName(&ofn)==TRUE)
                     {
                        HANDLE hf;
                        DWORD FileSize,nbcharRead ;
                        char *buffer;
                        FileSize = GetWindowTextLength(hEdit);
                        buffer = (char*)LocalAlloc(LMEM_FIXED, FileSize+1);
                        GetWindowText(hEdit, buffer, FileSize+1);
                        hf = CreateFile(szFile, GENERIC_WRITE, 0,NULL,
                                        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
                        WriteFile(hf, buffer, FileSize, &nbcharRead, NULL) ;
                        CloseHandle(hf);
                        LocalFree(buffer);
                     }
                  } 
     
                      /////// IDM_ABOUT  ////////
            if(LOWORD(wParam) == IDM_ABOUT)
            MessageBox(hwnd,"Supernet... C'est La solution de votre société!!","C'est Notre Societé!!",MB_OK);
     
     
        	if(HIWORD(wParam) == EN_CHANGE) EditNotChg = FALSE;
     
    		return 0;
     
                     /////// Police Change  ////////
            if(LOWORD(wParam) == IDM_FONT)
                  {
                    CHOOSEFONT cf;
                    ZeroMemory(&cf, sizeof(CHOOSEFONT));
                    cf.lStructSize = sizeof (CHOOSEFONT);
                    cf.hwndOwner = hwnd;
                    cf.lpLogFont = &lf;
                    cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
     
                    if (ChooseFont(&cf))
                     {
                        DeleteObject(hFont);
                        hFont = CreateFontIndirect(&lf);
                        SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);
                     }
                  }
     
     
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
     
    	default:
    		return DefWindowProc(hwnd, uMsg, wParam, lParam);
    	}
    }
    Merci..

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Veux-tu vraiment créer une fenêtre fille, ou bien seulement une fenêtre "owned" ?

  3. #3
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Veux-tu vraiment créer une fenêtre fille, ou bien seulement une fenêtre "owned" ?
    Oui, je veux créer vraiment une fenetre fille. mais je veux quelle s'ouvre lors du clic de bouton

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Dans ce cas, j'ai du mal à voir le problème...

  5. #5
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Dans ce cas, j'ai du mal à voir le problème...
    Bon, ok, si c'est pas possible, Donc je dois faire une fentre owned, alors svp comment faire dans ce cas?
    Merci d'avance

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Je n'ai jamais dit que ce n'était pas possible, j'ai dit que je ne voyais pas où tu bloques...

  7. #7
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Je n'ai jamais dit que ce n'était pas possible, j'ai dit que je ne voyais pas où tu bloques...
    Ok, le probleme exactement c'est que j'ai crée une fentre principale, qui contienne des boutons, mes ces boutons ne marche pas, cad, lors que je clique sur une bouton elle n'envoie rien. Je veux que lors que je clique sur une bouton elle affiche une boite de dialogue que je peux faire dedons des modification, puis l'enregister, etc.. C'est ça mon ami.

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Après un reformattage nécessaire de ton code, on s'aperçoit que la réponse est bien simple:
    Code C/C++ : 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
    /* ----- Defines pour que ça compile sous mon Visual 2005 ----- */
    /* Parce qu'il me manque le reste de ton projet */
    #undef _UNICODE
    #undef UNICODE
    #include <windows.h>
     
    #define ID_MONBUTTON 1000
    #define IDM_OPEN 1001
    #define IDM_SAVE 1002
    #define IDM_ABOUT 1003
    #define IDM_FONT 1004
    /* ----- Fin des Defines ----- */
     
    struct st_MainWndMemory
    {
    	HFONT hFont;
    	LOGFONT lf;
    	BOOL EditNotChg;
    	HBRUSH EditBrush;
    	COLORREF BkEditcolor;
    	COLORREF TextColor;
     
    	HWND hEdit;
    	HWND hbtn1;
    	HWND hbtn2;
    	HWND hbtn3;
    	HWND hbtn4;
    	HWND hbtn5;
    	HWND hbtn6;
    	HWND hbtn7;
    	HWND hbtn8;
    	HWND hbtn9;
    	HWND hbtn10;
    	HWND hbtn11;
    	HWND hbtn12;
    	HWND hbtn13;
    };
     
    LRESULT ProcessWmCommand(HWND hWnd, struct st_MainWndMemory *pt_mem, WORD commandId, WORD notification, HWND hControl)
    {
    	LRESULT ret = 0;
     
    	switch(commandId)
    	{
    	case IDM_OPEN:
    		{
    		OPENFILENAME ofn;
    		CHAR szFile[MAX_PATH]={0};
     
    		ZeroMemory(&ofn, sizeof(OPENFILENAME));
    		ofn.lStructSize = sizeof(OPENFILENAME);
    		ofn.hwndOwner = hWnd;
    		ofn.lpstrFile = szFile;
    		ofn.nMaxFile = MAX_PATH;
    		ofn.lpstrFilter = "Fichier texte\0*.txt\0Fichier Word 2003\0*.doc\0Fichier Word 2007\0*.docx\0";
    		ofn.nFilterIndex = 1;
    		ofn.Flags =OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
     
    		if (GetOpenFileName(&ofn)==TRUE)
    		{
    			HANDLE hf;
    			DWORD FileSize,nbcharRead ;
    			CHAR *buffer;
     
    			hf = CreateFile(szFile, GENERIC_READ, 0,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    			FileSize = GetFileSize(hf, NULL);
    			buffer = (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
    			ReadFile(hf, buffer, FileSize, &nbcharRead, NULL) ;
    			buffer[FileSize] = 0;
    			SendMessage(pt_mem->hEdit, WM_SETTEXT, 0, (LPARAM)buffer);
    			LocalFree(buffer);
    			CloseHandle(hf);
    		}
    		}
    		break;
     
    	case IDM_SAVE:
    		{
    		OPENFILENAME ofn;
    		CHAR szFile[260]={0};
     
    		ZeroMemory(&ofn, sizeof(OPENFILENAME));
    		#ifdef OPENFILENAME_SIZE_VERSION_400
    		ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
    		#else
    		ofn.lStructSize = sizeof(OPENFILENAME);
    		#endif
    		ofn.hwndOwner = hWnd;
    		ofn.lpstrFile = szFile;
    		ofn.nMaxFile = sizeof(szFile);
    		ofn.lpstrFilter = "Fichier texte\0*.txt\0Fichier Word 2003\0*.doc\0Fichier Word 2007\0*.docx\0";
    		ofn.nFilterIndex = 1;
    		ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
    		if (GetSaveFileName(&ofn)==TRUE)
    		{
    			HANDLE hf;
    			DWORD FileSize,nbcharRead ;
    			char *buffer;
    			FileSize = GetWindowTextLength(pt_mem->hEdit);
    			buffer = (char*)LocalAlloc(LMEM_FIXED, FileSize+1);
    			GetWindowText(pt_mem->hEdit, buffer, FileSize+1);
    			hf = CreateFile(szFile, GENERIC_WRITE, 0,NULL,
    			 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    			WriteFile(hf, buffer, FileSize, &nbcharRead, NULL) ;
    			CloseHandle(hf);
    			LocalFree(buffer);
    		}
    		}
    		break;
     
    	/////// IDM_ABOUT  ////////
    	case IDM_ABOUT :
    		MessageBox(hWnd, "Supernet... C'est La solution de votre société!!", "C'est Notre Societé!!", MB_OK);
    		break;
     
    	/////// Police Change  ////////
    	case IDM_FONT:
    		{
    		CHOOSEFONT cf;
    		ZeroMemory(&cf, sizeof(CHOOSEFONT));
    		cf.lStructSize = sizeof (CHOOSEFONT);
    		cf.hwndOwner = hWnd;
    		cf.lpLogFont = &pt_mem->lf;
    		cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
     
    		if (ChooseFont(&cf))
    		{
    			DeleteObject(pt_mem->hFont);
    			pt_mem->hFont = CreateFontIndirect(&pt_mem->lf);
    			SendMessage(pt_mem->hEdit,WM_SETFONT,(WPARAM)pt_mem->hFont,TRUE);
    		}
    		}
    		break;
     
    	default:
    		if(hControl == pt_mem->hEdit && notification==EN_CHANGE)
    		{
    			pt_mem->EditNotChg = FALSE;
    		}
    		break;
    	}
     
    	return ret;
    }
     
    LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	static struct st_MainWndMemory my_mem = {
    	 NULL,
    	 {0L, 0L, 0L, 0L, 0L, 0, 0, 0, 0, 0, 0, 0, 0, ""},
    	 TRUE,
    	 NULL,
    	 0xFFFFFF,
    	 0x000000,
     
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL,
    	 NULL
    	 };
     
    	LRESULT ret = 0;
     
    	switch (uMsg)
    	{
    	case WM_CREATE:
    		{
    			HFONT hFont;
    			my_mem.hEdit = CreateWindow("edit", "Texte",
    			 WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL,
    			 40,40, 0, 0, hwnd, NULL, NULL, NULL
    			 );
    			/*permet de récupérer des objets initialisés au démarrage de Windows, tel des pinceaux, crayons..*/
    			hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);/*changer le police de caractère*/
    			SendMessage(my_mem.hEdit, WM_SETFONT, (WPARAM)hFont, TRUE);/*mêmes paramètres que PostMessage et dans le même ordre//envoie le message directement à la procédure de fenêtre sans passer par la file d'attente*/
     
    			ZeroMemory(&my_mem.lf, sizeof(LOGFONT));
    			lstrcpy(my_mem.lf.lfFaceName,"Courier");
    			my_mem.lf.lfHeight = 10;
    			hFont = CreateFontIndirect(&my_mem.lf);
     
    			SendMessage(my_mem.hEdit,WM_SETFONT, (WPARAM)hFont,TRUE);
    			SendMessage(my_mem.hEdit, EM_SETMARGINS,
    			 EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5)
    			 );
    		}
     
    		SendMessage(my_mem.hEdit, EM_SETMARGINS,
    		 EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5)
    		 );/*pour mettre ses marges interieures droite et gauche à 5 pixels*/
     
    		//EXEC SQL CONNECT TO spernet [AS nom_connexion] [USER utilisateur];
     
    		my_mem.hbtn1 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE|ES_WANTRETURN | ES_MULTILINE,
    		 3,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn2 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 103,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn3 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 203,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn4 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 303,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn5 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 403,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn6 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 503,285, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn7 = CreateWindow("button", "Login", WS_CHILD | WS_VISIBLE,
    		 3,3, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn8 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,52, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn9 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,87, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn10 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,122, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn11 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,157, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn12 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,192, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		my_mem.hbtn13 = CreateWindow("button", "-----", WS_CHILD | WS_VISIBLE,
    		 3,227, 100, 35, hwnd, (HMENU)ID_MONBUTTON, NULL, NULL);
    		break;
     
    	case WM_COMMAND:
    		ret = ProcessWmCommand(hwnd, &my_mem, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
    		break;
     
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
     
    	default:
    		ret = DefWindowProc(hwnd, uMsg, wParam, lParam);
    	}
    	return ret;
    }
    Tu n'as rien mis dans ton code pour traiter le message WM_COMMAND(ID_MONBUTTON)...

    PS: On ne caste pas un handle en UINT pour le passer à SendMessage() : Il faut le caster en WPARAM/LPARAM ou au minimum en UINT_PTR.

  9. #9
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Après un reformattage nécessaire de ton code...
    Tu n'as rien mis dans ton code pour traiter le message WM_COMMAND(ID_MONBUTTON)...

    PS: On ne caste pas un handle en UINT pour le passer à SendMessage() : Il faut le caster en WPARAM/LPARAM ou au minimum en UINT_PTR.
    Vraiment un grand remerciment pour vous, le code est mieux organisée maintenant..

    oui, mais je ne sais pas comment le traiter, j'ai fait plusieurs éssai dans "WPARAM/LPARAM" sans résultat..

    Je compile sur Dev-C++ le message d'erreur suivant est affiché:

    [Linker error] undefined reference to `WinMain@16'
    ld returned 1 exit status
    C:\Dev-Cpp\Makefile.win [Build Error] [Projet1.exe] Error 1

    Je l'essaye sur Visual studio C++ 6.0 et on aperçoi l'erreur suivante:

    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    Cpp1.exe - 2 error(s), 0 warning(s)

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    C'est normal, ce code ne comporte ni main() ni WinMain().
    Je pensais que tu les avais...

  11. #11
    Membre à l'essai
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    C'est normal, ce code ne comporte ni main() ni WinMain().
    Je pensais que tu les avais...
    Je suis couvert de honte..
    oui bien sur je l'ai..

    Dans SendMessage(), je ne sais pas comment le traiter, j'ai fait plusieurs éssai dans "WPARAM/LPARAM" sans résultat..

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

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

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Pour le message du bouton, regarde la fonction ProcessWmCommand() que j'ai créée.
    Il te suffit d'y ajouter un case ID_MONBUTTON: et d'y mettre le code que tu veux...

Discussions similaires

  1. Problème de création d'une base à partir d'un template
    Par ljoly dans le forum Administration
    Réponses: 4
    Dernier message: 15/02/2011, 09h45
  2. Problème de création d'une image BMP à partir d'un byte[]
    Par Dark_Alex69 dans le forum Interfaces Graphiques en Java
    Réponses: 4
    Dernier message: 28/03/2010, 16h32
  3. Réponses: 9
    Dernier message: 05/04/2006, 17h48
  4. FAQ : problème avec création d'une requete en VBA
    Par Oluha dans le forum VBA Access
    Réponses: 14
    Dernier message: 14/02/2006, 12h05
  5. Problème de création d'une dll...
    Par adrien954 dans le forum C++Builder
    Réponses: 4
    Dernier message: 21/10/2005, 10h46

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