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 :

[Delphi 7] [RichEdit] ScrollBar récalcitrant


Sujet :

Composants VCL Delphi

  1. #1
    Membre chevronné
    Avatar de Droïde Système7
    Homme Profil pro
    Inscrit en
    Septembre 2003
    Messages
    2 262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 2 262
    Points : 1 928
    Points
    1 928
    Par défaut [Delphi 7] [RichEdit] ScrollBar récalcitrant
    Bonjour à Tous,


    Je n'arrive pas à faire bouger le ScrollBar du RichEdit sur la ligne correspondante à l'occurrence trouvée.


    Il semble que le classique :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    RichEdit1.Perform(EM_SCROLLCARET, 0, 0);
    Soit ici sans aucun effet...


    (Source : http://www.tek-tips.com/viewthread.cfm?qid=397710 )



    Voici le code qui me donne du fil à retordre :
    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
    function TForm1.FindText( const SearchStr: string;
                   StartPos, FindLength : LongInt; Options: TSearchTypes;
                   SearchDown : Boolean = TRUE ): Integer;
    var
    Find: TFindText;
    Flags: Word;
     
       begin
           with Find do
       begin
          chrg.cpMin := StartPos;
          chrg.cpMax := StartPos + FindLength;
          lpstrText := PChar(SearchStr);
             end;
     
    Flags := 0;
     
    if stWholeWord in Options then
       Flags := Flags or FT_WHOLEWORD
    else
       Flags := Flags and not FT_WHOLEWORD;
     
    if stMatchCase in Options then
       Flags := Flags or FT_MATCHCASE
    else
       Flags := Flags and not FT_MATCHCASE;
     
    if SearchDown then
       Flags := Flags OR $01
          else
       begin
       //Flags := Flags AND not $01;     // Search Up, just does not work !
       Flags := Flags OR $01
       end;
     
    Result := -1;
     
    if SearchDown then
       Result := SendMessage(RichEdit1.Handle, EM_FINDTEXT, Flags, LongInt(@Find))
    else
       // Search Up, just does not work !  So just search down over and over
       // adjusting the start point backward.
       while (StartPos > -1) and (result = -1) do
          begin
          //result := RichEdit1.Perform(EM_FindText, Flags, LongInt(@Find));
          Result := SendMessage(RichEdit1.Handle, EM_FINDTEXT, Flags, LongInt(@Find));
          Dec(StartPos);
          Find.chrg.cpMin := StartPos;
        end;
    end;
     
     
     
     
     
    procedure TForm1.FindDialogFind(Sender: TObject);
       var
          FoundAt: LongInt;
          StartPos, FindLength, ToEnd : LongInt;
          TheFindOptions   : TFindOptions; 
          TheSearchTypes  : TSearchTypes;
        begin
          TheFindOptions := [];
          TheSearchTypes := [];
     
    if frDown in FindDialog.Options then
         begin
            StartPos := RichEdit1.SelStart + RichEdit1.SelLength;
            FindLength := Length(RichEdit1.Text) - StartPos;
                 end
             else
        begin
            StartPos := RichEdit1.SelStart;
            FindLength := 0;
         end;
     
             with Sender as TFindDialog do
         begin
             if frMatchCase in Options then
                   TheSearchTypes := TheSearchTypes + [stMatchCase];
             if frWholeWord in Options then
                   TheSearchTypes := TheSearchTypes + [stWholeWord];
                 end;
            FoundAt := FindText(FindDialog.FindText, StartPos, FindLength, TheSearchTypes,  (frDown in FindDialog.Options) );
               if FoundAt <> -1 then
           begin
               RichEdit1.SetFocus;
                 RichEdit1.SelStart := FoundAt;
                 RichEdit1.SelLength := Length(FindDialog.FindText);
                   end
                else
       MessageDlg('"' + FindDialog.FindText + '" not found.', mtInformation, [mbOk], 0);
    end;


    Merci d'avance de vos idées
    (Je suis débutant)

  2. #2
    Membre chevronné
    Avatar de Droïde Système7
    Homme Profil pro
    Inscrit en
    Septembre 2003
    Messages
    2 262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 2 262
    Points : 1 928
    Points
    1 928
    Par défaut Pot aux roses trouvé, mais...
    Bonjour

    Je viens de trouver le morceau capital de l'énigme !!!

    http://www.developpez.net/forums/viewtopic.php?t=375521

    Je n'ai pas souhaité suivre ici sur ce topic pour des raisons de simplification et de compréhension. Car plus la lecture est longue et moins il y a d'amateurs à tenter de répondre...


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

Discussions similaires

  1. delphi composant richedit
    Par lllll dans le forum Débuter
    Réponses: 2
    Dernier message: 17/08/2010, 11h39
  2. Réponses: 3
    Dernier message: 31/07/2006, 09h34
  3. ScrollBars dans un RichEdit
    Par blondelle dans le forum C++Builder
    Réponses: 3
    Dernier message: 27/05/2006, 23h29
  4. Comment débloquer le ScrollBar d'un RichEdit ?
    Par Droïde Système7 dans le forum Composants VCL
    Réponses: 2
    Dernier message: 24/07/2005, 11h43
  5. Delphi Mysql et Richedit.
    Par rvzip64 dans le forum Bases de données
    Réponses: 5
    Dernier message: 21/06/2004, 17h13

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