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

C++Builder Discussion :

Transformer un Enter en tabulation


Sujet :

C++Builder

  1. #1
    Membre �clair�
    Profil pro
    Inscrit en
    Ao�t 2002
    Messages
    481
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2002
    Messages : 481
    Par d�faut Transformer un Enter en tabulation
    Bonjour � tous,
    Je travaille avec C++ Builder XE6.
    j'ai un probl�me dont je ne comprends pas l'origine.
    Dans un KeyPress je veux transformer un Enter ('r' ou VK_RETURN) en tabulation.
    J'utilisais sans probl�me :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    	if(Key =='r')
    	{
    		Key=0; // pour éviter le beep
    		//ShowMessage("Vers NextControl");
    		FindNextControl(dynamic_cast<TWinControl*>(Sender),true,true,false)->SetFocus();
    	}
    Actuellement avec le code suivant :
    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
    	void __fastcall TfNouveau::eSystoleKeyPress(TObject *Sender, System::WideChar &Key)
    {
    	ShowMessage("Entrée dans eSystoleKeyPress");
    	if(Key == VK_RETURN)  // ou if(Key == 'r')
    	{
    		Key=0; // pour éviter le beep
    		ShowMessage("Vers NextControl");
    		FindNextControl(dynamic_cast<TWinControl*>(Sender),true,true,false)->SetFocus();
    	}
    	else
    	{
    	 char DecimalSeparator = '.';
    	 if ((Key < '0' || Key >'9') && Key != 8 && (Key != DecimalSeparator ||
    												((TEdit *)Sender)->Text.Pos(DecimalSeparator)!=0))
    																														Key = NULL;
    	}
    }
    //-----------------
    Non seulement il n'y a pas la transformation du Retour chariot en tabulation, mais il n'y a pas le message "Entr�e dans eSystoleKeyPress".
    Quelle peut �tre la cause de ce comportement ?
    Merci de votre aide.

  2. #2
    Membre Expert
    Avatar de DjmSoftware
    Homme Profil pro
    Responsable de compte
    Inscrit en
    Mars 2002
    Messages
    1 044
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Responsable de compte
    Secteur : High Tech - Op�rateur de t�l�communications

    Informations forums :
    Inscription : Mars 2002
    Messages : 1 044
    Billets dans le blog
    1
    Par d�faut
    Salut
    il me semble qu'il y aie une certaine confusion
    en effet 'r' n'est pas �gal � VK_RETURN mais � 0x0D

    ton code n'est il pas tir� de http://http://swag.outpostbbs.net/DELPHI/0079.PAS.html

    Dans ce cas ta traduction est incorrecte
    je verrais plut�t ceci
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
     
     
    void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
    {
    	 if ((Key ==0x0d)
                SelectNext(dynamic_cast<TWinControl*>(Sender),true,true);
             Key=0;								
    	}
    vous trouverez mes tutoriels � l'adresse suivante: http://djmsoftware.developpez.com/
    je vous en souhaite une excellente lecture ...

    A lire : Les r�gles du forum

  3. #3
    Membre �clair�
    Profil pro
    Inscrit en
    Ao�t 2002
    Messages
    481
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2002
    Messages : 481
    Par d�faut
    Merci.
    Dans mon exemple la fonction est :
    void __fastcall TfNouveau::eSystoleKeyPress(TObject *Sender, System::WideChar &Key)
    Puis je changer le en ?

  4. #4
    Membre Expert
    Avatar de DjmSoftware
    Homme Profil pro
    Responsable de compte
    Inscrit en
    Mars 2002
    Messages
    1 044
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Responsable de compte
    Secteur : High Tech - Op�rateur de t�l�communications

    Informations forums :
    Inscription : Mars 2002
    Messages : 1 044
    Billets dans le blog
    1
    Par d�faut
    bonjour
    cela d�pend de la mani�re d'on ce code est appel�

    comment est d�clar� dans ton code TfNouveau::eSystoleKeyPress
    TfNouveau est il un descendant de Tform?
    eSystoleKeyPress est il une surcharge de FormKeyPress?
    dans le cas contraire pourquoi n''utilise tu pas la m�thode FormKeyPress de Tform avec l'impl�mentation que je t'ai fournie


    le code de ta classe TfNouveau est n�cessaire pour apporter une aide efficace

    cdlt
    vous trouverez mes tutoriels � l'adresse suivante: http://djmsoftware.developpez.com/
    je vous en souhaite une excellente lecture ...

    A lire : Les r�gles du forum

  5. #5
    Membre �clair�
    Profil pro
    Inscrit en
    Ao�t 2002
    Messages
    481
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2002
    Messages : 481
    Par d�faut
    Merci, j'ai appliqu� votre proposition.
    J'ai une r�ponse du compiler que je ne comprends pas.
    Je l'ai appliqu�e dans deux KeyPress.
    J'obtiens une seule erreur disant que je fais appel � une fonction inexistante.
    Elle ne concerne que l'un des 2 KeyPress
    Il s'agit de FindNext'�.

  6. #6
    Membre Expert
    Avatar de DjmSoftware
    Homme Profil pro
    Responsable de compte
    Inscrit en
    Mars 2002
    Messages
    1 044
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Responsable de compte
    Secteur : High Tech - Op�rateur de t�l�communications

    Informations forums :
    Inscription : Mars 2002
    Messages : 1 044
    Billets dans le blog
    1
    Par d�faut
    Salut
    voici un petit exemple avec 8 EditBox sur 1 fiche, ayant comme capacit� d'�tre s�lectionnable soit par la touche Tab ou la touche Enter(Return)
    a chaque fois qu'une EditBox est s�lectionn�e sa couleur change, lors de la d�s�lection sa couleur revient celle par d�faut.
    pour ce faire l'event OnKeyPress de chaque EditBox est renseign� par une m�thode commune LabelKeyPress

    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
     
     
    // la form en format Texte
    object Form117: TForm117
      Left = 0
      Top = 0
      Caption = 'Form117'
      ClientHeight = 261
      ClientWidth = 185
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Edit1: TEdit
        Left = 35
        Top = 25
        Width = 121
        Height = 21
        TabOrder = 0
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit2: TEdit
        Left = 35
        Top = 52
        Width = 121
        Height = 21
        TabOrder = 1
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit3: TEdit
        Left = 35
        Top = 81
        Width = 121
        Height = 21
        TabOrder = 2
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit4: TEdit
        Left = 35
        Top = 109
        Width = 121
        Height = 21
        TabOrder = 3
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit5: TEdit
        Left = 35
        Top = 138
        Width = 121
        Height = 21
        TabOrder = 4
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit6: TEdit
        Left = 35
        Top = 166
        Width = 121
        Height = 21
        TabOrder = 5
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit7: TEdit
        Left = 35
        Top = 195
        Width = 121
        Height = 21
        TabOrder = 6
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
      object Edit8: TEdit
        Left = 35
        Top = 222
        Width = 121
        Height = 21
        TabOrder = 7
        OnEnter = EditEnter
        OnExit = EditExit
        OnKeyPress = LabelKeyPress
      end
    end
     
    // le hpp
    //---------------------------------------------------------------------------
     
    #ifndef Unit117H
    #define Unit117H
    //---------------------------------------------------------------------------
    #include <System.Classes.hpp>
    #include <Vcl.Controls.hpp>
    #include <Vcl.StdCtrls.hpp>
    #include <Vcl.Forms.hpp>
    //---------------------------------------------------------------------------
    class TForm117 : public TForm
    {
    __published:	// Composants gérés par l'EDI
    	TEdit *Edit1;
    	TEdit *Edit2;
    	TEdit *Edit3;
    	TEdit *Edit4;
    	TEdit *Edit5;
    	TEdit *Edit6;
    	TEdit *Edit7;
    	TEdit *Edit8;
        void __fastcall LabelKeyPress(TObject *Sender, System::WideChar &Key);
    	void __fastcall EditEnter(TObject *Sender);
    	void __fastcall EditExit(TObject *Sender);
     
    private:	// Déclarations utilisateur
    public:		// Déclarations utilisateur
    	__fastcall TForm117(TComponent* Owner);
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TForm117 *Form117;
    //---------------------------------------------------------------------------
    #endif
     
     
    // le cpp
    // ---------------------------------------------------------------------------
     
    #include <vcl.h>
    #pragma hdrstop
     
    #include "Unit117.h"
    // ---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm117 *Form117;
     
    // ---------------------------------------------------------------------------
    __fastcall TForm117::TForm117(TComponent* Owner)
    	: TForm(Owner)
    {
     
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TForm117::LabelKeyPress(TObject *Sender, System::WideChar &Key)
    {
    	if (Key == 0x0D)
    	{
    		SelectNext(dynamic_cast<TWinControl*>(Sender), true, true);
    		Key = 0;
    	}
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TForm117::EditEnter(TObject *Sender)
    {
    	dynamic_cast<TEdit*>(Sender)->Color = (TColor)10483700;
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TForm117::EditExit(TObject *Sender)
    {
    	dynamic_cast<TEdit*>(Sender)->Color = clWindow;
    }
    // ---------------------------------------------------------------------------
    important
    l'�venement OnKeyPress de TForm est d�clench� uniquement si la propri�t� KeyPreview est �gal � true
    voir :http://docs.embarcadero.com/products...eyPreview.html


    cdlt
    vous trouverez mes tutoriels � l'adresse suivante: http://djmsoftware.developpez.com/
    je vous en souhaite une excellente lecture ...

    A lire : Les r�gles du forum

  7. #7
    Membre �clair�
    Profil pro
    Inscrit en
    Ao�t 2002
    Messages
    481
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2002
    Messages : 481
    Par d�faut
    Merci, j'essaie de me d�brouiller avec le fichier que vous m'avez transmis.
    Je vous tiendrai au courant.

Discussions similaires

  1. Datagridview, enter et tabulation
    Par kolosawoi dans le forum Windows Forms
    R�ponses: 1
    Dernier message: 18/03/2007, 10h37
  2. [HTML][formulaire] remplacer "Enter" par "tabulation"
    Par anti-conformiste dans le forum Balisage (X)HTML et validation W3C
    R�ponses: 4
    Dernier message: 05/11/2006, 21h29
  3. comment je peux faire une tabulation avec Enter
    Par iam dans le forum Bases de donn�es
    R�ponses: 3
    Dernier message: 26/04/2006, 20h41
  4. [LG] Transformer une tabulation par un espace
    Par JoseF dans le forum Langage
    R�ponses: 2
    Dernier message: 28/12/2005, 22h24
  5. [Editeur] Transformer tabulation en espace
    Par Oliveuh dans le forum Eclipse Java
    R�ponses: 1
    Dernier message: 07/11/2005, 15h29

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