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 :

Focus et controles ...


Sujet :

Windows

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 528
    Points : 217
    Points
    217
    Par défaut Focus et controles ...
    Bonjour,
    j'ai créé une fetre static qui me sert de fond, qui est subclassée sur un procedure ProcPrelev. J' ai ensuite plusieurs controles enfants qui sont traités par la procedure ProcPrelev
    Dans cette derniere procedure je n'arrive pas a gerer le focus...
    Voilà un bout de 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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    hprelev = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, 
    			            "Static", "", WS_BORDER | WS_CHILD | WS_VISIBLE | SS_NOTIFY, 			
    			            15, 5,	600, 355,						
    			            hWnd, (HMENU)1,	hInst, NULL);
               lpfnOldWndProc3 = (FARPROC)SetWindowLong(hprelev,
                                     GWL_WNDPROC, (DWORD) ProcPrelev);
               hsttitre = CreateWindowEx(WS_EX_LEFT,
    			              "Static", "",	WS_CHILD | WS_VISIBLE, 			
    			              150, 2, 280, 30,						
    			              hprelev, (HMENU)1, hInst, NULL);
               SendMessage (hsttitre, WM_SETFONT, (UINT)hFont3, 0);
    		   SetWindowText(hsttitre, "Gestion des prelèvements ...");
    hstobj = CreateWindowEx(WS_EX_LEFT,
    			              "Static", "",	WS_CHILD | WS_VISIBLE, 			
    			              20, 45, 380, 18,						
    			              hprelev, (HMENU)1, hInst, NULL);
    
               SetWindowText (hstobj, cp.LibCompte);
    for &#40;is=175,js=0; js<6; is+=25, js++&#41; &#123;
               hckbxprel&#91;js&#93; = CreateWindow&#40;"Button", "",
                              BS_AUTOCHECKBOX|WS_VISIBLE|WS_CHILD|WS_GROUP,
                              5, is, 18, 18, hprelev, NULL, hInst, NULL&#41;;
               hbtsel&#91;js&#93; = CreateWindowEx&#40;WS_EX_CLIENTEDGE,
    			             "Button", "",
                              WS_VISIBLE|WS_CHILD|WS_GROUP|BS_PUSHBUTTON,
                              25,is,18,18, hprelev, NULL, hInst, NULL&#41;;
               SendMessage &#40;hbtsel&#91;js&#93;, WM_SETFONT, &#40;UINT&#41;hFont2, 0&#41;;
    		   SetWindowText &#40;hbtsel&#91;js&#93;, "S"&#41;;
    
               hdateprel&#91;js&#93; = CreateWindowEx&#40;WS_EX_LEFT|WS_EX_CLIENTEDGE,
    			              "Edit", "",	WS_CHILD | WS_VISIBLE|ES_READONLY, 			
    			              45, is, 70, 18,						
    			              hprelev, &#40;HMENU&#41;1, hInst, NULL&#41;;
               SendMessage &#40;hdateprel&#91;js&#93;, WM_SETFONT, &#40;UINT&#41;hFont2, 0&#41;;
    
               hmontprel&#91;js&#93; = CreateWindowEx&#40;WS_EX_LEFT|WS_EX_CLIENTEDGE,
    			              "Edit", "",	WS_CHILD | WS_VISIBLE, 			
    			              125, is, 60, 18,						
    			              hprelev, &#40;HMENU&#41;1, hInst, NULL&#41;;
               SendMessage &#40;hmontprel&#91;js&#93;, WM_SETFONT, &#40;UINT&#41;hFont2, 0&#41;;
    		 &#125;
    J'ai bien essayé de coder un WM_SETFOCUS ou un KILLFOCUS, mais il y repond seulement en quittant la fenetre ???
    Comment puis gerer le curseur ?
    Merci.

  2. #2
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Salut
    As-tu essayé avec EN_SETFOCUS et EN_KILLFOCUS
    Citation Envoyé par MSDN
    EN_SETFOCUS
    The EN_SETFOCUS notification message is sent when an edit control receives the keyboard focus. The parent window of the edit control receives this notification message through a WM_COMMAND message.

    LRESULT CALLBACK WindowProc(
    HWND hwnd, // handle to window
    UINT uMsg, // WM_COMMAND
    WPARAM wParam, // edit control identifier, EN_SETFOCUS
    LPARAM lParam // handle to edit control (HWND)
    );
    Parameters
    wParam
    The low-order word specifies the edit control identifier.
    The high-order word specifies the notification message.

    lParam
    Handle to the edit control.
    Remarks
    The parent window will always get a WM_COMMAND message for this event, it does not require a notification mask sent with WM_SETEVENTMASK.

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 528
    Points : 217
    Points
    217
    Par défaut
    Citation Envoyé par Trap D
    Salut
    As-tu essayé avec EN_SETFOCUS et EN_KILLFOCUS
    J'ai essayé, Je n'ai aucune reponse sur ces notifications ....(???)

  4. #4
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Tu pourrais montrer le code de ProcPrelev ?

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 528
    Points : 217
    Points
    217
    Par défaut
    Citation Envoyé par Trap D
    Tu pourrais montrer le code de ProcPrelev ?
    Hello,
    le voilà ...
    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
    LRESULT CALLBACK ProcPrelev&#40;HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam&#41; &#123;
    
    static int etat=0;
    int i;
    static int action=0;
    static COLORREF RGB1 = RGB&#40;190, 240, 255&#41;;
    static COLORREF RGBPREL = RGB&#40;0, 150, 255&#41;;
    static COLORREF RGBBLANC  = RGB&#40;255, 255, 255&#41;;
    PRELEV prelev;
    
            switch &#40;message&#41; &#123;
    	      case WM_CREATE&#58;
                 return 0;
    
    		  case WM_CTLCOLORSTATIC &#58;
    			  for &#40;i=0; i<19; i++&#41; &#123;
                    if &#40;&#40;HWND&#41;lParam == hdateprel&#91;i&#93;&#41; &#123;
                      SetBkColor &#40;&#40;HDC&#41;wParam, RGB1&#41;;
    		          SetTextColor &#40;&#40;HDC&#41;wParam, RGB&#40;0, 0, 0&#41;&#41;;
                      return &#40;&#40;DWORD&#41; hBrush&#41;;
    				&#125;
    			  &#125;
    			if &#40;&#40;&#40;HWND&#41;lParam == hsttitre&#41;&#41;
    			&#123;
                  SetBkMode &#40;&#40;HDC&#41;wParam, TRANSPARENT&#41;;
                  SetBkColor &#40;&#40;HDC&#41;wParam, RGBPREL&#41;;
                  SetTextColor &#40;&#40;HDC&#41;wParam, RGBBLANC&#41;;
                  return &#40;&#40;DWORD&#41; hBrushPrel&#41;;
    			&#125;
                SetBkColor &#40;&#40;HDC&#41;wParam, RGBPREL&#41;;
                return &#40;&#40;DWORD&#41; hBrushPrel&#41;;
    		
            case WM_DESTROY&#58;
                ShowWindow&#40;hstatic1, SW_SHOW&#41;;
                ShowWindow&#40;hstattitre, SW_SHOW&#41;;
                ShowWindow&#40;hwndmvts, SW_SHOW&#41;;
                return 0;
    
            case WM_COMMAND&#58;
               switch &#40;wParam&#41;
    		   &#123;
               case BN_CLICKED&#58;
                 if &#40;lParam == hfermer&#41;
                   DestroyWindow&#40;hprelev&#41;;
    //Creation
                 if &#40;lParam == hbtnouveau&#41; &#123;
                   ShowWindow&#40;hlistprel, SW_HIDE&#41;;
                   ShowWindow&#40;heditnew, SW_SHOW&#41;;
                   EnableWindow &#40;hbtnouveau, FALSE&#41;;
                   SetWindowText&#40;hbtmod, "Valider"&#41;;
                   SetWindowText&#40;hbtsupp, "Annuler"&#41;;
    			   action=1;
    			 &#125;
    //Annuler Creation
    			 if &#40;lParam == hbtsupp&#41; &#123;
    				 if &#40;action == 1&#41; &#123;
                       SetWindowText&#40;hbtmod, "Modifier"&#41;;
                       SetWindowText&#40;hbtsupp, "Supprimer"&#41;;
                       EnableWindow &#40;hbtnouveau, TRUE&#41;;
                       ShowWindow&#40;hlistprel, SW_SHOW&#41;;
                       ShowWindow&#40;heditnew, SW_HIDE&#41;;
                       action=0;
    				 &#125;
    			 &#125;
    //Valider Creation
                 if &#40;lParam == hbtmod&#41; &#123;
                   if &#40;action == 1&#41; &#123;
                     strcpy&#40;prelev.cpt_prelev, compte_courrant&#41;;
                     GetWindowText&#40;heditnew, prelev.lib_prelev, sizeof&#40;prelev.lib_prelev&#41;&#41;;
                     MessageBox&#40;hwnd, prelev.lib_prelev, "Prelevements ...", MB_OK|MB_ICONINFORMATION&#41;;
    			   &#125;
    			 &#125;
    			 for &#40;i=0; i<19; i++&#41; &#123;
                   if &#40;lParam == hbtsel&#91;i&#93;&#41; &#123;
                     
                     hcalend = CreateWindowEx&#40;WS_EX_CLIENTEDGE,MONTHCAL_CLASS,
                         "",
                         WS_BORDER | WS_CHILD | WS_VISIBLE | MCS_NOTODAY | MCS_DAYSTATE,
                         418,2,175,150, 
                         hwnd, NULL, hInst, NULL&#41;;
    			   &#125;
    			 &#125;
    
    		   &#125;
    		&#125;
    
    
    
    
    return CallWindowProc&#40;lpfnOldWndProc3, hwnd, message, wParam, lParam&#41;;
    &#125;

  6. #6
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Dans le WM_COMMAND, tu as enlevé le EN_SETFOCUS car il ne fonctionnait pas ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
            case WM_COMMAND&#58;
              switch &#40;wParam&#41;
             &#123;
               case EN_SETFOCUS&#58;
                   MessageBox&#40;hwnd, "Youpi ça marche", "Test", MB_OK&#41;;
                    return 0;
                <......>
             &#125;

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 528
    Points : 217
    Points
    217
    Par défaut
    Citation Envoyé par Trap D
    Dans le WM_COMMAND, tu as enlevé le EN_SETFOCUS car il ne fonctionnait pas ?
    Oui, je ne capte aucune notification des "edit" !!!

  8. #8
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Salut, je viens de voir dans la Doc MSDN ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
                if&#40;HIWORD &#40;wParam&#41; == EN_CHANGE && 
                        LOWORD&#40;wParam&#41; == IDE_PASSWORDEDIT&#41; 
                &#123;
                    <................>
                 &#125;
    C'est paut-être celà qu'il faut tester :HIWORD(wPram) == EN_SETFOCUS)

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 528
    Points : 217
    Points
    217
    Par défaut
    ça marche pas mieux ...
    Je desespere, normalement le fait de pointer le curseur sur un edit doit déclancher un "en_setfocus"
    comment se fait il que je ne recoive rien ???

  10. #10
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Bon, j'ai trouvé :
    Citation Envoyé par MSDN
    Edit controls that are not in a dialog box use the data segment (DS) of their parent for the edit control's local heap. The amount of text an edit control can store is affected by the amount of memory that has already been used in this heap. To maximize the amount of text that an edit control can contain, the application should supply a heap for the edit control that has not been used for any other allocations. To do this, an application should perform the following steps
    Citation Envoyé par MSDN
    hEditDS = GlobalAlloc(GMEM_MOVEABLE |
    GMEM_ZEROINIT | GMEM_SHARE, 256L);
    if (hEditDS == NULL) {
    // Allocation failed; use default.
    hEditDS = hInst;
    }

    //
    // Create the edit control.
    // Pass the local heap handle in hInstance.
    hwndEdit = CreateWindow("edit", NULL,
    WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL |
    WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL |
    ES_AUTOVSCROLL,
    10, 10, 250, 200, hWnd, IDEDITCTL, hEditDS, NULL);

    // Now limit the text to the maximum possible amount.
    //
    SendMessage(hwndEdit, EM_LIMITTEXT, 0, 0L);

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

Discussions similaires

  1. [AC-2003] Focus dans controle onglet
    Par Aladin_23 dans le forum IHM
    Réponses: 2
    Dernier message: 24/09/2010, 21h48
  2. pb pour donner le focus à un controle.
    Par patou41000 dans le forum C++/CLI
    Réponses: 2
    Dernier message: 01/05/2007, 16h09
  3. Donner le focus au controle du sous-formulaire
    Par Invité dans le forum IHM
    Réponses: 2
    Dernier message: 26/01/2007, 19h18
  4. [MFC] tab control et focus
    Par Grey dans le forum MFC
    Réponses: 2
    Dernier message: 14/11/2005, 13h30
  5. [VB.NET] Comment récupérer le nom d'un control avec le focus
    Par jayce007 dans le forum Windows Forms
    Réponses: 5
    Dernier message: 20/01/2005, 00h53

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