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 :

Changer la propriété ItemIndex d'un TRadioGroup sans déclencher d'événement


Sujet :

Composants VCL Delphi

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut Changer la propriété ItemIndex d'un TRadioGroup sans déclencher d'événement
    Bonjour,

    Dans le code de mon application, je souhaiterais savoir comment ne pas déclencher un RadioGroupClick lorsque je modifie sa propriété ItemIndex.

    Merci de vos conseils

    Cordialement
    Pierre

  2. #2
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    je ne l'ai pas pour un RadioGroup mais je te laisse deviner à partir de cette exemple pour un CheckBox

    crée une nouvelle unité avec cela dedans
    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
     
     
      TCheckBoxSliteHelper = class helper for TCheckBox
      private
        procedure SetSilentChecked(const Value: Boolean);
      public
        property SilentChecked: Boolean write SetSilentChecked;
      end;
     
    //------------------------------------------------------------------------------
    procedure TCheckBoxSliteHelper.SetSilentChecked(const Value: Boolean);
    var
      ooc: TNotifyEvent;
    begin
      ooc := Self.OnClick;
      Self.OnClick := nil;
      try
        Self.Checked := Value;
      finally
        Self.OnClick := ooc;
      end;
    end;
    Dans l'unité du CheckBox1, tu ajoutes le uses sur l'unité du TCheckBoxSliteHelper
    et ton CheckBox1 aura une nouvelle propriété !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    CheckBox1.SilentChecked := True;
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Bonjour,

    Merci pour cette piste.

    Le code ci dessous vous semble-t-il correct?
    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
     
    type
      TRadioGroupSliteHelper = class helper for TRadioGroup
      private
        procedure SetSilentChecked(const Value: Boolean);
      public
        property SilentChecked: Boolean write SetSilentChecked;
      end;
     
     
    implementation
     
    procedure TRadioGroupSliteHelper.SetSilentChecked(const Value: Boolean);
    var
      ooc: TNotifyEvent;
    begin
      ooc := Self.OnClick;
      Self.OnClick := nil;
      try
        Self.Buttons.Checked:= Value
      finally
        Self.OnClick := ooc;
      end;
    end;
     
    end.
    Si oui, excusez mon niveau faible, mais lorsque je place:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    CheckBox1.SilentChecked := True;
    rdgAirport.ItemIndex:= 1;
    CheckBox1.SilentChecked := False;
    Je ne peux plus changer l'itemIndex.

    Merci de votre patience.

    Cordialement
    Pierre

  4. #4
    Membre expérimenté Avatar de guillemouze
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    876
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 876
    Points : 1 448
    Points
    1 448
    Par défaut
    heu ne serait-ce pas une property SilentItemIndex: integer; qu'il te faudrait, et juste faire MonRadioGroup.SilentItemIndex := 1; ?

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Merci Guillemouze,

    C'est exact, j'étais parti sur une mauvaise piste.
    J'ai corrigé ainsi:
    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
    type
      TRadioGroupSliteHelper = class helper for TRadioGroup
      private
        procedure SetSilentItemIndex(const Value: Integer);
      public
        property SilentItemIndex: Integer write SetSilentItemIndex;
      end;
     
     
    implementation
     
    procedure TRadioGroupSliteHelper.SetSilentItemIndex(const Value: Integer);
    var
      ooc: TNotifyEvent;
    begin
      ooc := Self.OnClick;
      Self.OnClick := nil;
      try
        Self.ItemIndex:= Value
      finally
        Self.OnClick := ooc;
      end;
    end;
    Puis dans mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    rdgAirport.SilentItemIndex:= 1;
    Un super merci à vous deux pour votre rapidité et votre patience avec un nœud nœud..

    Bien cordialement
    Pierre

  6. #6
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Ta version finale est parfaite, si cela te ne dérange pas,
    je vais l'ajouter à mon unité Slite.Helpers qui est mon unité bric-à-brac des Helpers
    cette unité fait la passerelle entre des Assistants que je maintiens depuis D5 et le nouveau mot clé helper for
    Mes Assistants doivent être utilisé explicitement, et le helper for a le confort d'être implicite,
    la fusion des deux est donc plutôt pratique car je n'ai pas à modifier mes Assistants et leur appel est rendu plus facile

    Le zip complet de la SLT/Slite : Pièce jointe 205014

    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
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    //------------------------------------------------------------------------------
    (*                     Slite is Dirty Wrapper for SLT                          -
     *                                                                             -
     *  Version alternative publiée sur "www.developpez.net"                       -
     *  Post : "Changer la propriété ItemIndex d'un TRadioGroup sans déclencher d'événement"
     *  Post Number : 8577500                                                      -
     *  Post URL = "http://www.developpez.net/forums/d1576193/environnements-developpement/delphi/composants-vcl/changer-propriete-itemindex-d-tradiogroup-declencher-d-evenement/#post8577500"
     *                                                                             -
     *  Copyright ou © ou Copr. "SLT Solutions", (2006)                            -
     *  contributeur : ShaiLeTroll (2012) - Création de l'enveloppe Slite          -
     *  contributeur : Pierre95/Guillemouze (2016) - TRadioGroupSliteHelper        -
     *                                                                             -
     * ShaiLeTroll@gmail.com                                                       -
     *                                                                             -
     * Ce logiciel est un programme informatique servant à aider les développeurs  -
     * Delphi a intégrer la bibliothèque SLT en fournissant des enveloppes         -
     * facilitant son utilisation au sacrifice de sa fragmentation                 -
     *                                                                             -
     * Ce logiciel est régi par la licence CeCILL-C soumise au droit français et   -
     * respectant les principes de diffusion des logiciels libres. Vous pouvez     -
     * utiliser, modifier et/ou redistribuer ce programme sous les conditions      -
     * de la licence CeCILL-C telle que diffusée par le CEA, le CNRS et l'INRIA    -
     * sur le site "http://www.cecill.info".                                       -
     *                                                                             -
     * En contrepartie de l'accessibilité au code source et des droits de copie,   -
     * de modification et de redistribution accordés par cette licence, il n'est   -
     * offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,   -
     * seule une responsabilité restreinte pèse sur l'auteur du programme,  le     -
     * titulaire des droits patrimoniaux et les concédants successifs.             -
     *                                                                             -
     * A cet égard  l'attention de l'utilisateur est attirée sur les risques       -
     * associés au chargement,  à l'utilisation,  à la modification et/ou au       -
     * développement et à la reproduction du logiciel par l'utilisateur étant      -
     * donné sa spécificité de logiciel libre, qui peut le rendre complexe à       -
     * manipuler et qui le réserve donc à des développeurs et des professionnels   -
     * avertis possédant  des  connaissances  informatiques approfondies.  Les     -
     * utilisateurs sont donc invités à charger  et  tester  l'adéquation  du      -
     * logiciel à leurs besoins dans des conditions permettant d'assurer la        -
     * sécurité de leurs systèmes et ou de leurs données et, plus généralement,    -
     * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.          -
     *                                                                             -
     * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez      -
     * pris connaissance de la licence CeCILL-C, et que vous en avez accepté les   -
     * termes.                                                                     -
     *                                                                             -
     *----------------------------------------------------------------------------*)
    unit Slite.Helpers;
     
    interface
     
    uses Winapi.Windows, Winapi.Messages,
      System.Classes, System.Types, System.SysUtils, System.Variants,
      System.IOUtils,
      Vcl.Controls, Vcl.Forms, Vcl.Graphics, Vcl.ComCtrls, Vcl.Menus, Vcl.Themes,
      Vcl.Grids, Vcl.DBGrids, Vcl.DBCGrids, Vcl.Printers, Vcl.StdCtrls, Vcl.ExtCtrls,
      Data.DB, Datasnap.DBClient, Datasnap.Provider,
      SLT.Common.Office.Excel;
     
    type
      { class declarations }
     
      TControlSliteHelper = class helper for TControl
      public
        procedure EnableControls();
        procedure DisableControls();
        function IsParent(AParentControl: TControl): Boolean;
      end;
     
      TFormSliteHelper = class helper for TForm
      public
        /// <summary>EnterAsTab permet de gérer un ENTER comme la touche TAB pour naviguer de controle en controle</summary>
        function EnterAsTab(var Key: Char): Boolean;
        procedure SelectNextControl();
        procedure SelectPriorControl();
      end;
     
      TStringsSliteHelper = class helper for TStrings
      public
        procedure FreeAndNilObjects();
        procedure ClearStringsAndObjects();
      end;
     
      TFontSliteHelper = class helper for TFont
      public
        function GetTextHeight(const AText: string): Integer;
        function GetTextWidth(const AText: string): Integer;
      public
        class function GetConstratedColor(AColor: TColor): TColor;
      end;
     
      TListViewSliteDrawer = class;
      TListViewSliteHelper = class helper for TListView
      public
        procedure SetColumnHeaderSizeable(ASizeable: Boolean);
        function DrawSubItemBegin(AItem: TListItem; ASubItem: Integer; ASubItemOneBased: Boolean = True): TListViewSliteDrawer;
        function GetThemedBackgroundColor(): TColor;
     
        function GetSubItemRect(AItem: TListItem; ASubItem: Integer; out ARect: TRect; ASubItemOneBased: Boolean = True): Boolean;
        function GetSubItemAtScreen(out ACol, ARow: Integer): Boolean;
        function GetItemAtScreen(out ACol, ARow: Integer): Boolean;
     
        procedure ViewInExcel(const ASheetName: string; const AColumnTypes: array of TVarType; ACheckedOnly: Boolean = False; AOnProgress: TNotifyEvent = nil; AOnBeforeActivateExcel: TNotifyEvent = nil; AShowWaitMessage: Boolean = True);
        procedure ZoomColumnTitleWidth(AZoomPourcent: Integer);
      end;
     
      TListViewSliteDrawer = class(TObject)
      private
        FAssistant: TObject;
        FCol: Integer;
        FRow: Integer;
      public
        constructor Create(AItem: TListItem; ASubItem: Integer; ASubItemOneBased: Boolean);
        destructor Destroy(); override;
        procedure DrawSubItemVerticalLines();
        procedure DrawSubItemCheckBox(AChecked: Boolean; AEnabled: Boolean = True);
        procedure DrawSubItemRadioButton(AChecked: Boolean; AEnabled: Boolean = True);
        procedure DrawSubItemImage(ABitmap: TBitmap);
        procedure DrawSubItemEnd();
      end;
     
      TStringGridSliteHelper = class helper for TStringGrid
      public
        procedure DrawCellEmpty(ACol, ARow: Integer; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
        procedure DrawCellTitleCenter(ACol, ARow: Integer; const AText: string; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
        procedure DrawCellCheckBox(ACol, ARow: Integer; AChecked: Boolean; AEnabled: Boolean = True; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
        procedure ZoomColumnWidth(AZoomPourcent: Integer);
      end;
     
      TDBGridSliteHelperSortDirection = (sdNone, sdAscending, sdDescending);
      TDBGridSliteHelper = class helper for TDBGrid
      public
        function EditButtonShowDateEditor(const Msg: string; AField: TField): Boolean;
        function EllipsisButtonShowComboEditor(const Msg: string; AColumn: TColumn; var AIndex: Integer): Boolean;
        procedure DrawCheckBox(const Rect: TRect; Checked: Boolean; AEnabled: Boolean = True; ABackgroundColor: TColor = clNone);
        procedure DrawEllipsisButton(const Rect: TRect; ABackgroundColor: TColor = clNone; AColumn: TColumn = nil; State: TGridDrawState = []);
        function HitOnEllipsisButton(Column: TColumn): Boolean;
        procedure DrawTextWithBackgroundColor(ABackgroundColor: TColor; const Rect: TRect; Column: TColumn; State: TGridDrawState);
        function HitOnTitle(out Column: TColumn): Boolean;
        function HitOnColumnCell(out Column: TColumn): Boolean;
        function GetTotalWidth(): Integer;
        function GetColumnTotalWidth(): Integer;
        function GetColumnBounds(const AColumn: TColumn): TRect;
        function GetTheoricRowHeight(): Integer;
     
        procedure DrawColumnArrowSort(const AColumn: TColumn; ASortDirection: TDBGridSliteHelperSortDirection);
     
        function GetThemedBackgroundColor(): TColor;
        function ThemeUseColumnColor(): Boolean;
        procedure ZoomColumnTitleWidth(AZoomPourcent: Integer);
      end;
     
      TDBGridSliteSortAssistant = class(TObject)
      public
        type
          TOnBeforeSortEvent = procedure(AColumn: TColumn; var AAllowedSort: Boolean) of object;
      strict private
        type
          TSortedColumn = record
            Column: TColumn;
            Order: TDBGridSliteHelperSortDirection;
            FlagColumnMoved: Boolean;
          end;
      strict private
        FDBGrid: TDBGrid;
        FDataSetProxy: Datasnap.DBClient.TClientDataSet;
        FDataSetProvider: Datasnap.Provider.TDataSetProvider;
        FSortedColumn: TSortedColumn;
        FOnBeforeSort: TOnBeforeSortEvent;
        FOriginalDataSet: TDataSet;
        FOriginalWndMethod: TWndMethod;
        FOriginalColumnMovedEventHandler: Vcl.Grids.TMovedEvent;
        FOriginalTitleClickEventHandler: TDBGridClickEvent;
        procedure ColumnMovedEventHandler(Sender: TObject; FromIndex, ToIndex: Integer);
        procedure TitleClickEventHandler(Column: TColumn);
        procedure NewWndMethod(var Message: TMessage);
        function IsAllowedSort(Column: TColumn): Boolean;
        procedure SetOriginalDataSet(Value: TDataSet);
        function RAZSort(): TDBGridSliteHelperSortDirection;
        function GetColumnOrdered(): TColumn;
        procedure SetColumnOrdered(Column: TColumn);
      public
        constructor Create(ADBGrid: TDBGrid);
        destructor Destroy(); override;
     
        procedure Refresh();
     
        property DataSet: TDataSet read FOriginalDataSet write SetOriginalDataSet;
        property DataSetOrdered: TClientDataSet read FDataSetProxy;
        property ColumnOrdered: TColumn read GetColumnOrdered write SetColumnOrdered;
     
        property OnBeforeSort: TOnBeforeSortEvent read FOnBeforeSort write FOnBeforeSort;
      end;
     
      TDBCGridSliteHelper = class helper for TDBCtrlGrid
      public
        procedure AdjustSizeAccording(MaxHeight, MaxWidth: Integer);
        procedure DrawSelection(Index: Integer; ASelectedColor: TColor = clNone);
        function ThemeUseSelectedColor(): Boolean;
      end;
     
      TDataSetSliteHelperViewInExcelProgressInfo = TSLTExcelDataSetExporter.TProgressInfo;
      TDataSetSliteHelper = class helper for TDataSet
      public
        procedure ViewInExcel(const ASheetName: string; const AFieldsNames, ATitles: array of string; AOnProgress: TNotifyEvent = nil; AOnBeforeActivateExcel: TNotifyEvent = nil; AShowWaitMessage: Boolean = True; ACellWithBorder: Boolean = False);
        function ViewInExcelProgressInfo(AProgressSender: TObject): TDataSetSliteHelperViewInExcelProgressInfo;
        function AddCalculatedField(const Name: string; DataType: TFieldType; Size: Integer = 0; Required: Boolean = False): TField;
        procedure ExportToCSV(const AFileName: TFileName; AWithHeader: Boolean; ASeparator: Char = ';'; AQuote: Char = '"');
      end;
     
      TFieldSliteHelper = class helper for TField
      public
        function IsChanged(): Boolean;
      end;
     
      TFieldDefsSliteHelper = class helper for TFieldDefs
      public
        function AddCalculated(const Name: string; DataType: TFieldType; Size: Integer = 0; Required: Boolean = False): TField;
      end;
     
      TCheckBoxSliteHelper = class helper for TCheckBox
      private
        procedure SetSilentChecked(const Value: Boolean);
      public
        property SilentChecked: Boolean write SetSilentChecked;
      end;
     
      TRadioGroupSliteHelper = class helper for TRadioGroup
      private
        procedure SetSilentItemIndex(const Value: Integer);
      public
        property SilentItemIndex: Integer write SetSilentItemIndex;
      end;
     
      TCanvasSliteHelper = class helper for TCanvas
      public
        procedure DrawCheckBox(const Rect: TRect; Checked: Boolean);
        procedure DrawArrow(X1, Y1, X2, Y2: Integer; LineWidth: Integer; TriangleRadius: Integer; const LineText: string = '');
        procedure DrawLine(X1, Y1, X2, Y2: Integer; LineWidth: Integer);
      public
        class function GetConstratedColor(AColor: TColor): TColor;
        class function GetGrayedColor(AColor: TColor): TColor;
      end;
     
      TStyleManagerSliteAssistant = class(TObject)
      public
        class procedure BuildChangeStyleMenu(AMenu: TMenuItem; const ADefaultStyle: string = ''); overload;
        class procedure SelectStyleInMenu(AMenu: TMenuItem; const ASelectedStyle: string);
        class procedure ChangeStyle(const AStyle: string);
        class function GetThemedBackgroundColor(): TColor;
        class procedure ChangePanelParentColorFromParentBackground(RootComponent: TComponent);
      end;
     
      TPrinterSliteHelper = class helper for TPrinter
      public
        class function SelectPrinter(const Msg: string; var PrinterName: string): Boolean;
      end;
     
      TAnimateSliteHelper = class helper for TAnimate
      public
        procedure ActiveThemedTabSheetTransparence();
      end;
     
      TTabSheetSliteAssistant = class(TObject)
      public
        class function GetThemedBackgroundColor(): TColor;
      end;
     
      TFileSliteHelper = record helper for System.IOUtils.TFile
        class function CompareVersion(const V1, V2: string): Integer; static;
      end;
     
    implementation
     
    uses System.Math, System.StrUtils,
      SLT.Common.ClassesEx,
      SLT.Controls.VCL.ControlsEx, SLT.Controls.VCL.GraphicsEx, SLT.Common.StrUtilsEx,
      SLT.Controls.VCL.ComCtrlsEx, SLT.Controls.VCL.GridsEx, SLT.Controls.VCL.DBGridsEx, SLT.Controls.VCL.DBCGridsEx,
      SLT.Controls.VCL.PrintersEx,
      SLT.Controls.VCL.ThemesEx;
     
    resourcestring
      SErrorMustCreateFieldBeforeAddCalculated = 'Must call protected method CreateFields before use create calculated field at runtime';
     
    { TControlSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TControlSliteHelper.EnableControls();
    begin
      TControlSLTToolHelp.SetEnabledControlRecursive(Self, True, True);
    end;
     
    //------------------------------------------------------------------------------
    function TControlSliteHelper.IsParent(AParentControl: TControl): Boolean;
    begin
      Result := TControlSLTToolHelp.IsParent(AParentControl, Self);
    end;
     
    //------------------------------------------------------------------------------
    procedure TControlSliteHelper.DisableControls();
    begin
      TControlSLTToolHelp.SetEnabledControlRecursive(Self, False, True);
    end;
     
     
    { TFormSliteHelper }
     
    //------------------------------------------------------------------------------
    function TFormSliteHelper.EnterAsTab(var Key: Char): Boolean;
    begin
      if Key = Chr(CarriageReturn) then
      begin
        Result := True;
        if LongBool(GetAsyncKeyState(VK_SHIFT) and $8000) then
          SelectPriorControl()
        else
          SelectNextControl();
        Key := #0; // Evite le "dong" !
      end
      else
        Result := False;
    end;
     
    //------------------------------------------------------------------------------
    procedure TFormSliteHelper.SelectNextControl();
    begin
      // TControl.SelectNext est une méthode protégée
      // le plus simple pour passer au controle suivant c'est le message Windows
      Self.Perform(WM_NEXTDLGCTL, 0, 0);
    end;
     
    //------------------------------------------------------------------------------
    procedure TFormSliteHelper.SelectPriorControl();
    begin
      // If wParam is zero, the next control receives the focus; otherwise, the previous control with the WS_TABSTOP style receives the focus.
      Self.Perform(WM_NEXTDLGCTL, 1, 0);
    end;
     
    { TStringsSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TStringsSliteHelper.ClearStringsAndObjects();
    begin
      TStringsSLTToolHelp.ClearStringsAndObjects(Self);
    end;
     
    //------------------------------------------------------------------------------
    procedure TStringsSliteHelper.FreeAndNilObjects();
    begin
      TStringsSLTToolHelp.FreeAndNilObjects(Self);
    end;
     
    { TFontSliteHelper }
     
    //------------------------------------------------------------------------------
    class function TFontSliteHelper.GetConstratedColor(AColor: TColor): TColor;
    begin
      Result := TCanvasSLTAssistant.GetConstratedColor(AColor);
    end;
     
    //------------------------------------------------------------------------------
    function TFontSliteHelper.GetTextHeight(const AText: string): Integer;
    begin
      Result := TFontSLTToolHelp.GetTextHeight(AText, Self)
    end;
     
    //------------------------------------------------------------------------------
    function TFontSliteHelper.GetTextWidth(const AText: string): Integer;
    begin
      Result := TFontSLTToolHelp.GetTextWidth(AText, Self);
    end;
     
    { TListViewSliteHelper }
     
    //------------------------------------------------------------------------------
    function TListViewSliteHelper.DrawSubItemBegin(AItem: TListItem; ASubItem: Integer; ASubItemOneBased: Boolean): TListViewSliteDrawer;
    begin
      // Remarque sur ASubItem et ASubItemOneBased par rapport à "http://docwiki.embarcadero.com/Libraries/en/Vcl.ComCtrls.TLVAdvancedCustomDrawSubItemEvent"
      // sprevot : Le 2014-02-20, L'article en Anglais a été amélioré, suite à un Feedback que j'ai laissé sur 'documentation@embarcadero.com'
      // Sentence d'origine : The SubItem parameter is the index of the subitem of that list item in its SubItems property.
      // Sentence ajoutée : SubItem is one-based, facilitating the call to some WinAPIs like GetSubItemRect. However, because SubItems is a TStrings and therefore zero-based, you must use SubItem - 1.
      Result := TListViewSliteDrawer.Create(AItem, ASubItem, ASubItemOneBased);
    end;
     
    //------------------------------------------------------------------------------
    function TListViewSliteHelper.GetItemAtScreen(out ACol, ARow: Integer): Boolean;
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        Result := GetItemAtScreen(ACol, ARow);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TListViewSliteHelper.GetSubItemAtScreen(out ACol, ARow: Integer): Boolean;
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        Result := GetSubItemAtScreen(ACol, ARow);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TListViewSliteHelper.GetSubItemRect(AItem: TListItem; ASubItem: Integer; out ARect: TRect; ASubItemOneBased: Boolean = True): Boolean;
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        Result := GetSubItemRect(ASubItem - Ord(ASubItemOneBased), AItem.Index, ARect);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TListViewSliteHelper.GetThemedBackgroundColor(): TColor;
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        Result := GetThemedBackgroundColor();
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteHelper.SetColumnHeaderSizeable(ASizeable: Boolean);
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        ColumnHeaderSizeable := ASizeable;
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteHelper.ViewInExcel(const ASheetName: string; const AColumnTypes: array of TVarType; ACheckedOnly: Boolean = False; AOnProgress: TNotifyEvent = nil; AOnBeforeActivateExcel: TNotifyEvent = nil; AShowWaitMessage: Boolean = True);
    begin
      with TSLTExcelListViewer.Create(Self) do
      try
        OnProgress := AOnProgress;
        OnBeforeActivateExcel := AOnBeforeActivateExcel;
        CheckedOnly := ACheckedOnly;
        ShowWaitMessage := AShowWaitMessage;
        ViewInExcel(ASheetName, AColumnTypes);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteHelper.ZoomColumnTitleWidth(AZoomPourcent: Integer);
    begin
      with TListViewSLTAssistant.Create(Self) do
      try
        ZoomColumnTitleWidth(AZoomPourcent);
      finally
        Free();
      end;
    end;
     
    { TListViewSliteDrawer }
     
    //------------------------------------------------------------------------------
    constructor TListViewSliteDrawer.Create(AItem: TListItem; ASubItem: Integer; ASubItemOneBased: Boolean);
    begin
      inherited Create();
     
      FAssistant := TListViewSLTAssistant.Create(AItem.ListView);
      FCol := ASubItem;
      FRow := AItem.Index;
     
      // ASubItem :
      // Si ASubItemOneBased alors c'est un sous-item de 1 à n (Zéro est toléré comme Item mais mieux vaut éviter d'utiliser comme tel avec des fonctions DrawSubItem...)
      // Sinon c'est obligatoirement un sous-item, l'indice de 0 à n-1 comme dans SubStrings
      // Voir commentaire dans TListViewSliteHelper.DrawSubItemBegin
      if not ASubItemOneBased then
        Inc(FCol); // on transforme du zero-based en one-based
     
      TListViewSLTAssistant(FAssistant).DrawPrepare(FCol, FRow);
    end;
     
    //------------------------------------------------------------------------------
    destructor TListViewSliteDrawer.Destroy();
    begin
      FreeAndNil(FAssistant);
     
      inherited Destroy();
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteDrawer.DrawSubItemCheckBox(AChecked, AEnabled: Boolean);
    begin
      TListViewSLTAssistant(FAssistant).DrawItemCheckBox(FCol, FRow, AChecked, AEnabled);
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteDrawer.DrawSubItemEnd();
    begin
      TListViewSLTAssistant(FAssistant).DrawUnprepare(FCol, FRow);
     
      Free();
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteDrawer.DrawSubItemImage(ABitmap: TBitmap);
    begin
      TListViewSLTAssistant(FAssistant).DrawItemImage(FCol, FRow, ABitmap);
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteDrawer.DrawSubItemRadioButton(AChecked, AEnabled: Boolean);
    begin
      TListViewSLTAssistant(FAssistant).DrawItemRadioButton(FCol, FRow, AChecked, AEnabled);
    end;
     
    //------------------------------------------------------------------------------
    procedure TListViewSliteDrawer.DrawSubItemVerticalLines();
    begin
      TListViewSLTAssistant(FAssistant).DrawItemVerticalLines(FCol, FRow);
    end;
     
    { TStyleManagerSliteAssistant }
     
    //------------------------------------------------------------------------------
    class procedure TStyleManagerSliteAssistant.BuildChangeStyleMenu(AMenu: TMenuItem; const ADefaultStyle: string = '');
    begin
      TStyleManagerSLTAssistant.BuildChangeStyleMenu(AMenu, TStyleManagerSLTAssistant.StyleClickDefaultEventHandler, ADefaultStyle);
    end;
     
    //------------------------------------------------------------------------------
    class procedure TStyleManagerSliteAssistant.ChangePanelParentColorFromParentBackground(RootComponent: TComponent);
    var
      I: Integer;
      Cpt: TComponent;
    begin
      // En local, les postes développeurs sous Vista\Seven,
      // En Citrix, les environnements semblent être sous Window 2003 ou Window 2008 sous le thème classique (Win2K)
      // Avec le Thème Aero, une application avec coloration de la TForm nécessite
      // . ParentBackground si elle compilée avec le Manifest Common Control Version 6.0 fourni par Embarcadero, ParentBackground provoque une transparence permettant de voir la couleur de fond (cela peut-être une image)
      // . ParentColor si elle est compilée SANS les thèmes, Si ParentColor est à True cela propage la couleur, problème par défaut le TPanel force cette valeur à False depuis l'apparition de ParentBackground
      // Avec le Thème classique (Win2K), une application avec coloration de la TForm nécessite
      // . ParentColor si elle est compilée AVEC ou SANS les thèmes
      if not VCL.Themes.StyleServices.Enabled then
      begin
        // ParentBackground est sans effet à moins que les thèmes XP ne soient activés.
        // Il faut forcer ParentColor à True alors que sur les TPanel c'est par défaut à False
        for I := 0 to RootComponent.ComponentCount - 1 do
        begin
          Cpt := RootComponent.Components[I];
          if Cpt is TPanel then
            if TPanel(Cpt).ParentBackground then
              TPanel(Cpt).ParentColor := True;
        end;
      end;
    end;
     
    //------------------------------------------------------------------------------
    class procedure TStyleManagerSliteAssistant.ChangeStyle(const AStyle: string);
    begin
      TStyleManager.TrySetStyle(AStyle, False);
    end;
     
    //------------------------------------------------------------------------------
    class function TStyleManagerSliteAssistant.GetThemedBackgroundColor(): TColor;
    begin
      Result := TStyleManagerSLTAssistant.GetThemedBackgroundColor();
    end;
     
    //------------------------------------------------------------------------------
    class procedure TStyleManagerSliteAssistant.SelectStyleInMenu(AMenu: TMenuItem; const ASelectedStyle: string);
    var
      I: Integer;
    begin
      for I := 0 to AMenu.Count - 1 do
      begin
        if SameText(AMenu.Items[I].Caption, ASelectedStyle) then
        begin
          TStyleManagerSLTAssistant.StyleClickDefaultEventHandler(AMenu.Items[I]);
          Exit;
        end;
      end;
    end;
     
    { TStringGridSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TStringGridSliteHelper.DrawCellCheckBox(ACol, ARow: Integer; AChecked: Boolean; AEnabled: Boolean = True; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
    begin
      with TStringGridSLTAssistant.Create(Self) do
      try
        DrawCellCheckBox(ACol, ARow, AChecked, AEnabled, ABackgroundColor, AState);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TStringGridSliteHelper.DrawCellEmpty(ACol, ARow: Integer; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
    begin
      with TStringGridSLTAssistant.Create(Self) do
      try
        DrawCellEmpty(ACol, ARow, ABackgroundColor, AState);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TStringGridSliteHelper.DrawCellTitleCenter(ACol, ARow: Integer; const AText: string; ABackgroundColor: TColor = clNone; AState: TGridDrawState = []);
    begin
      with TStringGridSLTAssistant.Create(Self) do
      try
        DrawCellTitleCenter(ACol, ARow, AText, ABackgroundColor, AState);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TStringGridSliteHelper.ZoomColumnWidth(AZoomPourcent: Integer);
    begin
      with TStringGridSLTAssistant.Create(Self) do
      try
        ZoomColumnWidth(AZoomPourcent);
      finally
        Free();
      end;
    end;
     
    { TDBGridSliteHelper }
     
    type
      TDBGridSliteHack = class(TDBGrid);
     
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteHelper.DrawCheckBox(const Rect: TRect; Checked: Boolean; AEnabled: Boolean = True; ABackgroundColor: TColor = clNone);
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        DrawCheckBox(Rect, Checked, AEnabled, ABackgroundColor);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteHelper.DrawColumnArrowSort(const AColumn: TColumn; ASortDirection: TDBGridSliteHelperSortDirection);
    var
      csd: TDBGridSLTAssistant.TColumnSortDirection;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        csd := csdNone;
        if ASortDirection = sdAscending then
          csd := csdAscending
        else if ASortDirection = sdDescending then
          csd := csdDescending;
     
        DrawColumnArrowSort(AColumn, csd);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteHelper.DrawEllipsisButton(const Rect: TRect; ABackgroundColor: TColor = clNone; AColumn: TColumn = nil; State: TGridDrawState = []);
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        DrawEllipsisButton(Rect, ABackgroundColor, AColumn, State);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteHelper.DrawTextWithBackgroundColor(ABackgroundColor: TColor; const Rect: TRect; Column: TColumn; State: TGridDrawState);
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        DrawTextWithBackgroundColor(ABackgroundColor, Rect, Column, State);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.EditButtonShowDateEditor(const Msg: string; AField: TField): Boolean;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := EditButtonInputDatePicker(Msg, AField);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.EllipsisButtonShowComboEditor(const Msg: string; AColumn: TColumn; var AIndex: Integer): Boolean;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := ShowCombo(Msg, AColumn.PickList, AIndex);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.GetColumnBounds(const AColumn: TColumn): TRect;
    var
      ColR: TRect;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        ColR := GetColumnScreenRect(AColumn);
        Result.TopLeft := Self.ScreenToClient(ColR.TopLeft);
        Result.BottomRight := Self.ScreenToClient(ColR.BottomRight);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.GetColumnTotalWidth(): Integer;
    var
      I: Integer;
    begin
      Result := 0;
      for I := 0 to Self.Columns.Count - 1 do
        Inc(Result, Self.Columns[I].Width);
     
      if dgColLines in Self.Options then
        Inc(Result, Self.Columns.Count);
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.GetThemedBackgroundColor(): TColor;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := GetThemedBackgroundColor();
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.GetTheoricRowHeight(): Integer;
    begin
      Result := TDBGridSliteHack(Self).DefaultRowHeight;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.GetTotalWidth(): Integer;
    begin
      Result := GetColumnTotalWidth() + GetSystemMetrics(SM_CXVSCROLL);
      if dgIndicator in Self.Options then
        Inc(Result, GetSystemMetrics(SM_CXVSCROLL));
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.HitOnColumnCell(out Column: TColumn): Boolean;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := HitOnColumnCell(Column);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.HitOnEllipsisButton(Column: TColumn): Boolean;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := HitOnEllipsisButton(Column);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.HitOnTitle(out Column: TColumn): Boolean;
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        Result := HitOnTitle(Column);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteHelper.ThemeUseColumnColor(): Boolean;
    begin
      Result := TDBGridSLTAssistant.ThemeUseColumnColor;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteHelper.ZoomColumnTitleWidth(AZoomPourcent: Integer);
    begin
      with TDBGridSLTAssistant.Create(Self) do
      try
        ZoomColumnTitleWidth(AZoomPourcent);
      finally
        Free();
      end;
    end;
     
     
    { TDBGridSliteSortAssistant }
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.ColumnMovedEventHandler(Sender: TObject; FromIndex, ToIndex: Integer);
    begin
      // La Colonne en deplacement est celle du Tri en cours
      if FSortedColumn.Column = FDBGrid.Columns[ToIndex] then
      begin
        FDBGrid.DrawColumnArrowSort(FDBGrid.Columns.Items[ToIndex], FSortedColumn.Order);
        FSortedColumn.FlagColumnMoved := FromIndex <> ToIndex;
      end
      else
      begin
        // La Colonne qui sera remplacée est celle du Tri en cours
        if FSortedColumn.Column = FDBGrid.Columns[ToIndex] then
        begin
          FDBGrid.DrawColumnArrowSort(FDBGrid.Columns.Items[FromIndex], FSortedColumn.Order);
          FSortedColumn.FlagColumnMoved := FromIndex <> ToIndex;
        end;
      end;
     
      if Assigned(FOriginalColumnMovedEventHandler) then
        FOriginalColumnMovedEventHandler(Sender, FromIndex, ToIndex);
    end;
     
    //------------------------------------------------------------------------------
    constructor TDBGridSliteSortAssistant.Create(ADBGrid: TDBGrid);
    const
      ERR_UNASSISTED_CLASS = 'La Classe d''Assistance %s n''accepte que les instance de la classe %s';
      DEFAULT_PACKET_RECORDS = 25; // 25 lignes visibles dans une DBGrid, c'est une valeur généralement utilisée
    begin
      inherited Create();
     
      if not Assigned(ADBGrid) then
        raise Exception.CreateFmt(ERR_UNASSISTED_CLASS, [ClassName(), TDBGrid.ClassName()]);
     
      FDBGrid := ADBGrid;
     
      FOriginalWndMethod := FDBGrid.WindowProc;
      FDBGrid.WindowProc := NewWndMethod;
     
      FOriginalColumnMovedEventHandler := FDBGrid.OnColumnMoved;
      FDBGrid.OnColumnMoved := ColumnMovedEventHandler;
     
      FOriginalTitleClickEventHandler := FDBGrid.OnTitleClick;
      FDBGrid.OnTitleClick := TitleClickEventHandler;
     
      FDataSetProxy := Datasnap.DBClient.TClientDataSet.Create(nil);
      FDataSetProvider := Datasnap.Provider.TDataSetProvider.Create(nil);
      FDataSetProxy.SetProvider(FDataSetProvider);
      if TDBGridSliteHack(ADBGrid).DefaultRowHeight > 0 then
        FDataSetProxy.PacketRecords := System.Math.Ceil(ADBGrid.Height / TDBGridSliteHack(ADBGrid).DefaultRowHeight)
      else
        FDataSetProxy.PacketRecords := DEFAULT_PACKET_RECORDS;
     
      if Assigned(FDBGrid) and Assigned(FDBGrid.DataSource) then
      begin
        FOriginalDataSet := FDBGrid.DataSource.DataSet;
        FDataSetProvider.DataSet := FOriginalDataSet;
        FDBGrid.DataSource.DataSet := FDataSetProxy;
        if Assigned(FOriginalDataSet) then
        begin
          FDataSetProxy.Open();
          // Attribuez la valeur false à LogChanges si vous n'avez pas l'intention de mettre à jour la base de données avec les modifications de l'ensemble de données client
          FDataSetProxy.LogChanges := False;
        end;
      end;
    end;
     
    //------------------------------------------------------------------------------
    destructor TDBGridSliteSortAssistant.Destroy();
    begin
      if Assigned(FDBGrid) and Assigned(FDBGrid.DataSource) and Assigned(FDataSetProvider) then
        FDBGrid.DataSource.DataSet := FOriginalDataSet;
     
      FreeAndNil(FDataSetProxy);
      FreeAndNil(FDataSetProvider);
     
      FOriginalColumnMovedEventHandler := FDBGrid.OnColumnMoved;
      FOriginalTitleClickEventHandler := FDBGrid.OnTitleClick;
     
      if Assigned(FDBGrid) then
        FDBGrid.WindowProc := FOriginalWndMethod;
     
      inherited Destroy();
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteSortAssistant.GetColumnOrdered(): TColumn;
    begin
      Result := FSortedColumn.Column;
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteSortAssistant.IsAllowedSort(Column: TColumn): Boolean;
    begin
      Result := True;
      if Assigned(FOnBeforeSort) then
        FOnBeforeSort(Column, Result);
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.NewWndMethod(var Message: TMessage);
    begin
      FOriginalWndMethod(Message);
     
      if (Message.Msg = WM_HSCROLL) or (Message.Msg = WM_SIZE) then
        if Assigned(FSortedColumn.Column) then
          FDBGrid.DrawColumnArrowSort(FSortedColumn.Column, FSortedColumn.Order);
    end;
     
    //------------------------------------------------------------------------------
    function TDBGridSliteSortAssistant.RAZSort(): TDBGridSliteHelperSortDirection;
    begin
      Result := FSortedColumn.Order;
     
      if Assigned(FDBGrid) then
        FDBGrid.DrawColumnArrowSort(nil, sdNone);
     
      FSortedColumn.Column := nil;
      FSortedColumn.Order := sdNone;
      FSortedColumn.FlagColumnMoved := False;
     
      if FDataSetProxy.IndexName <> '' then
        FDataSetProxy.IndexName := '';
      FDataSetProxy.IndexDefs.Clear();
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.Refresh();
    begin
      if Assigned(FDataSetProvider) and Assigned(FDataSetProvider.DataSet) and Assigned(FDataSetProxy) and FDataSetProxy.Active then
        FDataSetProxy.Refresh();
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.SetColumnOrdered(Column: TColumn);
    var
      OldOrder: TDBGridSliteHelperSortDirection;
      IndexName: String;
    begin
      // Remise à zéro du tri en cours
      OldOrder := RAZSort();
     
      if Assigned(FDBGrid) and Assigned(Column) and (Column.Grid = FDBGrid) and FDataSetProxy.Active then
      begin
        // Est-ce bien une Colonne Triable ?
        if Assigned(Column.Field) and IsAllowedSort(Column) then
        begin
          // Changement de l'ordre de tri selon celui qui était actif précédemment
          case OldOrder of
            sdNone, sdDescending :
              begin
                FSortedColumn.Column := Column;
                FSortedColumn.Order := sdAscending;
                FDBGrid.DrawColumnArrowSort(FSortedColumn.Column, sdAscending); // Attention, cela modifie la propriété Width
                IndexName := Copy('ASC_' + Column.FieldName, 1, 30); // 30 = Taille maximum
                FDataSetProxy.AddIndex(IndexName, Column.FieldName, [ixCaseInsensitive]);
              end;
     
            sdAscending :
              begin
                FSortedColumn.Column := Column;
                FSortedColumn.Order := sdDescending;
                FDBGrid.DrawColumnArrowSort(FSortedColumn.Column, sdDescending); // Attention, cela modifie la propriété Width
                IndexName := Copy('DESC_' + Column.FieldName, 1, 30); // 30 = Taille maximum
                FDataSetProxy.AddIndex(IndexName, Column.FieldName, [ixDescending, ixCaseInsensitive]);
              end;
          end;
        end;
     
        // Application du Tri !
        try
          FDataSetProxy.IndexDefs.Update();
          FDataSetProxy.IndexName := IndexName;
        except
          RAZSort();
        end;
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.SetOriginalDataSet(Value: TDataSet);
    begin
      FOriginalDataSet := Value;
     
      FDataSetProxy.Close();
      RAZSort();
     
      FDataSetProvider.DataSet := Value;
      if Assigned(FDBGrid) and Assigned(FDBGrid.DataSource) and Assigned(Value) then
      begin
        FDataSetProxy.SetProvider(FDataSetProvider);
        FDataSetProxy.Open();
        // Attribuez la valeur false à LogChanges si vous n'avez pas l'intention de mettre à jour la base de données avec les modifications de l'ensemble de données client
        FDataSetProxy.LogChanges := False;
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBGridSliteSortAssistant.TitleClickEventHandler(Column: TColumn);
    begin
      // Protection contre le déplacement de colonne
      if FSortedColumn.FlagColumnMoved then begin
        FSortedColumn.FlagColumnMoved := False;
        Exit;
      end;
     
      SetColumnOrdered(Column);
     
      if Assigned(FOriginalTitleClickEventHandler) then
        FOriginalTitleClickEventHandler(Column);
    end;
     
    { TDBCGridSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TDBCGridSliteHelper.AdjustSizeAccording(MaxHeight, MaxWidth: Integer);
    begin
      with TDBCtrlGridSLTAssistant.Create(Self) do
      try
        AdjustSizeAccording(MaxHeight, MaxWidth);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDBCGridSliteHelper.DrawSelection(Index: Integer; ASelectedColor: TColor = clNone);
    begin
      with TDBCtrlGridSLTAssistant.Create(Self) do
      try
        DrawSelection(Index, ASelectedColor);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDBCGridSliteHelper.ThemeUseSelectedColor(): Boolean;
    begin
      Result := TDBCtrlGridSLTAssistant.ThemeUseSelectedColor;
    end;
     
    { TDataSetSliteHelper }
     
    //------------------------------------------------------------------------------
    function TDataSetSliteHelper.AddCalculatedField(const Name: string; DataType: TFieldType; Size: Integer = 0; Required: Boolean = False): TField;
    begin
      // Avant de forcer la création d'un champ calculé, il faut créer les champs persistants définis.
      if Self.Fields.Count = 0 then
        raise EDatabaseError.CreateRes(@SErrorMustCreateFieldBeforeAddCalculated);
     
      Result := Self.FindField(Name);
      if not Assigned(Result) then
      begin
        Result := DefaultFieldClasses[DataType].Create(Self);
        Result.FieldName := Name;
        Result.Name := Name;
        if Self is TClientDataSet then
          Result.FieldKind := fkInternalCalc
        else
          Result.FieldKind := fkCalculated;
     
        Result.DataSet := Self;
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDataSetSliteHelper.ExportToCSV(const AFileName: TFileName; AWithHeader: Boolean; ASeparator: Char = ';'; AQuote: Char = '"');
    var
      fExport: TextFile;
      Data: TStringDynArray;
      sLigne, sCol: string;
      I: Integer;
      FBookmark: TBookmark;
    begin
      // RFC 4180 - Common Format and MIME Type for Comma-Separated Values (CSV) Files
      // The last field in the record must not be followed by a comma = La dernière colonne ne se termine pas par un séparateur !
     
      AssignFile(fExport, AFileName);
      Rewrite(fExport);
      try
        SetLength(Data, FieldCount);
     
        // Ligne d'en-tête
        if AWithHeader then
        begin
          for I := 0 to FieldCount - 1 do
            Data[I] := Fields[i].FieldName;
     
          sLigne := SLT.Common.StrUtilsEx.ImplodeLazy(Data, ASeparator);
          Writeln(fExport, sLigne);
        end;
     
        // Enregistrements
        DisableControls();
        try
          FBookmark := Bookmark;
          try
            First();
            while not Eof do
            begin
              for I := 0 to FieldCount - 1 do
              begin
                sCol := Fields[i].AsString;
                if ContainsStr(sCol, ASeparator) then
                  sCol := AQuote + sCol + AQuote;
     
                Data[I] := sCol;
              end;
     
              sLigne := SLT.Common.StrUtilsEx.ImplodeLazy(Data, ASeparator);
              Writeln(fExport, sLigne);
     
              Next();
            end;
          finally
            Bookmark := FBookmark;
          end;
        finally
          EnableControls();
        end;
      finally
        CloseFile(fExport);
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TDataSetSliteHelper.ViewInExcel(const ASheetName: string; const AFieldsNames, ATitles: array of string; AOnProgress: TNotifyEvent = nil; AOnBeforeActivateExcel: TNotifyEvent = nil; AShowWaitMessage: Boolean = True; ACellWithBorder: Boolean = False);
    begin
      Assert(Length(AFieldsNames) = Length(ATitles), 'TDataSetSliteHelper.ViewInExcel : Length(AFieldsNames) <> Length(ATitles)');
     
      with TSLTExcelDataSetExporter.Create(Self) do
      try
        OnProgress := AOnProgress;
        OnBeforeActivateExcel := AOnBeforeActivateExcel;
        ShowWaitMessage := AShowWaitMessage;
        CellWithBorder := ACellWithBorder;
        ViewInExcel(ASheetName, AFieldsNames, ATitles);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TDataSetSliteHelper.ViewInExcelProgressInfo(AProgressSender: TObject): TDataSetSliteHelperViewInExcelProgressInfo;
    begin
      if AProgressSender is TSLTExcelDataSetExporter then
        Result := TSLTExcelDataSetExporter(AProgressSender).ProgressInfo
      else
        Result.Position := 0;
    end;
     
    { TFieldSliteHelper }
     
    //------------------------------------------------------------------------------
    function TFieldSliteHelper.IsChanged(): Boolean;
    var
      OldV, NewV: Variant;
    begin
      OldV := Self.OldValue;
      NewV := Self.NewValue;
      Result := (VarType(OldV) <> VarType(NewV)) or (OldV <> NewV);
    end;
     
    { TFieldDefsSliteHelper }
     
    //------------------------------------------------------------------------------
    function TFieldDefsSliteHelper.AddCalculated(const Name: string; DataType: TFieldType; Size: Integer = 0; Required: Boolean = False): TField;
    begin
      // Avant de forcer la création d'un champ calculé, il faut créer les champs persistants définis.
      if Self.DataSet.Fields.Count = 0 then
        raise EDatabaseError.CreateRes(@SErrorMustCreateFieldBeforeAddCalculated);
     
      Result := Self.DataSet.FindField(Name);
      if not Assigned(Result) then
      begin
        Result := Self.DataSet.AddCalculatedField(Name, DataType, Size, Required);
        Self.Add(Name, DataType, Size, Required);
      end;
    end;
     
    { TCheckBoxSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TCheckBoxSliteHelper.SetSilentChecked(const Value: Boolean);
    var
      ooc: TNotifyEvent;
    begin
      ooc := Self.OnClick;
      Self.OnClick := nil;
      try
        Self.Checked := Value;
      finally
        Self.OnClick := ooc;
      end;
    end;
     
    { TRadioGroupSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TRadioGroupSliteHelper.SetSilentItemIndex(const Value: Integer);
    var
      ooc: TNotifyEvent;
    begin
      ooc := Self.OnClick;
      Self.OnClick := nil;
      try
        Self.ItemIndex:= Value
      finally
        Self.OnClick := ooc;
      end;
    end;
     
    { TPrinterSliteHelper }
     
    //------------------------------------------------------------------------------
    class function TPrinterSliteHelper.SelectPrinter(const Msg: string; var PrinterName: string): Boolean;
    begin
      Result := TPrinterSLTAssistant.SelectPrinter(Msg, PrinterName);
    end;
     
    { TCanvasSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TCanvasSliteHelper.DrawArrow(X1, Y1, X2, Y2: Integer; LineWidth: Integer; TriangleRadius: Integer; const LineText: string = '');
    begin
      with TCanvasSLTAssistant.Create(Self) do
      try
        DrawArrow(X1, Y1, X2, Y2, LineWidth, TriangleRadius, LineText);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TCanvasSliteHelper.DrawCheckBox(const Rect: TRect; Checked: Boolean);
    begin
      with TCanvasSLTAssistant.Create(Self) do
      try
        DrawCheckBox(Rect, Checked);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    procedure TCanvasSliteHelper.DrawLine(X1, Y1, X2, Y2, LineWidth: Integer);
    begin
      with TCanvasSLTAssistant.Create(Self) do
      try
        DrawLine(X1, Y1, X2, Y2, LineWidth);
      finally
        Free();
      end;
    end;
     
    //------------------------------------------------------------------------------
    class function TCanvasSliteHelper.GetConstratedColor(AColor: TColor): TColor;
    begin
      Result := TCanvasSLTAssistant.GetConstratedColor(AColor);
    end;
     
    //------------------------------------------------------------------------------
    class function TCanvasSliteHelper.GetGrayedColor(AColor: TColor): TColor;
    begin
      Result := TCanvasSLTAssistant.GetGrayedColor(AColor);
    end;
     
    { TAnimateSliteHelper }
     
    //------------------------------------------------------------------------------
    procedure TAnimateSliteHelper.ActiveThemedTabSheetTransparence();
    begin
      with TAnimateSLTAssistant.Create(Self) do
      try
        ActiveThemedTabSheetTransparence();
      finally
        Free();
      end;
    end;
     
    { TFileSliteHelper }
     
    //------------------------------------------------------------------------------
    class function TFileSliteHelper.CompareVersion(const V1, V2: string): Integer;
    begin
      Result := SLT.Common.StrUtilsEx.CompareVersion(V1, V2);
    end;
     
    { TTabSheetSliteAssistant }
     
    //------------------------------------------------------------------------------
    class function TTabSheetSliteAssistant.GetThemedBackgroundColor(): TColor;
    begin
      Result := TTabSheetSLTAssistant.GetThemedBackgroundColor();
    end;
     
    end.
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  7. #7
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 693
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 693
    Points : 13 128
    Points
    13 128
    Par défaut
    Très bien le helper checkbox

    Quelques remarques cependant :

    • Créer le helper pour TButtonControl permettrait un SilentChecked pour TCheckBox mais aussi pour TRadioButton. Pour les Helpers aussi, remonter le plus possible dans les ancêtres.
    • Eviter les unités "bric-à-brac" (ce que je faisais aussi au départ mais que j'ai vite abandonné). Mieux vaut être plus strict et créer une unité helper par unité Delphi : SysUtils -> Helper.SysUtils, Forms -> Helper.Forms, Registry -> Helper.Registry, etc.
      Il est dommage d'inclure Forms (par exemple) à une application console ou une dll si on n'a besoin que d'un helper relatif à SysUtils. La taille de l'exe (dll) s'en trouvera grandement réduite

  8. #8
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Que de bonnes remarques

    C'est drôle ce que tu dis car mes collègues actuels n'aimaient pas du tout ma façon de nommer les unités comme "SLT.Controls.VCL.ComCtrlsEx" ou "SLT.Common.SysUtilsEx"
    je fais cela pour les unités utilitaires qui n'ont rien à voir avec le métier genre xxx.SMTP, xxx.LDAP, xxx.StrUtilsEx
    Il n'aime pas les points dans les noms d'unités, je leur ai expliqué que certains pour identifier les codes communs en les regroupant dans un namespace xxx avec xxx c'est le nom de la société
    En plus du Namespace principal, je trouve cela pratique de regrouper par Thème, comme VCL/FMX/Data ...

    pour les unités de projet, j'ai conservé un nommage plus classique genre NomProjet_ThemeMetier
    Notre équipe reprend en interne des projets maintenus par un presta pendant 15 ans
    On s'est retrouvé deux cent projets, et on avait presque deux cent MainForm.pas et MainDataModule.pas, Delphi dans un groupe de projet s'y perdait et mélangeait les DataModule d'un projet à un autre
    Un de mes collègues, a compris de faire du propre dans tout ça
    il a pigé l'idée d'avoir du code en commun avec un namespace pour que cela semble être à la fin un tout cohérent presque un lib interne
    Il a d'ailleurs presque à lui tout seul, tout renommer en NomProjet_ThemeMetier, refait la structure des dossiers src/ihm, src/business, bin, bin/dcu, res, res/sql ... cela a permis de voir beaucoup de doublon, de code non utilisé ...

    L'autre collègue, lui, refuse toute évolution et continue a copier coller les codes au lieu de réutiliser

    J'ai créé ce "Dirty Wrapper" qui s'appelait uxxxHelpers pour leur faciliter la vie et par flemme, j'ai repris l'idée dans mon Slite.Helpers
    Combien de fois, dans d'autres sociétés, j'ai fait "propre" et qu'il a fallut que j'encaspule le tout dans des fonctions en code procédurale avec 20 paramètres parce que l'objet c'est fatiguant
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  9. #9
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 693
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 693
    Points : 13 128
    Points
    13 128
    Par défaut
    Citation Envoyé par ShaiLeTroll Voir le message
    L'autre, lui, refuse toute évolution et continue a copier coller les codes au lieu de réutiliser
    Le collègue à 5%
    Encore un partisan du "ça a toujours marché comme ça". Quelle plaie !

  10. #10
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Citation Envoyé par Andnotor Voir le message
    Le collègue à 5%
    quelle mémoire !

    Citation Envoyé par Andnotor Voir le message
    Encore un partisan du "ça a toujours marché comme ça". Quelle plaie !
    C'est même pas cela mais plutôt du "Fait comme tu veux, ça ne m'intéresse pas"

    Au début, j'ai voulu réutiliser ce qu'il avait mis en place comme couche ORM, cela avait l'air plutôt intéressant
    Lorsque je lui a demandé comment je devais m'y pendre pour utiliser cette couche, il m'a fait comprendre qu'il n'avait pas le temps de m'expliquer.
    J'ai tenté plusieurs fois de mettre en commun nos codes, il m'a fait comprendre un jour qu'il ne me supportait pas et que je devais arrêter de me mêler de son travail.
    Depuis lors, on travaille à deux d'un côté et lui d'un autre, et tout le monde est content ...
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  11. #11
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 693
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 693
    Points : 13 128
    Points
    13 128
    Par défaut
    Je compatis

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

Discussions similaires

  1. [C#] Petit problème avec un élément du FAQ
    Par matech dans le forum ASP.NET
    Réponses: 11
    Dernier message: 24/01/2008, 14h11
  2. Petit problème avec grep
    Par dug dans le forum Shell et commandes GNU
    Réponses: 13
    Dernier message: 11/05/2005, 15h34
  3. petit probleme avec Devil
    Par ellipse dans le forum DevIL
    Réponses: 2
    Dernier message: 01/02/2005, 18h41
  4. [TP]petit probleme avec solution
    Par pompompolom dans le forum Turbo Pascal
    Réponses: 1
    Dernier message: 02/12/2004, 19h48
  5. petit probleme avec l'éditeur de builder
    Par qZheneton dans le forum C++Builder
    Réponses: 2
    Dernier message: 28/10/2004, 16h19

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