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

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    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
    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
    Veux-tu vraiment créer une fenêtre fille, ou bien seulement une fenêtre "owned" ?
    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.

  3. #3
    Membre averti
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    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
    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
    Dans ce cas, j'ai du mal à voir le problème...
    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.

  5. #5
    Membre averti
    Inscrit en
    Juillet 2008
    Messages
    33
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 33
    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
    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
    Je n'ai jamais dit que ce n'était pas possible, j'ai dit que je ne voyais pas où tu bloques...
    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.

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