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

Composants VCL Delphi Discussion :

Pb avec une subsitution de touche :(


Sujet :

Composants VCL Delphi

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 6
    Points : 6
    Points
    6
    Par défaut Pb avec une subsitution de touche :(
    Bonjour

    Voila mon soucis j'aimerais que la touche TAB agisse comme l'appuie de la touche ENTER...

    Et j'ai deja essayer avec les evenements KeyPress, KeyDown, KeyPress...

    J'ai bien tenté avec la procedure WndProc...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
      if (msg.WParam = 9) and
         not (GetKeyState(vk_control)<0) and
         not (GetKeyState(vk_menu)<0) and
         ( FmInventaire.ActiveControl.Handle =  wwDbGrid_Comptage.Handle ) then
      begin
        if (msg.WParam and $80000000)=0 then
        begin
          msg.WParam := 0;
          msg.Result := 1;
          wwDbGrid_Comptage.Dispatch(Msg);
     
    //      if ( (Msg.Msg = WM_KEYUP) OR (Msg.Msg = WM_KEYDOWN) ) then
            wwDbGrid_Comptage.Perform(WM_KEYDOWN, 13, 1);
        end
    La tabulation ne fonctionne plus... ca c'est ce que je voulais en partie mais elle n'agit pas comme la touche ENTER...

    Alors si vous pouviez m'aider a sortir de cette melasse vous seriez gentil

  2. #2
    Membre émérite
    Avatar de Merlin
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2002
    Messages
    524
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information

    Informations forums :
    Inscription : Mars 2002
    Messages : 524
    Points : 2 883
    Points
    2 883
    Par défaut
    Title: How to make the [Enter] key behave like the [Tab] key
    Author: Jonas Bilinkevicius
    Product: Delphi 1.x (or higher)
    Post Date: 10/01/2002

    Problem/Question/Abstract:

    How to make the [Enter] key behave like the [Tab] key

    Answer:

    Solve 1:

    You need to trap the keystroke and set up your own response to it. Try this: (Note: This will not work within a DBGrid, since the next field is not a separate object.)

    procedure TMainForm.FormCreate(Sender: TObject);
    begin
    keyPreview := true; {To turn the event "ON"}
    end;

    procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
    begin
    if Key = #13 then
    begin
    Key := #0;
    PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
    end;
    end;


    Solve 2:

    Use this code for example for an TEdit's OnKeyPress event:

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    if Key = #13 then
    begin
    SelectNext(Sender as TWinControl, True, True);
    Key := #0;
    end;
    end;

    This causes Enter to behave like tab. Now, select all controls on the form you'd like to exhibit this behavior (not Buttons) and go to the Object Inspector and set their OnKeyPress handler to EditKeyPress. Now, each control you selected will process Enter as Tab. If you'd like to handle this at the form (as opposed to control) level, reset all the controls OnKeyPress properties to blank, and set the form's OnKeyPress property to EditKeyPress. Then, change Sender to ActiveControl and set the form's KeyPreview property to true:

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    if Key = #13 then
    begin
    SelectNext(ActiveControl as tWinControl, True, True);
    Key := #0;
    end;
    end;

    This will cause each control on the form (that can) to process Enter as Tab.


    Solve 3:

    Handle this in the OnKeyPress event. The form's KeyPreview property must be set to true.

    procedure TFrmEnterTab.FormKeyPress(Sender: TObject; var Key: Char);
    begin
    if Key = Chr(VK_RETURN) then
    begin
    if GetKeyState(VK_SHIFT) < 0 then
    SelectNext(ActiveControl, false, true)
    else
    SelectNext(ActiveControl, true, true);
    Key := #0;
    end;
    end;

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 6
    Points : 6
    Points
    6
    Par défaut Merci...
    Merci pour ton aide... Je vais essayer de suite

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

Discussions similaires

  1. un evenement avec une combinaison de touches
    Par reeda dans le forum Windows Forms
    Réponses: 5
    Dernier message: 11/06/2009, 20h16
  2. Réponses: 20
    Dernier message: 27/11/2007, 14h40
  3. comment fermer l'executable avec une touche?
    Par bilou_2007 dans le forum C
    Réponses: 12
    Dernier message: 03/11/2007, 09h08
  4. Un système de tutos avec une touche de XML
    Par nicknick63 dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 06/06/2007, 15h26
  5. [Tableaux] pb avec une touche
    Par xtiand4 dans le forum Langage
    Réponses: 21
    Dernier message: 23/06/2006, 14h22

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