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 :

WM_CTLCOLORSTATIC


Sujet :

Windows

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    525
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2003
    Messages : 525
    Points : 212
    Points
    212
    Par défaut WM_CTLCOLORSTATIC
    Bonjour,
    Je construis 3 fenetres static dont 2 enfants de la première.
    Le probleme, c'est que j'intercepte bie le message ctlcolor pour la premiere, mais je n'y arrive pas pour les 2 autres ...
    Comment faire ? Dans la procedure de static1 ?
    Voilà une partie de mon code ...
    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
    hstatic1 = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
    			"Static", NULL,						        
    			WS_CHILD | WS_VISIBLE, 			
    			50, 50,	500, 70,						
    			hWnd, (HMENU)1,							
    			hInst, NULL);
    
    lpfnOldWndProc2 = (FARPROC)SetWindowLong(hstatic1,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);
    hstatic2 = CreateWindowEx(NULL,
    			"Static",						
    			"Intitulé du compte :",						        
    			WS_CHILD | WS_VISIBLE, 			
    			10, 10,	130, 22,						
    			hstatic1, (HMENU)1,							
    			hInst, NULL);
    
    hstatic3 = CreateWindowEx(WS_EX_CLIENTEDGE,
    			"Static",						
    			"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxY",						        
    			WS_CHILD | WS_VISIBLE, 			
    			140, 10, 330, 18,						
    			hstatic1, (HMENU)1,							
    			hInst, NULL);

  2. #2
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Normal, tu redéfinit la procédure que pour le 1er.

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    525
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2003
    Messages : 525
    Points : 212
    Points
    212
    Par défaut
    ça a pas l'air de mieux marcher ...
    Je ne comprends pas
    Le ctlcolor de la fenetre static1 est intercepté dans la procedure principale
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    case WM_CTLCOLORSTATIC :
    	        if ((HWND)lParam == hstatic1) {
                  SetBkColor ((HDC)wParam, RGB1);
                  return ((DWORD) hBrush); }
                return 0;
    Mais pour intercepter ceux des static2 et 3 dont la fenetre parent est hstatic1 ???
    Pour static2 et 3 ça ne remonte pas sur la procedure principale ?

  4. #4
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SetWindowLong(hstatic2,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);
    SetWindowLong(hstatic3,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);

  5. #5
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    525
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2003
    Messages : 525
    Points : 212
    Points
    212
    Par défaut
    En faisant pointer les 2 static sur la même procedure :
    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
    hstatic1 = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
    			"Static", NULL,						        
    			WS_CHILD | WS_VISIBLE, 			
    			50, 50,	500, 70,						
    			hWnd, (HMENU)1,							
    			hInst, NULL);
    
    lpfnOldWndProc1 = (FARPROC)SetWindowLong(hstatic1,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);
    hstatic2 = CreateWindowEx(WS_EX_LEFT,
    			"Static",						
    			"Intitulé du compte :",						        
    			WS_CHILD | WS_VISIBLE, 			
    			10, 10,	125, 18,						
    			hstatic1,
    			(HMENU)1,							
    			hInst, NULL);
    lpfnOldWndProc2 = (FARPROC)SetWindowLong(hstatic2,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);
    Le static1 n'a plus la couleur de fond et Le static2 ne s'affiche pas ...
    Je ne sais plus quoi faire dans la procedure !!!
    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
    switch (message) {
    	      case WM_CREATE:
                 MessageBox(hwnd, "WM_CREATE - PROCEDURE STATIC 1", "Programmation API Win32", MB_OK|MB_ICONINFORMATION);
                 return 0;
    
             case WM_PAINT:
                  hdc = BeginPaint(hwnd, &ps);
                  MessageBox(hwnd, "WM_PAINT - PROCEDURE STATIC 1", "Programmation API Win32", MB_OK|MB_ICONINFORMATION);
                  EndPaint (hwnd, &ps);
    
    		 case WM_CTLCOLORSTATIC :
                  MessageBox(hwnd, "WM_CTLCOLORSTATIC - PROCEDURE STATIC 1", "Programmation API Win32", MB_OK|MB_ICONINFORMATION);
    	          SetBkColor ((HDC)wParam, RGB1);
                  return ((DWORD) hBrush); 
            
    		}
    
    //
    return CallWindowProc(lpfnOldWndProc1, hwnd, message, wParam, lParam);
    }

  6. #6
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Tu doit redéfinir la couleur des static2 et 3 dans la procédure de static1, et laisse tomber ca:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SetWindowLong(hstatic2,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);
    SetWindowLong(hstatic3,
                                     GWL_WNDPROC, (DWORD) ProcStatic1);

  7. #7
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    525
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2003
    Messages : 525
    Points : 212
    Points
    212
    Par défaut
    Donc je fais pointer Static1 sur sa procedure, les 2 autres static etant enfants de static1.
    J'ai bien les fenetres Blanc sur fond bleu sauf la fenetre principale Static 1 qui n'a pas de fond ?
    voilà la proc
    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
    /*------------------------------------------------------------------*/
    /*                    PROCEDURE DE LA STATIC1                       */
    /*------------------------------------------------------------------*/
    LRESULT CALLBACK ProcStatic1(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    
    static HDC hdc;
    static RECT rc;
    static COLORREF RGBBLUE = RGB(0,0,255);
    static COLORREF RGBRED = RGB(255,0,0);
    static COLORREF RGBB;
    PAINTSTRUCT ps;
    static HBRUSH hBrush;
    HFONT       font;
    static COLORREF RGB1 = RGB(255, 255, 255);
    static char szText[50];
    
            switch (message) {
    	      case WM_CREATE:
                 return 0;
    
             case WM_PAINT:
                  hdc = BeginPaint(hwnd, &ps);
    
                  EndPaint (hwnd, &ps);
    
    		 case WM_CTLCOLORSTATIC :
    
                  SetTextColor ((HDC)wParam, RGB1);
                  SetBkColor ((HDC)wParam, RGBBLUE);
                  return ((DWORD) hBrush2); 
            
    		}
    
    //
    return CallWindowProc(lpfnOldWndProc1, hwnd, message, wParam, lParam);
    }

  8. #8
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Le fond de static1 doit etre définit dans la procedure de la fenetre parente de static1

  9. #9
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    525
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2003
    Messages : 525
    Points : 212
    Points
    212
    Par défaut
    J'ai retiré le WM_PAINT de la procedure Procstatitc1 et ça fonctionne !
    Merci encore.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Problème] WM_CTLCOLORSTATIC et background
    Par t0t0 dans le forum Windows
    Réponses: 6
    Dernier message: 12/06/2006, 15h43

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