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 :

Editeur de masque - C++ Builder 6


Sujet :

C++Builder

  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2008
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2008
    Messages : 27
    Points : 20
    Points
    20
    Par défaut Editeur de masque - C++ Builder 6
    Bonjour,

    je voulais savoir si quelqu'un pourrait m'expliquer comment fonctionne les masques et comment en créer de nouveaux en mélangeant chiffres, lettres, ...

    Merci de votre aide

    Nom : editeur_masque.png
Affichages : 649
Taille : 12,9 Ko

  2. #2
    Membre chevronné
    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
    Points : 2 187
    Points
    2 187
    Billets dans le blog
    1
    Par défaut
    Salut
    Voir Explication en adglais qui est à la portée de tout un chacun aujourd'hui
    Bonne lecture
    Cdlt


    The MaskEdit Control


    Introduction

    The MaskEdit is a special Edit object that provides more control over text entered or displaying in an edit box. The biggest difference between the Edit and the MaskEdit controls is the masking possibilities available on the latter.

    To add a MaskEdit control to your form, from the Additional tab of the Tool Palette, click the MaskEdit button and click on the form.

    MaskEdit Characteristics

    The most important property of a MaskEdit control, which sets it apart from the (traditional) Edit control, is its ability to control what the user can and cannot enter in the text side. To configure this text, on the Object Inspector, click the EditMask field to reveal its ellipsis button. You have two options:

    If you are familiar with the masking properties of this control, you can type a value using the appropriate symbols. Otherwise you should use an appropriate dialog box to guide you. You have two alternatives. You can double-click the empty area of the EditMask field or you can click the ellipsis button. This would call the Input Mask Editor dialog box

    Nom : inputmask1.gif
Affichages : 555
Taille : 14,4 Ko

    Once there, you have various alternatives. The easiest way is to select one of the available formats in the Sample Masks list. Once you select a sample, its formatted mask displays in the Input Mask edit box. If the format is satisfying, you can click OK. Otherwise, you can add or delete symbols in the Input Mask edit box as you see fit.
    If none of the samples matches your desired format and you know the symbols used, you can type your own. You can also check masks created for foreign languages to see if one of them would have the mask you need. To do this, click the Masks… button. This would call the Open Mask File dialog box:

    Nom : openmask1.gif
Affichages : 542
Taille : 17,6 Ko

    Click one file with a .dem extension and click OK. With the new mask in the Input Mask Editor, examine the samples in the Sample Masks list and select one. You can still customize any of the available masks.

    Another alternative is to create your own list of masks. To do this, follow the format used to create a mask. This is:

    Name | Sample | Mask

    This line is made of three sections. The first and the second, then the second and the third are separated by a beam. To see a sample file, using Notepad, locate the C:\Program Files\Borland\Cbuilder6\Bin folder. After changing the Files of Type to All files, click one of the files with .dem extensions:

    Nom : open2.gif
Affichages : 479
Taille : 47,7 Ko


    Click Open:
    Nom : notepad1.gif
Affichages : 465
Taille : 12,2 Ko


    Create a new file following the example. Each mask is typed on its own line and press Enter at the end of each mask. To save the file, locate the C:\Program Files\Borland\Cbuilder5\Bin folder. In the Save dialog box, change the Save As Type to All Files. Type a name in one-word followed by an extension .dem extension. To use your list of masks, invoke the Input Mask Editor, click Masks… Locate the C:\Program Files\Borland\Cbuilder5\Bin folder. Change the Files of Types to All files. Click the file you created and click Open.

    You can also set a mask programmatically using the symbols appropriate for the masks. Here is an example:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    //---------------------------------------------------------------------------
    void __fastcall TForm1::FormCreate(TObject *Sender)
     {
         // Mask for an 8 character file name + 3-character extension
        // The first character is automatically converted to uppercase
         // After the first character, the user can enter an alphabetical
         // character or a digit to complete the 8 characters.
         // The other 7 characters and the extensions are converted to lowercase
         edtFileName->EditMask = ">L<aaaaaaa.<LLL;1;_";
     }
     //---------------------------------------------------------------------------
    As a text-based control, the content of the MaskEdit control is represented by the Text property, which is an AnsiString object. Following the EditMask you had set in the Input Mask Editor editor, you can use a default text that would display when the control opens. To set this text, on the Object inspector, click Text and type a value that abides by the rules of the EditText field. At design time, C++ Builder will assist you and make sure that the value you type is appropriate. At runtime also, the user will have to follow the rules of the mask.

    When a mask is configured for a MaskEdit control, the compiler reinforces the rule to make sure the user would follow number and types of characters allowed in the edit box. If you add a MaskEdit control but do not apply a mask to it, you can limit the number of characters that the user can enter in the box. The maximum number of characters allowed is set using the MaxLength property. This property has any effect only if no mask is applied to the control. At design time, type an integer value for the property. At runtime, assign an appropriate value to the control.

    The IsMasked Boolean property can be used to check whether a MaskEdit control has been configured with a mask already.

    MaskEdit Methods

    On its own, the MaskEdit control has only two methods: the constructor and the destructor. The TMaskEdit constructor is used to dynamically create a MaskEdit object. This requires an instance of a TMaskEdit class. Using the new operator, specify the owner of the control. You must also specify the parent of the variable. Here is an example:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
     {
         TMaskEdit *Mascot = new TMaskEdit(Form1);
         Mascot->Parent = Form1;
     }
     //---------------------------------------------------------------------------
    A MaskEdit object created like this is just a classic Edit control. If you want to make a true MaskEdit object, set its properties as needed, namely an EditMask and possibly a Text properties. This time, not only will you have to work in a non-visual setting but you should also make sure that the EditMask and the Text properties are synchronized. Sometimes, this would involve trial-and-error.

    MaskEdit Events

    The main event of the MaskEdit control occurs when the content of the control has been altered. The compiler takes care of validating the characters and symbols while the user is editing the edit box. When the user has finished and presses Enter or Tab to possibly shift the focus to another control, a notification is sent to the operating system. If the value entered in the control does not conform to the EditMask property, an error is thrown and the application may stop responding. For this reason, you should use the MaskEdit control only when appropriately needed; or you should write an event handler or function that would deal with errors of this control.
    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

Discussions similaires

  1. Editeur de masque de saisie
    Par Ghilas1985 dans le forum Bases de données
    Réponses: 1
    Dernier message: 06/11/2009, 08h52
  2. Outils, cours et NOUVEAUX tutoriels pour Borland C++Builder
    Par hiko-seijuro dans le forum C++Builder
    Réponses: 10
    Dernier message: 12/03/2006, 22h33
  3. c++ builder JavaDoc :)
    Par JEG dans le forum C++Builder
    Réponses: 8
    Dernier message: 08/06/2002, 13h31
  4. Documentation DirectX dans C++Builder 3
    Par srvremi dans le forum DirectX
    Réponses: 1
    Dernier message: 26/04/2002, 09h59
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

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