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

Lazarus Pascal Discussion :

ScrollBar : erreur de positionnement [Lazarus]


Sujet :

Lazarus Pascal

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Mai 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2013
    Messages : 15
    Points : 6
    Points
    6
    Par défaut ScrollBar : erreur de positionnement
    Bonjour développeurs,

    J'utilise Windows 7, Lazarus version 1.0.12, FPC 2.6.2 et SVN 42478.

    Je viens de constater une situation qui me semble être une anomalie avec le ScrollBar.

    La position que je donne au ScrollBar ne correspond pas tout à fait à la position que devrait être la ScrollBar.
    Voir la capture d'écran ci-joint.

    Voici le code que vous pouvez tester afin de confirmer que cette situation peut être répétée.

    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
     
    unit Unit1;
     
    {$mode objfpc}{$H+}
     
    interface
     
    uses
      Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
      ComCtrls;
     
    type
     
      { TForm1 }
     
      TForm1 = class(TForm)
        Label1: TLabel;
        Label10: TLabel;
        Label11: TLabel;
        Label12: TLabel;
        Label13: TLabel;
        Label14: TLabel;
        Label15: TLabel;
        Label16: TLabel;
        Label17: TLabel;
        Label18: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Label7: TLabel;
        Label8: TLabel;
        Label9: TLabel;
        ScrollBar1: TScrollBar;
        ScrollBar2: TScrollBar;
        ScrollBar3: TScrollBar;
        TrackBar1: TTrackBar;
        procedure FormCreate(Sender: TObject);
      private
        { private declarations }
      public
        { public declarations }
      end;
     
    var
      Form1: TForm1;
      iPos : byte;
     
    implementation
     
    {$R *.lfm}
     
    { TForm1 }
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
       iPos := 2;
     
       ScrollBar1.Position := iPos;
       Label1.Caption := intTostr(ScrollBar1.Position);
     
       ScrollBar2.Position := iPos;
       Label5.Caption := intTostr(ScrollBar2.Position);
     
       ScrollBar3.Position := iPos;
       Label18.Caption := intTostr(ScrollBar3.Position);
     
       TrackBar1.Position := iPos;
       Label6.Caption := intTostr(TrackBar1.Position);
     
    end;
    end.
    Le TrackBar lui se positionne à la bonne place alors que la position du ScrollBar n'est pas du tout à la bonne position.

    Est-ce un bug ou c'est la façon dont se comporte le ScrollBar???
    Images attachées Images attachées  

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Je ne sais pas si vous avez défini la valeur Min des ScrollBars. Par défaut, elle vaut 0 : http://lazarus-ccr.sourceforge.net/d...llbar.min.html

    Cela pourrait être une explication: Si votre intervalle est [0; 4] alors Pos =2 est en effet la valeur centrale de l'intervalle et le curseur se place au milieu de l'intervalle comme sur votre premier dessin...

    Mais la borne inférieure sur vos dessins semble être 1... Et dans l'éventualité où vous n'auriez pas modifié la valeur Min par défaut, c'est votre graduation qui serait erronée (ie ne correspondant à l'intervalle [0; 4]).

    Il faudrait le .lfm de la Form pour vérifier cette hypothèse.
    Cordialement. Gilles

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Mai 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2013
    Messages : 15
    Points : 6
    Points
    6
    Par défaut
    Bonjour Gilles,

    Effectivement c'est un bon point.
    Les valeurs des ScrollBar sont affichées au début de chaque ligne dans ma capture d'écran et elles débutent toutes à 1 pour faciliter le test.

    Voici le .lfm pour confirmation.

    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
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
     
    object Form1: TForm1
      Left = 484
      Height = 280
      Top = 273
      Width = 608
      Caption = 'Form1'
      ClientHeight = 280
      ClientWidth = 608
      Color = 10785678
      OnCreate = FormCreate
      LCLVersion = '1.0.12.0'
      object ScrollBar1: TScrollBar
        Left = 144
        Height = 16
        Top = 40
        Width = 372
        Max = 4
        Min = 1
        PageSize = 0
        Position = 4
        TabOrder = 0
      end
      object Label1: TLabel
        Left = 536
        Height = 16
        Top = 40
        Width = 35
        Caption = 'Label1'
        ParentColor = False
      end
      object TrackBar1: TTrackBar
        Left = 144
        Height = 32
        Top = 184
        Width = 372
        Max = 4
        Min = 1
        Position = 1
        TabOrder = 1
      end
      object ScrollBar2: TScrollBar
        Left = 144
        Height = 16
        Top = 124
        Width = 372
        Max = 5
        Min = 1
        PageSize = 0
        Position = 5
        TabOrder = 2
      end
      object Label2: TLabel
        Left = 24
        Height = 16
        Top = 40
        Width = 73
        Caption = 'Min 1 - Max 4'
        ParentColor = False
      end
      object Label3: TLabel
        Left = 24
        Height = 16
        Top = 124
        Width = 73
        Caption = 'Min 1 - Max 5'
        ParentColor = False
      end
      object Label4: TLabel
        Left = 24
        Height = 16
        Top = 184
        Width = 73
        Caption = 'Min 1 - Max 4'
        ParentColor = False
      end
      object Label5: TLabel
        Left = 536
        Height = 16
        Top = 124
        Width = 35
        Caption = 'Label5'
        ParentColor = False
      end
      object Label6: TLabel
        Left = 536
        Height = 16
        Top = 184
        Width = 35
        Caption = 'Label6'
        ParentColor = False
      end
      object Label7: TLabel
        Left = 528
        Height = 16
        Top = 8
        Width = 48
        Caption = 'Position'
        Font.Style = [fsBold, fsItalic, fsUnderline]
        ParentColor = False
        ParentFont = False
      end
      object Label8: TLabel
        Left = 166
        Height = 16
        Top = 20
        Width = 7
        Caption = '1'
        ParentColor = False
      end
      object Label9: TLabel
        Left = 273
        Height = 16
        Top = 20
        Width = 7
        Caption = '2'
        ParentColor = False
      end
      object Label10: TLabel
        Left = 380
        Height = 16
        Top = 20
        Width = 7
        Caption = '3'
        ParentColor = False
      end
      object Label11: TLabel
        Left = 486
        Height = 16
        Top = 20
        Width = 7
        Caption = '4'
        ParentColor = False
      end
      object Label12: TLabel
        Left = 166
        Height = 16
        Top = 102
        Width = 7
        Caption = '1'
        ParentColor = False
      end
      object Label13: TLabel
        Left = 246
        Height = 16
        Top = 102
        Width = 7
        Caption = '2'
        ParentColor = False
      end
      object Label14: TLabel
        Left = 327
        Height = 16
        Top = 102
        Width = 7
        Caption = '3'
        ParentColor = False
      end
      object Label15: TLabel
        Left = 406
        Height = 16
        Top = 102
        Width = 7
        Caption = '4'
        ParentColor = False
      end
      object Label16: TLabel
        Left = 486
        Height = 16
        Top = 102
        Width = 7
        Caption = '5'
        ParentColor = False
      end
      object ScrollBar3: TScrollBar
        Left = 152
        Height = 17
        Top = 241
        Width = 121
        Max = 4
        Min = 1
        PageSize = 0
        Position = 1
        TabOrder = 3
      end
      object Label17: TLabel
        Left = 24
        Height = 16
        Top = 241
        Width = 73
        Caption = 'Min 1 - Max 4'
        ParentColor = False
      end
      object Label18: TLabel
        Left = 296
        Height = 16
        Top = 240
        Width = 41
        Caption = 'Label18'
        ParentColor = False
      end
    end
    Afin d'avoir une meilleure évaluation de la position du curseur, j'ai ajouté des étiquettes avec la position que devrait prendre normalement le curseur.
    Le positionnement des chiffres a été fait avec l'assignation de la valeur "Position" dans la propriété de l'objet.

    On peut constater que la position du curseur pour les Scrollbar est vraiment décalée contrairement au TrackBar qui lui est directement sur le 2.

    Merci.
    Images attachées Images attachées  

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonsoir,

    Hum... C'est le prof de maths (les bornes et les valeurs centrales) qui a répondu et pas l'utilisateur de Lazarus
    Votre code est correct mais il n'est pas placé au bon endroit... J'aurais dû le voir plus tôt mais j'étais dans Windev. C'est un peu différent... et avant de vous répondre, je n'ai pas pris le temps de changer "d'interface" avec d'ailleurs toujours avec autant de plaisir.

    Déplacez votre code dans procedure TForm1.FormShow(Sender: TObject); ou dans TForm1.FormPaint(Sender: TObject); Je privilégierais OnShow plutôt que OnPaint : Mettez un showmessage("OnPaint") dans TForm1.FormPaint(Sender: TObject); et un showmessage("OnShow") dans TForm1.FormShow(Sender: TObject);

    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
    procedure TForm1.FormShow(Sender: TObject);
    begin
      iPos := 2;
     
       ScrollBar1.Position := iPos;
       Label1.Caption := intTostr(ScrollBar1.Position);
     
       ScrollBar2.Position := iPos;
       Label5.Caption := intTostr(ScrollBar2.Position);
     
       ScrollBar3.Position := iPos;
       Label18.Caption := intTostr(ScrollBar3.Position);
     
       TrackBar1.Position := iPos;
       Label6.Caption := intTostr(TrackBar1.Position);
    end;
    ... Dans TForm1.FormCreate(Sender: TObject) les objets sont créés mais les objets graphiques ne sont pas encore "finalisés" (ie dessinés) et donc le ScrollBar1.Position := iPos; est mal "interprété"... En réalité, il ne peut pas être interprété.

    Cordialement. Gilles
    Dernière modification par Invité ; 30/10/2013 à 18h08.

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Mai 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2013
    Messages : 15
    Points : 6
    Points
    6
    Par défaut
    Merci Beaucoup Gilles,

    C'est vraiment un manque de connaissances de ma part.
    La solution que vous m'avez proposée fonctionne à merveille.

    Merci encore.

  6. #6
    Expert éminent sénior
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    10 720
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 10 720
    Points : 15 106
    Points
    15 106
    Par défaut
    Citation Envoyé par MikeEagle Voir le message
    La solution que vous m'avez proposée fonctionne à merveille.

    Merci encore.
    Plus qu'à cliquer sur , alors ---> tout en bas.

    Ça facilitera les futures recherches.
    Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peutêtre qu'il peut être sûr, etc.
    Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
    Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
    On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
    Mes 2 cts,
    --
    jp

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

Discussions similaires

  1. Aruco et estimation d'erreur de positionnement
    Par black_hole dans le forum OpenCV
    Réponses: 0
    Dernier message: 31/05/2014, 20h34
  2. Erreur de positionnement différent avec Chrome
    Par nico44530 dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 29/08/2012, 08h14
  3. Réponses: 2
    Dernier message: 21/06/2006, 16h18
  4. [JScrollPane] positionnement des scrollbars
    Par Dnasty dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 19/03/2006, 14h46
  5. [MDI] Erreur de positionnement
    Par Benjamin GAGNEUX dans le forum Composants VCL
    Réponses: 6
    Dernier message: 08/09/2004, 18h57

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