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

 Delphi Discussion :

Personnalisation d'un InputBox (Font & Centrer le contenu) Delphi 7


Sujet :

Delphi

  1. #1
    Membre du Club
    Homme Profil pro
    Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Inscrit en
    Juin 2011
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 227
    Points : 51
    Points
    51
    Par défaut Personnalisation d'un InputBox (Font & Centrer le contenu) Delphi 7
    Salut tous le monde, je veux savoir si c'est possible de changer le font d'écriture d'un InputBox et aussi comment centrer son contenu dans la version 7 de Delphi.
    Merci d'avance.

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 042
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 042
    Points : 40 952
    Points
    40 952
    Billets dans le blog
    62
    Par défaut
    Bonjour,

    réponse courte : Non, ce n'est pas possible.

    réponse étayée : InputBox est une fonction qui appelle InputQuery, InputQuery ne fait ni plus ni moins que créer, au runtime, une forme modale.
    . Soit pour votre besoin spécifique vous créez une forme de même type pour votre projet.
    . Soit vous créez une fonction avec le même comportement. Comment ? si vous avez Delphi 7 pro, vous avez les sources (unité dialogs) en quelques clics vous retrouverez facilement la fonction InputQuery et ainsi la manière de faire
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  3. #3
    Membre du Club
    Homme Profil pro
    Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Inscrit en
    Juin 2011
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 227
    Points : 51
    Points
    51
    Par défaut
    Bonsoir, merci @SergioMaster pour la réponse, donc il faut un peu cassé la tête et créer quelque chose de spécifique.

  4. #4
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 425
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 425
    Points : 1 326
    Points
    1 326
    Par défaut
    Bonsoir à toutes et à tous,

    @ bm1990, essaye ceci pour la font :

    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
     
     
    uses MessageDlg;
     
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Integer;
    begin
      with CreateMessageDialog('- Voici un exemple', mtInformation, [mbOk], mbOk) do
      try
     
        for i := 0 to ControlCount - 1 do
          if Controls[i] is TLabel then
            with Controls[i] as TLabel do
            begin
              Font.Name := 'Times New Roman';
              Font.Size := 12;
            end;
        ShowModal;
      finally
        Free;
      end;
     
     
    end;
    Ou :

    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
     
    procedure TForm1.BButton2Click(Sender: TObject);
    var
     MsgDialogYESNO: TForm; // Identifier la variable MsgDialogOk
    begin
     
     MsgDialogYESNO := CreateMessageDialog(EMessage2.Text, mtWarning,[mbYes, mbNo]);
     with MsgDialogYESNO do
     try
     // changer le titre de Message
          Caption := ETitre2.Text;
     // Modifier le text de boutton oui
          TButton(FindComponent('Yes')).Caption := EButtonYES2.Text;
     // Modifier le text de boutton non
          TButton(FindComponent('No')).Caption := EButtonNO2.Text;
     // Modifier l'apparence de message avec l'annimation
          AnimateWindow(Handle, 500, AW_CENTER);
     // Définir la position de message
          Position := poScreenCenter;
     // Afficher le message
          ShowModal;
     finally
     // Libérer la mémoire
      Free;
     end;
     
     end;
    @+,

    cincap

  5. #5
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 042
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 042
    Points : 40 952
    Points
    40 952
    Billets dans le blog
    62
    Par défaut
    Bonjour,
    Citation Envoyé par bm1990 Voir le message
    donc il faut un peu cassé la tête et créer quelque chose de spécifique.
    je n'appelle pas "faire un copier coller de quelques lignes (67)" se casser la tête !
    Au contraire, apprendre à naviguer dans les sources pour comprendre comment cela fonctionne est très formateur, en lisant et modifiant ces 67 lignes vous apprendrez à créer une forme au runtime
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  6. #6
    Membre éprouvé
    Avatar de Cirec
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    467
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 467
    Points : 1 072
    Points
    1 072
    Par défaut
    Citation Envoyé par SergioMaster Voir le message
    Bonjour,


    je n'appelle pas "faire un copier coller de quelques lignes (67)" se casser la tête !
    Au contraire, apprendre à naviguer dans les sources pour comprendre comment cela fonctionne est très formateur, en lisant et modifiant ces 67 lignes vous apprendrez à créer une forme au runtime
    Bonjour,

    je confirme que le fait de mettre le nez dans les sources de la VCL
    a été ma plus grande source d'apprentissage de progression d'inspiration etc. etc.

    D'ailleurs une fois pris l'habitude de les "utiliser" il est très embêtant de ne plus y avoir accès (version Starter )

    Tout ça pour dire qu'il serait "criminel" de s'en passer (si on les possèdes bien sûr)

    Cordialement,

    @+

  7. #7
    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 Cirec Voir le message
    je confirme que le fait de mettre le nez dans les sources de la VCL
    a été ma plus grande source d'apprentissage de progression d'inspiration etc. etc.
    De loin aussi ma meilleure source, j'ai passé en revue Classes.pas un tas de fois



    Désolé, je n'ai plus exactement les version Delphi 7 mais depuis longtemps, j'ai personnalisé les InputBox, regarde MessageDlgPosFont, tu peux changer la Font et la Position, donc tout ce dont tu as besoin
    MessageDlgPosFont est a mon avis recopié de D7, la partie procédure de l'unité étant assez ancienne

    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
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527
    1528
    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    //------------------------------------------------------------------------------
    (*                SoLuTions is an Versatile Library for Delphi                 -
     *                                                                             -
     *  Version alternative publiée sur "www.developpez.net"                       -
     *  Post : "MessageBox ou MessageDlg ?"                                        -
     *  Post Number : 2530570                                                      -
     *  Post URL = "http://www.developpez.net/forums/d417066/environnements-developpement/delphi/debutant/messagebox-messagedlg/#post2530570"
     *                                                                             -
     *  Version alternative publiée sur "www.developpez.net"                       -
     *  Post : "Personnaliser les boutons du MessageDialog"                        -
     *  Post Number : 4662116                                                      -
     *  Post URL = "http://www.developpez.net/forums/d811727/environnements-developpement/delphi/debutant/personnaliser-boutons-messagedialog/#post4662116"
     *                                                                             -
     *  Copyright "SLT Solutions", (©2006)                                         -
     *  contributeur : ShaiLeTroll (2007) - Passage en Classe d'un code procédural -
     *  contributeur : ShaiLeTroll (2012) - Passage en Enregistrement avancé au lieu d'une classe
     *  contributeur : ShaiLeTroll (2012) - Renommage Fichier et Correction XE2    -
     *  contributeur : ShaiLeTroll (2012) - Documentation Insight                  -
     *  contributeur : ShaiLeTroll (2014) - Retour en classe au lieu d'un Enregistrement avancé car cela permet un héritage
     *                                                                             -
     *                                                                             -
     * Ce logiciel est un programme informatique servant à aider les développeurs  -
     * Delphi avec une bibliothèque polyvalente, adaptable et fragmentable.        -
     *                                                                             -
     * 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 SLT.Controls.VCL.DialogsEx;
     
    interface
     
    uses System.Classes, System.Types, System.UITypes, System.Math, System.Generics.Collections,
      VCL.Forms, Vcl.Controls, VCL.StdCtrls, Vcl.Buttons, VCL.Dialogs, VCL.Graphics, Vcl.AppEvnts,
      VCL.Samples.Spin,
      Winapi.Windows, Winapi.Messages;
     
    type
      /// <summary>Type de valeurs devant être récupérées par le dialogue fournit par la méthode TSLTMessageDlg.InputDateTime</summary>
      TSLTTInputDateTimeKind = (idtkDate, idtkTime, idtkDateTime);
     
      /// <summary>TSLTMessageDlg fournit une variante d'appel à MessageDlgCustomBtn et MessageDlgFont</summary>
      TSLTMessageDlg = class(TObject)
      private
        type
          TSLTInputQueryForm = class(TForm)
          private
            FEdit: TEdit;
            FAllowCloseBySystemMenu: Boolean;
          public
            function CloseQuery(): Boolean; override;
            procedure WMClose(var Message: TWMClose); message WM_CLOSE;
          end;
      private
        class var
          FApplicationEvents: TApplicationEvents;
          FForms: System.Generics.Collections.TList<TForm>;
      private
        class function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TForm; overload;
        class function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn): TForm; overload;
        class procedure RegisterForm(AForm: TForm);
        class procedure UnregisterForm(AForm: TForm);
        class procedure BringToFrontRegisteredForms();
     
        class procedure ApplicationEventDefaultEventHandler(Sender: TObject);
        class procedure RegisterFormDestroyEventHandler(Sender: TObject);
      strict private
        class procedure InputIntegerFormCloseEventHandler(Sender: TObject; var Action: TCloseAction);
      public
        /// <summary>DEFAULT permet de conserver le libellé d'origine parmi des libellés personnalisés</summary>
        const DEFAULT = '';
        /// <summary>TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpCustomBtn avec des libellés personnalisés pour chaque bouton</summary>
        class function Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of string; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer; overload; static;
        /// <summary>TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpFont avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
        class function Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer; overload; static;
        /// <summary>TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpFont avec la Gestion de la Font pour la fenêtre et les Boutons dont un bouton par défaut</summary>
        class function Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont = nil; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer; overload; static;
     
        /// <summary>TSLTMessageDlg.InputString fournit un dialogue proche d'un InputQuery avec des limitations sur le clavier et les menus</summary>
        class function InputString(const ACaption: string; const APrompt: string; var AValue: string; AButtonAcceptKeyboard: Boolean = True; AAllowCloseBySystemMenu: Boolean = False): Boolean;
        /// <summary>TSLTMessageDlg.InputDateTime fournit un dialogue proche d'un InputQuery avec un sélecteur de Date et\ou d'heure</summary>
        class function InputDateTime(const Msg: string; var Value: TDateTime; AKind: TSLTTInputDateTimeKind = idtkDate): Boolean; static;
        /// <summary>TSLTMessageDlg.InputDates fournit un dialogue proche d'un InputQuery avec un sélecteur multiples de Date</summary>
        class function InputDates(const Msg: string; const APrompts: array of string; var AValues: array of TDateTime): Boolean; static;
        /// <summary>TSLTMessageDlg.InputPrinter fournit un dialogue proche d'un InputQuery avec un sélecteur d'entier</summary>
        class function InputInteger(const Msg: string; const APrompt: string; var AValue: Integer; const AMinValue: Integer = 0; const AMaxValue: Integer = 0): Boolean; overload; static;
        class function InputInteger(const Msg: string; const APrompt: string; var AValue: Int64; const AMinValue: Int64 = 0; const AMaxValue: Int64 = 0): Boolean; overload; static;
        /// <summary>TSLTMessageDlg.InputPrinter fournit un dialogue proche d'un InputQuery avec un sélecteur d'imprimante bien plus simple que le TPrintDialog</summary>
        class function InputPrinter(const Msg: string; var PrinterName: string): Boolean; static;
        /// <summary>TSLTMessageDlg.InputCombo fournit un dialogue proche d'un InputQuery avec un sélecteur en liste déroulante</summary>
        class function InputCombo(const Msg: string; ComboItems: TStrings; var ComboItemIndex: Integer; ComboDropDownList: Boolean = True): Boolean; static;
      public
        class destructor Destroy();
      end;
     
    /// <summary>MessageDlgCustomBtn fonctionne comme MessageDlg avec des libellés personnalisés pour chaque bouton</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="ButtonStrings">Fourni les libellés personnalisés pour chaque bouton</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgCustomBtn(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of String; HelpCtx: Longint = 0): Integer;
     
    /// <summary>MessageDlgPosHelpCustomBtn fonctionne comme MessageDlgPosHelp avec des libellés personnalisés pour chaque bouton</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="ButtonStrings">Fourni les libellés personnalisés pour chaque bouton</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <param name="X">Position Horizontale du Message</param>
    /// <param name="Y">Position Verticale du Message</param>
    /// <param name="HelpFileName">Fichier d'aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgPosHelpCustomBtn(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of String; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer;
     
    /// <summary>MessageDlgFont fonctionne comme MessageDlg avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint = 0): Integer; overload;
    /// <summary>MessageDlgFont fonctionne comme MessageDlg avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="DefaultButton">Désigne le bouton qui sera actif par défaut</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont; HelpCtx: Longint = 0): Integer; overload;
    /// <summary>MessageDlgPosFont fonctionne comme MessageDlgPos avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <param name="X">Position Horizontale du Message</param>
    /// <param name="Y">Position Verticale du Message</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgPosFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint; X, Y: Integer): Integer; overload;
    /// <summary>MessageDlgPosFont fonctionne comme MessageDlgPos avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="DefaultButton">Désigne le bouton qui sera actif par défaut</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <param name="X">Position Horizontale du Message</param>
    /// <param name="Y">Position Verticale du Message</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgPosFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont; HelpCtx: Longint; X, Y: Integer): Integer; overload;
    /// <summary>MessageDlgPosHelpFont fonctionne comme MessageDlgPosHelp avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <param name="X">Position Horizontale du Message</param>
    /// <param name="Y">Position Verticale du Message</param>
    /// <param name="HelpFileName">Fichier d'aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer; overload;
    /// <summary>MessageDlgPosHelpFont fonctionne comme MessageDlgPosHelp avec la Gestion de la Font pour la fenêtre et les Boutons</summary>
    /// <param name="Msg">Chaine à Afficher</param>
    /// <param name="DlgType">Type du Dialogue</param>
    /// <param name="Buttons">Ensemble de boutons</param>
    /// <param name="DefaultButton">Désigne le bouton qui sera actif par défaut</param>
    /// <param name="FontMsg">Font spécifique pour Fenêtre et Boutons</param>
    /// <param name="HelpCtx">Contexte d'Aide</param>
    /// <param name="X">Position Horizontale du Message</param>
    /// <param name="Y">Position Verticale du Message</param>
    /// <param name="HelpFileName">Fichier d'aide</param>
    /// <returns>Entier Résultat associé à chaque Bouton</returns>
    function MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer; overload;
     
    implementation
     
    uses System.SysUtils, System.DateUtils, System.StrUtils,
      Vcl.ComCtrls, Vcl.Printers, Vcl.Consts,
      SLT.Controls.VCL.GraphicsEx;
     
    { TSLTMessageDlg }
     
    {* --- TSLTMessageDlg.ApplicationEventDefaultEventHandler -------------------- }
    class procedure TSLTMessageDlg.ApplicationEventDefaultEventHandler(Sender: TObject);
    begin
      BringToFrontRegisteredForms();
    end;
     
    {* --- TSLTMessageDlg.CreateMessageDialog ------------------------------------ }
    class function TSLTMessageDlg.CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TForm;
    begin
      Result := Vcl.Dialogs.CreateMessageDialog(Msg, DlgType, Buttons);
      RegisterForm(Result);
    end;
     
    {* --- TSLTMessageDlg.BringToFrontRegisteredForms ---------------------------- }
    class procedure TSLTMessageDlg.BringToFrontRegisteredForms();
     
      procedure Flash(AForm: TForm);
      var
        pfwi: FLASHWINFO;
      begin
        pfwi.cbSize := SizeOf(pfwi);
        pfwi.hwnd := AForm.Handle;
        pfwi.uCount := 5;
        pfwi.dwFlags := FLASHW_ALL;
        pfwi.dwTimeout := 50;
        FlashWindowEx(pfwi);
      end;
     
    var
      I: Integer;
    begin
      for I := 0 to FForms.Count - 1 do
      begin
        FForms[I].BringToFront();
        Flash(FForms[I]);
      end;
    end;
     
    {* --- TSLTMessageDlg.CreateMessageDialog ------------------------------------ }
    class function TSLTMessageDlg.CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn): TForm;
    begin
      Result := Vcl.Dialogs.CreateMessageDialog(Msg, DlgType, Buttons, DefaultButton);
      RegisterForm(Result);
    end;
     
    {* --- TSLTMessageDlg.Destroy ------------------------------------------------ }
    class destructor TSLTMessageDlg.Destroy();
    begin
      FreeAndNil(FApplicationEvents);
      FreeAndNil(FForms);
    end;
     
    {* --- TSLTMessageDlg.InputCombo -----------------------------------------------------
    TSLTMessageDlg.InputCombo fournit un dialogue proche d'un InputQuery avec un sélecteur en liste déroulante
    @param Msg Chaine à Afficher
    @param ComboItems Liste des élements de la liste déroulante
    @param ComboItemIndex Element pré-selectionné
    @param AComboDropDownList indique si l'on est en Style csDropDownList plus fiable que le mode csDropDown par contre ce dernier est plus pratique pour l'auto-complétion d'une longue liste
    @return Booléen InputCombo renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputCombo(const Msg: string; ComboItems: TStrings; var ComboItemIndex: Integer; ComboDropDownList: Boolean = True): Boolean;
     
      function GetAveCharSize(AFont: TFont): TSize;
      begin
        Result := TFontSLTToolHelp.GetTextSize(Msg, AFont);
        Result.Width := Result.Width div Max(Length(Msg), 1); // Average !
      end;
     
    const
      mcHorzMargin = 8;
      mcVertMargin = 8;
      mcHorzSpacing = 10;
    var
      MsgForm: TForm;
      MsgLabel: TComponent;
      DialogUnits: TSize;
      InputWidth, InputHeight, I, K: Integer;
      HorzMargin, VertMargin, HorzSpacing, HorzOffset, VertOffset: Integer;
      PickCombo: TComboBox;
      PickText: string;
      IndexControls: Integer;
      XY: TPoint;
    begin
      Result := False;
     
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, mtConfirmation, mbOKCancel);
      with MsgForm do
      try
        if not (ContainsStr(Msg, #13) or ContainsStr(Msg, #10)) then
          Caption := Msg;
        MsgLabel := FindComponent('Message');
        if MsgLabel is TLabel then
        begin
          DialogUnits := GetAveCharSize(Font);
          HorzMargin := MulDiv(mcHorzMargin, DialogUnits.Width, 4);
          VertMargin := MulDiv(mcVertMargin, DialogUnits.Height, 8);
          HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.Width, 4);
     
          PickCombo := TComboBox.Create(MsgForm);
          PickCombo.Parent := MsgForm;
          PickCombo.Visible := True;
          if ComboDropDownList then
            PickCombo.Style := csDropDownList
          else
            PickCombo.Style := csDropDown;
          InputHeight := PickCombo.Height;
          PickCombo.Items.Assign(ComboItems);
          PickCombo.ItemIndex := ComboItemIndex;
     
          K := TLabel(MsgLabel).Width;
          for I := 0 to PickCombo.Items.Count - 1 do
          begin
            PickText := PickCombo.Items[I];
            K := Max(K, TFontSLTToolHelp.GetTextWidth(PickText, PickCombo.Font));
          end;
     
          PickCombo.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin + VertMargin div 2;
          PickCombo.Width := K + HorzSpacing + InputHeight*2;
          InputWidth := PickCombo.Width;
          ActiveControl := PickCombo;
     
          HorzOffset := Max(InputWidth - TLabel(MsgLabel).Width, 0);
          VertOffset := VertMargin + InputHeight;
          for IndexControls := 0 to ControlCount - 1 do
          begin
            if Controls[IndexControls] is TButton then
            begin
              with TButton(Controls[IndexControls]) do
              begin
                Top := Top + VertOffset;
                Left := Left + HorzOffset div 2;
              end;
            end;
          end;
     
          Height := Height + VertOffset;
          Width := Width + HorzOffset;
          PickCombo.Left := (ClientWidth - PickCombo.Width) div 2 + HorzMargin;
     
          XY := Mouse.CursorPos;
          XY.X := XY.X - Width div 2;
          XY.Y := XY.Y - Height div 2;
          if XY.X < Screen.WorkAreaLeft then
            XY.X := Screen.WorkAreaLeft;
          if XY.Y < Screen.WorkAreaTop then
            XY.Y := Screen.WorkAreaTop;
          if XY.X + Width > Screen.WorkAreaWidth then
            XY.X := Screen.WorkAreaWidth - Width;
          if XY.Y + Height > Screen.WorkAreaHeight then
            XY.Y := Screen.WorkAreaHeight - Height;
     
          Left := XY.X;
          Top := XY.Y;
          if ShowModal() = mrOk then
          begin
            // L'Auto-Complete était moins fiable dans les versions précédentes, ce code date de C++Builder 2007, je le mets au cas où !
            if not ComboDropDownList then
            begin
              // Un item est sélectionné
              if PickCombo.ItemIndex >= 0  then
              begin
                // le texte en cours n'est pas le même que le texte de l'item sélectionné
                if not SameText(PickCombo.Text, PickCombo.Items[PickCombo.ItemIndex]) then
                  if MessageDlg('Confirmez vous la sélection de ' + PickCombo.Items[PickCombo.ItemIndex], mtWarning, mbYesNo, 0) <> mrYes then
                    Exit;
              end
              else
              begin
                // pas d'item selectionné mais un texte présent, recherche du texte pour sélectionner l'item qui aurait du l'être !
                if PickCombo.Text <> ''  then
                  PickCombo.ItemIndex := PickCombo.Items.IndexOf(PickCombo.Text);
              end;
            end;
     
            ComboItemIndex := PickCombo.ItemIndex;
            Result := True;
          end;
        end
        else
          Abort;
      finally
        Free;
      end;
    end;
     
    {* --- TSLTMessageDlg.InputDateTime -----------------------------------------------------
    TSLTMessageDlg.InputDates fournit un dialogue proche d'un InputQuery des champs de saisie de type TDateTimePicker. Utilisez InputDates pour afficher une boîte de dialogue qui contient un nombre de contrôles TDateTimePicker égal au nombre de chaînes de APrompts
    @param Msg Chaine à Afficher
    @param APrompts sont les textes d'invite l'utilisateur à entrer des données dans les boîtes de saisie.
    @param AValues Valeurs affichées à l'ouverture du Dialogue et contiendra les valeurs acceptées par l'utilisateur
    @return Booléen InputDates renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputDates(const Msg: string; const APrompts: array of string; var AValues: array of TDateTime): Boolean;
     
      function GetAveCharSize(AFont: TFont): TSize;
      begin
        Result := TFontSLTToolHelp.GetTextSize(Msg, AFont);
        Result.Width := Result.Width div Max(Length(Msg), 1); // Average !
      end;
     
      function GetMaxPromptWidth(AFont: TFont; ADialogUnits: TSize): Integer;
      var
        I: Integer;
      begin
        Result := 0;
        for I := Low(APrompts) to High(APrompts) do
          Result := Max(Result, TFontSLTToolHelp.GetTextSize(APrompts[I], AFont).Width + ADialogUnits.Width);
      end;
     
     
    const
      mcHorzMargin = 8;
      mcVertMargin = 8;
      mcHorzSpacing = 10;
    var
      MsgForm: TForm;
      MsgLabel: TComponent;
      DialogUnits: TSize;
      InputWidth, InputHeight, InputLeft: Integer;
      HorzMargin, VertMargin, HorzSpacing, HorzOffset, VertOffset: Integer;
      LabelPicker: TLabel;
      DatePicker: TDateTimePicker;
      DatePickers: array of TDateTimePicker;
      IndexControls, iPrompt: Integer;
      XY: TPoint;
    begin
      if Length(AValues) < Length(APrompts) then
        raise EInvalidOperation.CreateRes(@SPromptArrayTooShort);
      if Length(APrompts) < 1 then
        raise EInvalidOperation.CreateRes(@SPromptArrayEmpty);
      SetLength(DatePickers, Length(APrompts));
     
      Result := False;
     
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, mtConfirmation, mbOKCancel);
      with MsgForm do
      try
        if not (ContainsStr(Msg, #13) or ContainsStr(Msg, #10)) then
          Caption := Msg;
        MsgLabel := FindComponent('Message');
        if MsgLabel is TLabel then
        begin
          DialogUnits := GetAveCharSize(Font);
          HorzMargin := MulDiv(mcHorzMargin, DialogUnits.Width, 4);
          VertMargin := MulDiv(mcVertMargin, DialogUnits.Height, 8);
          HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.Width, 4);
     
          InputHeight := 0;
          InputWidth := 0;
          InputLeft := Max(GetMaxPromptWidth(MsgForm.Font, DialogUnits) + HorzMargin + HorzSpacing, MsgForm.Width div 2);
     
          for iPrompt := Low(APrompts) to High(APrompts) do
          begin
            LabelPicker := TLabel.Create(MsgForm);
            LabelPicker.Parent := MsgForm;
            LabelPicker.Caption := APrompts[iPrompt];
            LabelPicker.Alignment := taRightJustify;
            LabelPicker.Left := InputLeft - LabelPicker.Width - HorzSpacing div 2;
            LabelPicker.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin*2 + (InputHeight + VertMargin) * iPrompt;
     
            DatePicker := TDateTimePicker.Create(MsgForm);
            DatePickers[iPrompt] := DatePicker;
            DatePicker.Parent := MsgForm;
            DatePicker.Kind := dtkDate;
            DatePicker.Visible := True;
            InputHeight := DatePicker.Height;
            DatePicker.Top := LabelPicker.Top - (DatePicker.Height - LabelPicker.Height) div 2;
            DatePicker.Width := TFontSLTToolHelp.GetTextWidth(DateToStr(AValues[iPrompt]), DatePicker.Font) + HorzSpacing + InputHeight*2;
            InputWidth := DatePicker.Width;
            DatePicker.Left := InputLeft;
            DatePicker.Date := DateOf(AValues[iPrompt]);
            if ActiveControl = nil then
              ActiveControl := DatePicker;
          end;
     
          HorzOffset := Max(InputLeft + InputWidth + HorzMargin - ClientWidth, 0);
          VertOffset := (InputHeight + VertMargin) * Length(APrompts);
          for IndexControls := 0 to ControlCount - 1 do
          begin
            if Controls[IndexControls] is TButton then
            begin
              with TButton(Controls[IndexControls]) do
              begin
                Top := Top + VertOffset;
                Left := Left + HorzOffset div 2;
              end;
            end;
          end;
     
          Height := Height + VertOffset;
          Width := Width + HorzOffset;
     
          XY := Mouse.CursorPos;
          XY.X := XY.X - Width div 2;
          XY.Y := XY.Y - Height div 2;
          if XY.X < Screen.WorkAreaLeft then
            XY.X := Screen.WorkAreaLeft;
          if XY.Y < Screen.WorkAreaTop then
            XY.Y := Screen.WorkAreaTop;
          if XY.X + Width > Screen.WorkAreaWidth then
            XY.X := Screen.WorkAreaWidth - Width;
          if XY.Y + Height > Screen.WorkAreaHeight then
            XY.Y := Screen.WorkAreaHeight - Height;
     
          Left := XY.X;
          Top := XY.Y;
          if ShowModal() = mrOk then
          begin
            Result := True;
            for iPrompt := Low(APrompts) to High(APrompts) do
              AValues[iPrompt] := DatePickers[iPrompt].Date;
          end;
        end
        else
          Abort;
      finally
        Free;
      end;
    end;
     
    {* --- TSLTMessageDlg.InputDateTime -----------------------------------------------------
    TSLTMessageDlg.InputDateTime fonctionne comme un InputQuery avec un champ de saisie de type TDateTimePicker
    @param Msg Chaine à Afficher
    @param Value Valeur affichée à l'ouverture du Dialogue et contiendra la valeur acceptée par l'utilisateur
    @param AKind Indique si l'on affiche une sélection de Date (par défaut), une selection de l'Heure ou une double sélection incluant Date ET Heure
    @return Booléen InputDateTime renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputDateTime(const Msg: string; var Value: TDateTime; AKind: TSLTTInputDateTimeKind = idtkDate): Boolean;
     
      function GetAveCharSize(AFont: TFont): TSize;
      begin
        Result := TFontSLTToolHelp.GetTextSize(Msg, AFont);
        Result.Width := Result.Width div Max(Length(Msg), 1); // Average !
      end;
     
    const
      mcHorzMargin = 8;
      mcVertMargin = 8;
      mcHorzSpacing = 10;
    var
      MsgForm: TForm;
      MsgLabel: TComponent;
      DialogUnits: TSize;
      InputWidth, InputHeight: Integer;
      HorzMargin, VertMargin, HorzSpacing, HorzOffset, VertOffset: Integer;
      DatePicker, TimePicker: TDateTimePicker;
      IndexControls: Integer;
      XY: TPoint;
    begin
      Result := False;
     
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, mtConfirmation, mbOKCancel);
      with MsgForm do
      try
        if not (ContainsStr(Msg, #13) or ContainsStr(Msg, #10)) then
          Caption := Msg;
        MsgLabel := FindComponent('Message');
        if MsgLabel is TLabel then
        begin
          DialogUnits := GetAveCharSize(Font);
          HorzMargin := MulDiv(mcHorzMargin, DialogUnits.Width, 4);
          VertMargin := MulDiv(mcVertMargin, DialogUnits.Height, 8);
          HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.Width, 4);
     
          InputHeight := 0;
          InputWidth := 0;
          if (AKind = idtkDate) or (AKind = idtkDateTime) then
          begin
            DatePicker := TDateTimePicker.Create(MsgForm);
            DatePicker.Parent := MsgForm;
            DatePicker.Kind := dtkDate;
            DatePicker.Visible := True;
            InputHeight := DatePicker.Height;
            DatePicker.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin + VertMargin div 2;
            DatePicker.Width := TFontSLTToolHelp.GetTextWidth(DateToStr(Value), DatePicker.Font) + HorzSpacing + InputHeight*2;
            InputWidth := DatePicker.Width;
            DatePicker.Left := (ClientWidth - DatePicker.Width) div 2 + HorzMargin;
            DatePicker.Date := DateOf(Value);
            ActiveControl := DatePicker;
          end
          else
            DatePicker := nil;
     
          if (AKind = idtkTime) or (AKind = idtkDateTime) then
          begin
            TimePicker := TDateTimePicker.Create(MsgForm);
            TimePicker.Parent := MsgForm;
            TimePicker.Kind := dtkTime;
            TimePicker.Visible := True;
            InputHeight := TimePicker.Height;
            TimePicker.Width := TFontSLTToolHelp.GetTextWidth(TimeToStr(Value), TimePicker.Font) + HorzSpacing + InputHeight*2;
            if Assigned(DatePicker) then
            begin
              TimePicker.Top := DatePicker.Top;
              DatePicker.Left := (ClientWidth - TimePicker.Width - HorzSpacing - DatePicker.Width) div 2 + HorzSpacing;
              TimePicker.Left := DatePicker.Left + DatePicker.Width + HorzSpacing;
              InputWidth := DatePicker.Width + HorzSpacing + TimePicker.Width;
            end
            else
            begin
              TimePicker.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin + VertMargin div 2;
              TimePicker.Left := (ClientWidth - TimePicker.Width) div 2 + HorzSpacing;
              InputWidth := TimePicker.Width;
              ActiveControl := TimePicker;
            end;
            TimePicker.Time := TimeOf(Value);
          end
          else
            TimePicker := nil;
     
          HorzOffset := Max(InputWidth - TLabel(MsgLabel).Width, 0);
          VertOffset := VertMargin + InputHeight;
          for IndexControls := 0 to ControlCount - 1 do
          begin
            if Controls[IndexControls] is TButton then
            begin
              with TButton(Controls[IndexControls]) do
              begin
                Top := Top + VertOffset;
                Left := Left + HorzOffset div 2;
              end;
            end;
          end;
     
          Height := Height + VertOffset;
          Width := Width + HorzOffset;
          if HorzOffset > 0 then
          begin
            if Assigned(DatePicker) then
              DatePicker.Left := DatePicker.Left + HorzOffset div 2;
            if Assigned(TimePicker) then
              TimePicker.Left := TimePicker.Left + HorzOffset div 2;
          end;
     
          XY := Mouse.CursorPos;
          XY.X := XY.X - Width div 2;
          XY.Y := XY.Y - Height div 2;
          if XY.X < Screen.WorkAreaLeft then
            XY.X := Screen.WorkAreaLeft;
          if XY.Y < Screen.WorkAreaTop then
            XY.Y := Screen.WorkAreaTop;
          if XY.X + Width > Screen.WorkAreaWidth then
            XY.X := Screen.WorkAreaWidth - Width;
          if XY.Y + Height > Screen.WorkAreaHeight then
            XY.Y := Screen.WorkAreaHeight - Height;
     
          Left := XY.X;
          Top := XY.Y;
          if ShowModal() = mrOk then
          begin
            Result := True;
            if (AKind = idtkDate) or (AKind = idtkDateTime) then
              Value := DateOf(DatePicker.Date)
            else
              Value := 0;
     
            if (AKind = idtkTime) or (AKind = idtkDateTime) then
              Value := Value + TimeOf(DatePicker.Time);
          end;
        end
        else
          Abort;
      finally
        Free;
      end;
    end;
     
    {* --- TSLTMessageDlg.InputInteger -----------------------------------------------------
    TSLTMessageDlg.InputInteger fonctionne comme un InputQuery avec un champ de saisie de type TSpinEdit
    @param Msg Chaine à Afficher
    @param Value Valeur affichée à l'ouverture du Dialogue et contiendra la valeur acceptée par l'utilisateur
    @param AMinValue limite basse
    @param AMaxValue limite haute
    @return Booléen InputInteger renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputInteger(const Msg: string; const APrompt: string; var AValue: Integer; const AMinValue: Integer = 0; const AMaxValue: Integer = 0): Boolean;
    var
      LValue: Int64;
    begin
      LValue := AValue;
      Result := InputInteger(Msg, APrompt, LValue, AMinValue, AMaxValue);
      if Result then
        AValue := LValue;
    end;
     
    {* --- TSLTMessageDlg.InputInteger ---------------------------------------------
    TSLTMessageDlg.InputInteger fonctionne comme un InputQuery avec un champ de saisie de type TEdit ou TSpinEdit
    @param Msg Chaine à Afficher
    @param Value Valeur affichée à l'ouverture du Dialogue et contiendra la valeur acceptée par l'utilisateur
    @param AMinValue limite basse
    @param AMaxValue limite haute
    @return Booléen InputInteger renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputInteger(const Msg: string; const APrompt: string; var AValue: Int64; const AMinValue: Int64 = 0; const AMaxValue: Int64 = 0): Boolean;
     
      function GetAveCharSize(AFont: TFont): TSize;
      begin
        Result := TFontSLTToolHelp.GetTextSize(Msg, AFont);
        Result.Width := Result.Width div Max(Length(Msg), 1); // Average !
      end;
     
    const
      mcHorzMargin = 8;
      mcVertMargin = 8;
      mcHorzSpacing = 10;
    var
      MsgForm: TForm;
      MsgLabel: TComponent;
      DialogUnits: TSize;
      InputWidth, InputHeight: Integer;
      HorzMargin, VertMargin, HorzSpacing, HorzOffset, VertOffset: Integer;
      IntegerEdit: TSpinEdit;
      Int64Edit: TEdit;
      IndexControls: Integer;
      XY: TPoint;
    begin
      Result := False;
     
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, mtConfirmation, mbOKCancel);
      with MsgForm do
      try
        MsgForm.OnClose := InputIntegerFormCloseEventHandler;
     
        if not (ContainsStr(Msg, #13) or ContainsStr(Msg, #10)) then
          Caption := Msg;
        MsgLabel := FindComponent('Message');
        if MsgLabel is TLabel then
        begin
          DialogUnits := GetAveCharSize(Font);
          HorzMargin := MulDiv(mcHorzMargin, DialogUnits.Width, 4);
          VertMargin := MulDiv(mcVertMargin, DialogUnits.Height, 8);
          HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.Width, 4);
     
          if (AMinValue < AMaxValue) and ((Low(Integer) <= AValue) and (AValue <= High(Integer))) and ((Low(Integer) <= AMinValue) and (AMinValue <= High(Integer))) and ((Low(Integer) <= AMaxValue) and (AMaxValue <= High(Integer))) then
          begin
            Int64Edit := nil;
            IntegerEdit := TSpinEdit.Create(MsgForm);
            IntegerEdit.Name := 'Edit';
            IntegerEdit.Parent := MsgForm;
            IntegerEdit.MinValue := AMinValue;
            IntegerEdit.MaxValue := AMaxValue;
            IntegerEdit.Visible := True;
            InputHeight := IntegerEdit.Height;
            IntegerEdit.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin + VertMargin div 2;
            IntegerEdit.Width := TFontSLTToolHelp.GetTextWidth(IntToStr(High(Integer)), IntegerEdit.Font) + HorzSpacing + InputHeight*3;
            InputWidth := IntegerEdit.Width;
            IntegerEdit.Left := (ClientWidth - IntegerEdit.Width) div 2 + HorzMargin;
            IntegerEdit.Value := AValue;
            ActiveControl := IntegerEdit;
          end
          else
          begin
            IntegerEdit := nil;
            Int64Edit := TEdit.Create(MsgForm);
            Int64Edit.Name := 'Edit';
            Int64Edit.Parent := MsgForm;
            Int64Edit.NumbersOnly := True;
            Int64Edit.MaxLength := Length(IntToStr(High(Int64)));
            Int64Edit.Visible := True;
            InputHeight := Int64Edit.Height;
            Int64Edit.Top := TLabel(MsgLabel).Top + TLabel(MsgLabel).Height + VertMargin + VertMargin div 2;
            Int64Edit.Width := TFontSLTToolHelp.GetTextWidth(IntToStr(High(Int64)), Int64Edit.Font) + HorzSpacing + InputHeight*2;
            InputWidth := Int64Edit.Width;
            Int64Edit.Left := (ClientWidth - Int64Edit.Width) div 2 + HorzMargin;
            Int64Edit.Text := IntToStr(AValue);
            ActiveControl := Int64Edit;
          end;
     
          HorzOffset := Max(InputWidth - TLabel(MsgLabel).Width, 0);
          VertOffset := VertMargin + InputHeight;
          for IndexControls := 0 to ControlCount - 1 do
          begin
            if Controls[IndexControls] is TButton then
            begin
              with TButton(Controls[IndexControls]) do
              begin
                Top := Top + VertOffset;
                Left := Left + HorzOffset div 2;
              end;
            end;
          end;
     
          Height := Height + VertOffset;
          Width := Width + HorzOffset;
          if HorzOffset > 0 then
          begin
            if Assigned(IntegerEdit) then
              IntegerEdit.Left := IntegerEdit.Left + HorzOffset div 2
            else
              Int64Edit.Left := Int64Edit.Left + HorzOffset div 2;
          end;
     
          XY := Mouse.CursorPos;
          XY.X := XY.X - Width div 2;
          XY.Y := XY.Y - Height div 2;
          if XY.X < Screen.WorkAreaLeft then
            XY.X := Screen.WorkAreaLeft;
          if XY.Y < Screen.WorkAreaTop then
            XY.Y := Screen.WorkAreaTop;
          if XY.X + Width > Screen.WorkAreaWidth then
            XY.X := Screen.WorkAreaWidth - Width;
          if XY.Y + Height > Screen.WorkAreaHeight then
            XY.Y := Screen.WorkAreaHeight - Height;
     
          Left := XY.X;
          Top := XY.Y;
          if ShowModal() = mrOk then
          begin
            Result := True;
            if Assigned(IntegerEdit) then
              AValue := IntegerEdit.Value
            else
              AValue := StrToInt64(Int64Edit.Text);
          end;
        end
        else
          Abort;
      finally
        Free;
      end;
    end;
     
    {* --- TSLTMessageDlg.InputInteger ---------------------------------------------
    Controle de la saisie
    ------------------------------------------------------------------------------ }
    class procedure TSLTMessageDlg.InputIntegerFormCloseEventHandler(Sender: TObject; var Action: TCloseAction);
    var
      Edit: TComponent;
      V: Int64;
    begin
      Edit := (Sender as TForm).FindComponent('Edit');
      if Edit is TEdit then
        if not TryStrToInt64(TEdit(Edit).Text, V) then
          Action := caNone;
    end;
     
    {* --- TSLTMessageDlg.InputPrinter -----------------------------------------------------
    TSLTMessageDlg.InputPrinter fournit un dialogue proche d'un InputQuery avec un sélecteur d'imprimante bien plus simple que le TPrintDialog
    @param Msg Chaine à Afficher
    @param PrinterName Nom de l'imprimante affichée à l'ouverture du Dialogue et contiendra la valeur acceptée par l'utilisateur
    @return Booléen InputPrinter renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputPrinter(const Msg: string; var PrinterName: string): Boolean;
    var
      PrinterIndex: Integer;
    begin
      PrinterIndex := Printer.Printers.IndexOf(PrinterName);
      Result := InputCombo(Msg, Printer.Printers, PrinterIndex) and (PrinterIndex >= 0);
      if Result then
        PrinterName := Printer.Printers.Strings[PrinterIndex];
    end;
     
    {* --- TSLTMessageDlg.InputString -----------------------------------------------------
    TSLTMessageDlg.InputString fournit un dialogue proche d'un InputQuery
    @param ACaption Titre à Afficher
    @param APrompt Chaine à Afficher
    @param AValue Valeur initiale et valeur saisie
    @param AButtonAcceptKeyboard Indique si les boutons sont réactifs sur Échap et Entrée
    @param AAllowCloseBySystemMenu Indique si l'on accepe la fermeture par la croix du menu système !
    @return Booléen InputString renvoie true si l'utilisateur choisit OK et false si l'utilisateur choisit Annuler ou appuie sur Echap.
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.InputString(const ACaption: string; const APrompt: string; var AValue: string; AButtonAcceptKeyboard: Boolean = True; AAllowCloseBySystemMenu: Boolean = False): Boolean;
    var
      Form: TSLTInputQueryForm;
      Prompt: TLabel;
      DialogUnits: TSize;
      MaxPromptWidth: Integer;
      ButtonTop, ButtonWidth, ButtonHeight: Integer;
     
      function GetPromptCaption(const ACaption: string): string;
      begin
        if (Length(ACaption) > 1) and (ACaption[1] < #32) then
          Result := Copy(ACaption, 2, MaxInt)
        else
          Result := ACaption;
      end;
     
      function GetMaxPromptWidth(Canvas: TCanvas): Integer;
      var
        LLabel: TLabel;
      begin
        LLabel := TLabel.Create(nil);
        try
          LLabel.Caption := GetPromptCaption(APrompt);
          Result := LLabel.Width + DialogUnits.Width;
        finally
          LLabel.Free;
        end;
      end;
     
      function GetPasswordChar(const ACaption: string): Char;
      begin
        if (Length(ACaption) > 1) and (ACaption[1] < #32) then
          Result := '*'
        else
          Result := #0;
      end;
     
      function GetAveCharSize(AFont: TFont): TSize;
      begin
        Result := TFontSLTToolHelp.GetTextSize(ACaption, AFont);
        Result.Width := Result.Width div Max(Length(ACaption), 1); // Average !
      end;
     
      function GetTextBaseline(AControl: TControl; ACanvas: TCanvas): Integer;
      var
        tm: TTextMetric;
        ClientRect: TRect;
        Ascent: Integer;
      begin
        ClientRect := AControl.ClientRect;
        GetTextMetrics(ACanvas.Handle, tm);
        Ascent := tm.tmAscent + 1;
        Result := ClientRect.Top + Ascent;
        Result := AControl.Parent.ScreenToClient(AControl.ClientToScreen(TPoint.Create(0, Result))).Y - AControl.Top;
      end;
     
    begin
      Result := False;
      Form := TSLTInputQueryForm.CreateNew(Application);
      with Form do
        try
          RegisterForm(Form);
     
          Canvas.Font := Font;
          DialogUnits := GetAveCharSize(Canvas.Font);
          MaxPromptWidth := GetMaxPromptWidth(Canvas);
          FAllowCloseBySystemMenu := AAllowCloseBySystemMenu;
          BorderStyle := bsDialog;
          // On ne peut utiliser que les boutons Valider/Annuler et surtout pas la croix du menu système
          if not AAllowCloseBySystemMenu then
            BorderIcons := [];
     
          Caption := ACaption;
          ClientWidth := MulDiv(180 + MaxPromptWidth, DialogUnits.Width, 4);
          PopupMode := pmAuto;
          Position := poScreenCenter;
     
          Prompt := TLabel.Create(Form);
          with Prompt do
          begin
            Parent := Form;
            Caption := GetPromptCaption(APrompt);
            Left := MulDiv(8, DialogUnits.Width, 4);
            Top := MulDiv(8, DialogUnits.Height, 8);
            Constraints.MaxWidth := MaxPromptWidth;
            WordWrap := True;
          end;
     
          FEdit := TEdit.Create(Form);
          with FEdit do
          begin
            Parent := Form;
            PasswordChar := GetPasswordChar(APrompt);
            Left := Prompt.Left + MaxPromptWidth;
            Top := Prompt.Top + Prompt.Height - DialogUnits.Height -
              (GetTextBaseline(FEdit, Canvas) - GetTextBaseline(Prompt, Canvas));
            Width := Form.ClientWidth - Left - MulDiv(8, DialogUnits.Width, 4);
            MaxLength := 255;
            Text := AValue;
            SelectAll;
            Prompt.FocusControl := FEdit;
          end;
     
          ButtonTop := FEdit.Top + FEdit.Height + 15;
          ButtonWidth := MulDiv(50, DialogUnits.Width, 4);
          ButtonHeight := MulDiv(14, DialogUnits.Height, 8);
     
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgOK;
            ModalResult := mrOk;
            Default := AButtonAcceptKeyboard;
            SetBounds(Form.ClientWidth - (ButtonWidth + MulDiv(8, DialogUnits.Width, 4)) * 2, ButtonTop, ButtonWidth, ButtonHeight);
          end;
     
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgCancel;
            ModalResult := mrAbort; // Différencie mrCancel correspondant au Echap ou à la fermeture de la fenêtre et le choix volontaire sur le bouton "Annuler" (Cancel)
            Cancel := AButtonAcceptKeyboard;
            SetBounds(Form.ClientWidth - (ButtonWidth + MulDiv(8, DialogUnits.Width, 4)), ButtonTop, ButtonWidth, ButtonHeight);
            Form.ClientHeight := Top + Height + 13;
          end;
     
          // Création d'un champ servant de capture au clavier (touche ENTER) lorsque l'on ne veut pas de bouton par défaut
          if not AButtonAcceptKeyboard then
          begin
            with TButton.Create(Form) do
            begin
              Parent := Form;
              SetBounds(-1, -1, 0, 0);
              Show();
              TabOrder := 0;
            end;
          end;
     
          if ShowModal() = mrOk then
          begin
            AValue := FEdit.Text;
            Result := True;
          end;
        finally
          Form.Free;
        end;
    end;
     
     
    {* --- TSLTMessageDlg.RegisterForm ------------------------------------------- }
    class procedure TSLTMessageDlg.RegisterForm(AForm: TForm);
    begin
      if not Assigned(AForm) then
        Exit;
     
      if not Assigned(FForms) then
        FForms := System.Generics.Collections.TList<TForm>.Create();
     
      FForms.Add(AForm);
      AForm.OnDestroy := RegisterFormDestroyEventHandler;
     
      if not Assigned(FApplicationEvents) then
      begin
        FApplicationEvents := TApplicationEvents.Create(nil);
        FApplicationEvents.OnRestore := ApplicationEventDefaultEventHandler;
        FApplicationEvents.OnActivate := ApplicationEventDefaultEventHandler;
      end;
    end;
     
    {* --- TSLTMessageDlg.RegisterFormDestroyEventHandler ------------------------ }
    class procedure TSLTMessageDlg.RegisterFormDestroyEventHandler(Sender: TObject);
    begin
      UnregisterForm(TForm(Sender));
    end;
     
    {* --- TSLTMessageDlg.Show -----------------------------------------------------
    TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpCustomBtn avec des libellés personnalisés pour chaque bouton
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param ButtonStrings Fourni les libellés personnalisés pour chaque bouton
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of string; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer;
    begin
      Result := MessageDlgPosHelpCustomBtn(Msg, DlgType, Buttons, ButtonStrings, HelpCtx, X, Y, HelpFileName);
    end;
     
    {* --- TSLTMessageDlg.Show -----------------------------------------------------
    TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpFont avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param DefaultButton Désigne le bouton qui sera actif par défaut
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, FontMsg, HelpCtx, X, Y, HelpFileName);
    end;
     
    {* --- TSLTMessageDlg.Show -----------------------------------------------------
    TSLTMessageDlg.Show fonctionne comme MessageDlgPosHelpFont avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param DefaultButton Désigne le bouton qui sera actif par défaut
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    class function TSLTMessageDlg.Show(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont = nil; HelpCtx: Longint = 0; X: Integer = -1; Y: Integer = -1; const HelpFileName: string = ''): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, DefaultButton, FontMsg, HelpCtx, X, Y, HelpFileName);
    end;
     
    {* --- TSLTMessageDlg.UnregisterForm ----------------------------------------- }
    class procedure TSLTMessageDlg.UnregisterForm(AForm: TForm);
    begin
      if Assigned(FForms) then
        FForms.Remove(AForm);
     
    end;
     
    { TSLTMessageDlg.TSLTInputQueryForm }
     
    {* --- TSLTMessageDlg.TSLTInputQueryForm.CloseQuery ---------------------------}
    function TSLTMessageDlg.TSLTInputQueryForm.CloseQuery(): Boolean;
    begin
      Result := (ModalResult = mrAbort) or (FAllowCloseBySystemMenu and (ModalResult = mrCancel)) or (FEdit.Text <> '');
    end;
     
    {* --- TSLTMessageDlg.TSLTInputQueryForm.WMClose ---------------------------}
    procedure TSLTMessageDlg.TSLTInputQueryForm.WMClose(var Message: TWMClose);
    begin
      if FAllowCloseBySystemMenu then
        Close();
    end;
     
    { Procedural code }
     
    {* --- MessageDlgCustomBtn -----------------------------------------------------
    MessageDlgCustomBtn fonctionne comme MessageDlg avec des libellés personnalisés pour chaque bouton
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param ButtonStrings Fourni les libellés personnalisés pour chaque bouton
    @param HelpCtx Contexte d'Aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgCustomBtn(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of String; HelpCtx: Longint = 0): Integer;
    begin
      Result := MessageDlgPosHelpCustomBtn(Msg, DlgType, Buttons, ButtonStrings, HelpCtx, -1, -1, '');
    end;
     
    {* --- MessageDlgPosHelpCustomBtn ----------------------------------------------
    MessageDlgPosHelpCustomBtn fonctionne comme MessageDlgPosHelp avec des libellés personnalisés pour chaque bouton
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param ButtonStrings Fourni les libellés personnalisés pour chaque bouton
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgPosHelpCustomBtn(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const ButtonStrings: array of String; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer;
    const
      ModalResults: array[TMsgDlgBtn] of Integer = (mrYes, mrNo, mrOk, mrCancel, mrAbort, mrRetry, mrIgnore, mrAll, mrNoToAll, mrYesToAll, mrHelp, mrClose);
    var
      MsgForm: TForm;
      IndexControls: Integer;
      IndexButtons: TMsgDlgBtn;
      IndexStrings: Integer;
      NewCaption: string;
      NewWidth, NewHeight, AllWidth, BaseWidth, BaseHeigth, BaseLeft, BaseTop: Integer;
      TextRect: TRect;
      ButtonLine: Integer;
      ButtonWordWrap: Boolean;
    begin
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, DlgType, Buttons);
      with MsgForm do
      try
        if Length(ButtonStrings) > 0 then
        begin
          IndexStrings := Low(ButtonStrings);
          for IndexButtons := Low(IndexButtons) to High(IndexButtons) do
          begin
            if (IndexButtons in Buttons) and (IndexStrings <= High(ButtonStrings)) then
            begin
              for IndexControls := 0 to ControlCount - 1 do
              begin
                if Controls[IndexControls] is TButton then
                begin
                  with TButton(Controls[IndexControls]) do
                  begin
                    if ModalResults[IndexButtons] = ModalResult then
                    begin
                      NewCaption := ButtonStrings[IndexStrings];
                      if NewCaption <> '' then
                        Caption := NewCaption;
                      Inc(IndexStrings);
     
                      if IndexStrings > High(ButtonStrings) then
                        Break;
                    end;
                  end;
                end;
              end;
            end;
          end;
        end;
     
        AllWidth := 0;
        BaseHeigth := 0;
        BaseTop := MaxInt;
        ButtonWordWrap := False;
        for IndexControls := 0 to ControlCount - 1 do
        begin
          if Controls[IndexControls] is TButton then
          begin
            with TButton(Controls[IndexControls]) do
            begin
              NewHeight := Height;
              if ContainsStr(Caption, sLineBreak) then
              begin
                WordWrap := True;
                ButtonWordWrap := True;
                Winapi.Windows.DrawText(Canvas.Handle, PChar(Caption), -1, TextRect, DT_CALCRECT or DT_LEFT or DrawTextBiDiModeFlagsReadingOnly);
                Inc(NewHeight, TextRect.Height);
              end
              else
              begin
                TextRect := Rect(0,0,0,0);
                Winapi.Windows.DrawText(Canvas.Handle, PChar(Caption), -1, TextRect, DT_CALCRECT or DT_LEFT or DT_SINGLELINE or DrawTextBiDiModeFlagsReadingOnly);
              end;
     
              NewWidth := TextRect.Width + 16;
     
              if NewWidth > Width then
                Width := NewWidth;
     
              if NewHeight > Height then
                Height := NewHeight;
     
              Inc(AllWidth, Width + 8);
     
              if Height > BaseHeigth then
                BaseHeigth := Height;
     
              if Top < BaseTop then
                BaseTop := Top;
            end;
          end;
        end;
     
     
        // 2/3 de l'écran au maximum
        if AllWidth > ClientWidth then
        begin
          if AllWidth + 16 > (Screen.WorkAreaWidth div 3 * 2) then
            ClientWidth := (Screen.WorkAreaWidth div 3 * 2)
          else
            ClientWidth := AllWidth + 16;
        end;
     
        if AllWidth + 16 > ClientWidth then
          BaseWidth := ClientWidth - 16
        else
          BaseWidth := AllWidth;
     
        BaseLeft := (MsgForm.ClientWidth - BaseWidth) div 2;
        ButtonLine := 0;
        for IndexControls := 0 to ControlCount - 1 do
        begin
          if Controls[IndexControls] is TButton then
          begin
            with TButton(Controls[IndexControls]) do
            begin
              if (BaseWidth <> AllWidth) and (BaseLeft + Width > MsgForm.ClientWidth) then
              begin
                BaseLeft := (MsgForm.ClientWidth - BaseWidth) div 2;
                Inc(BaseTop, BaseHeigth + 8);
                Inc(ButtonLine);
              end;
     
              Left := BaseLeft;
              Top := BaseTop;
              Height := BaseHeigth;
              Inc(BaseLeft, Width + 8);
            end;
          end;
        end;
     
        if ButtonLine > 0 then
          ClientHeight  := ClientHeight + ButtonLine * (BaseHeigth + 8)
        else if ButtonWordWrap then
          ClientHeight  := ClientHeight + BaseHeigth + 8;
     
        HelpContext := HelpCtx;
        HelpFile := HelpFileName;
        if X >= 0 then Left := X;
        if Y >= 0 then Top := Y;
        if (Y < 0) and (X < 0) then Position := poScreenCenter;
     
        if Max(Top, 0) + Height > Screen.WorkAreaHeight then
          Height := Screen.WorkAreaHeight - Max(Top, 0);
     
        Result := ShowModal;
      finally
        Free;
      end;
    end;
     
    { MessageDlgFont }
     
    {* --- MessageDlgFont ----------------------------------------------------------
    MessageDlgFont fonctionne comme MessageDlg avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint = 0): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, FontMsg, HelpCtx, -1, -1, '');
    end;
     
    {* --- MessageDlgFont ----------------------------------------------------------
    MessageDlgFont fonctionne comme MessageDlg avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param DefaultButton Désigne le bouton qui sera actif par défaut
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont;
      HelpCtx: Longint = 0): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, DefaultButton, FontMsg, HelpCtx, -1, -1, '');
    end;
     
    {* --- MessageDlgPosFont -------------------------------------------------------
    MessageDlgPosFont fonctionne comme MessageDlgPos avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgPosFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; FontMsg: TFont;
      HelpCtx: Longint; X, Y: Integer): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, FontMsg, HelpCtx, X, Y, '');
    end;
     
    {* --- MessageDlgPosFont -------------------------------------------------------
    MessageDlgPosFont fonctionne comme MessageDlgPos avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param DefaultButton Désigne le bouton qui sera actif par défaut
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgPosFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont;
      HelpCtx: Longint; X, Y: Integer): Integer;
    begin
      Result := MessageDlgPosHelpFont(Msg, DlgType, Buttons, DefaultButton, FontMsg, HelpCtx, X, Y, '');
    end;
     
    {* --- Internal MessageDlgFont forward ----------------------------------------}
    function _MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; const DefaultButtonArray: array of TMsgDlgBtn;
      FontMsg: TFont; HelpCtx: Longint; X, Y: Integer;
      const HelpFileName: string): Integer; forward;
     
    {* --- MessageDlgPosHelpFont ---------------------------------------------------
    MessageDlgPosHelpFont fonctionne comme MessageDlgPosHelp avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; FontMsg: TFont; HelpCtx: Longint; X, Y: Integer;
      const HelpFileName: string): Integer;
    begin
      Result := _MessageDlgPosHelpFont(Msg, DlgType, Buttons, [], FontMsg, HelpCtx, X, Y, HelpFileName);
    end;
     
    {* --- MessageDlgPosHelpFont ---------------------------------------------------
    MessageDlgPosHelpFont fonctionne comme MessageDlgPosHelp avec la Gestion de la Font pour la fenêtre et les Boutons
    @param Msg Chaine à Afficher
    @param DlgType Type du Dialogue
    @param Buttons Ensemble de boutons
    @param DefaultButton Désigne le bouton qui sera actif par défaut
    @param FontMsg Font spécifique pour Fenêtre et Boutons
    @param HelpCtx Contexte d'Aide
    @param X Position Horizontale du Message
    @param Y Position Verticale du Message
    @param HelpFileName Fichier d'aide
    @return Entier Résultat associé à chaque Bouton
    ------------------------------------------------------------------------------ }
    function MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; FontMsg: TFont;
      HelpCtx: Longint; X, Y: Integer;
      const HelpFileName: string): Integer;
    var
      DefaultButtonArray: array of TMsgDlgBtn;
    begin
      SetLength(DefaultButtonArray, 1);
      DefaultButtonArray[0] := DefaultButton;
      Result := _MessageDlgPosHelpFont(Msg, DlgType, Buttons, DefaultButtonArray, FontMsg, HelpCtx, X, Y, HelpFileName);
    end;
     
    {* --- Internal MessageDlgFont ------------------------------------------------}
    function _MessageDlgPosHelpFont(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons; const DefaultButtonArray: array of TMsgDlgBtn;
      FontMsg: TFont; HelpCtx: Longint; X, Y: Integer;
      const HelpFileName: string): Integer;
    const
      IMAGE_WIDTH = 20;
    var
      MsgForm: TForm;
      MsgLabel: TComponent;
      IndexControls: Integer;
      OldWidth, OldFontSize, OldLabelWidth, OldLabelHeight, Decalage, DecalageButton: Integer;
      OldButton: TButton;
      OverButton: TBitBtn;
      DefaultButton: TMsgDlgBtn;
      NoDefault: Boolean;
     
      procedure SetOverButtonKind(AKind: TBitBtnKind; BtnType: TMsgDlgBtn);
      begin
        OverButton.Kind := AKind;
        OverButton.ModalResult := OldButton.ModalResult;
     
        if OldButton.Default then
        begin
          OldButton.Default := False;
          OverButton.Default := (Length(DefaultButtonArray) = 0) or ((Length(DefaultButtonArray) = 1) and (DefaultButtonArray[0] = BtnType));
        end
        else
          OverButton.Default := (Length(DefaultButtonArray) = 1) and (DefaultButtonArray[0] = BtnType);
     
        if OverButton.Default then
          OverButton.TabOrder := 0; // Ne devrais pas être nécessaire en théorie, mais en pratique cela fonctionne bien mieux !
        if OldButton.Cancel then
        begin
          OldButton.Cancel := False;
          OverButton.Cancel := True;
        end;
     
        if Assigned(OldButton.OnClick) then
         OverButton.OnClick := OldButton.OnClick;
      end;
     
    begin
      if Length(DefaultButtonArray) = 0 then
      begin
        if mbOk in Buttons then DefaultButton := mbOk else
          if mbYes in Buttons then DefaultButton := mbYes else
            DefaultButton := mbRetry;
      end
      else
        DefaultButton := DefaultButtonArray[0];
     
      // Si le bouton par défaut n'est pas parmi les boutons affichés, c'est que l'on souhaite aucun bouton par défaut
      NoDefault := (Length(DefaultButtonArray) = 1) and not (DefaultButtonArray[0] in Buttons);
     
      MsgForm := TSLTMessageDlg.CreateMessageDialog(Msg, DlgType, Buttons, DefaultButton);
      with MsgForm do
      try
        MsgLabel := FindComponent('Message');
        if MsgLabel is TLabel then
        begin
          OldLabelWidth := TLabel(MsgLabel).Width;
          OldLabelHeight := TLabel(MsgLabel).Height;
          OldFontSize := System.Math.Max(TLabel(MsgLabel).Font.Size, 1);
          if Assigned(FontMsg) then
            TLabel(MsgLabel).Font.Assign(FontMsg);
     
          TLabel(MsgLabel).Width := System.Math.Min(System.Math.Max(OldLabelWidth, Round(OldLabelWidth * TLabel(MsgLabel).Font.Size / OldFontSize)), Screen.Width div 2);
     
          OldWidth := Width;
          Width := System.Math.Max(Width, Width - OldLabelWidth + TLabel(MsgLabel).Width);
     
          DecalageButton := 0;
          for IndexControls := 0 to ControlCount - 1 do
            if Controls[IndexControls] is TButton then
              Inc(DecalageButton, IMAGE_WIDTH);
     
          Decalage := (Width - OldWidth) div 2 + DecalageButton;
          Width := Width + DecalageButton;
     
          for IndexControls := 0 to ControlCount - 1 do
          begin
            if Controls[IndexControls] is TButton then
            begin
              OldButton := TButton(Controls[IndexControls]); // utilisé dans SetOverButtonKind
     
              OverButton := TBitBtn.Create(MsgForm);
              OverButton.Left := OldButton.Left + Decalage - DecalageButton;
              OverButton.Top := OldButton.Top;
              OverButton.Height := OldButton.Height + 2;
              OverButton.Width := OldButton.Width + IMAGE_WIDTH;
              OverButton.Parent := OldButton.Parent;
              OverButton.Anchors := OldButton.Anchors - [akTop] + [akBottom];
              Dec(DecalageButton, IMAGE_WIDTH);
     
              case OldButton.ModalResult of
                mrNone: SetOverButtonKind(bkHelp, mbHelp);
                mrOk: SetOverButtonKind(bkOK, mbOK);
                mrCancel: SetOverButtonKind(bkCancel, mbCancel);
                mrAbort: SetOverButtonKind(bkAbort, mbAbort);
                mrRetry: SetOverButtonKind(bkRetry, mbRetry);
                mrIgnore: SetOverButtonKind(bkIgnore, mbIgnore);
                mrYes: SetOverButtonKind(bkYes, mbYes);
                mrNo: SetOverButtonKind(bkNo, mbNo);
                mrAll: SetOverButtonKind(bkAll, mbAll);
                mrNoToAll: SetOverButtonKind(bkNo, mbYesToAll);
                mrYesToAll: SetOverButtonKind(bkYes, mbNoToAll);
              end;
     
              OldButton.Enabled := False;
              OldButton.Visible := False;
            end;
          end;
     
          // Création d'un champ servant de capture au clavier (touche ENTER)
          // lorsque l'on ne veut pas de bouton par défaut
          if NoDefault then
          begin
            with TButton.Create(MsgForm) do
            begin
              Parent := MsgForm;
              SetBounds(-1, -1, 0, 0);
              Show();
              TabOrder := 0;
            end;
          end;
     
          Height := System.Math.Max(Height, Height - OldLabelHeight + TLabel(MsgLabel).Height);
     
          Left := (Screen.Width div 2) - (Width div 2);
          Top := (Screen.Height div 2) - (Height div 2);
        end;
     
        HelpContext := HelpCtx;
        HelpFile := HelpFileName;
        if X >= 0 then Left := X;
        if Y >= 0 then Top := Y;
        if (Y < 0) and (X < 0) then Position := poScreenCenter;
     
        if Max(Top, 0) + Height > Screen.WorkAreaHeight then
          Height := Screen.WorkAreaHeight - Max(Top, 0);
     
        Result := ShowModal();
      finally
         Free;
      end;
    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

  8. #8
    Membre du Club
    Homme Profil pro
    Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Inscrit en
    Juin 2011
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 227
    Points : 51
    Points
    51
    Par défaut
    Merci à tous on cherchant dans les unités de Delphi j'ai trouver l'unité Dialogs.pas qui a tous les fonctions et procédures et j'ai trouver les fonctions suivante:

    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
    function InputQuery(const ACaption, APrompt: string;
      var Value: string): Boolean;
    var
      Form: TForm;
      Prompt: TLabel;
      Edit: TEdit;
      DialogUnits: TPoint;
      ButtonTop, ButtonWidth, ButtonHeight: Integer;
    begin
      Result := False;
      Form := TForm.Create(Application);
      with Form do
        try
          Canvas.Font := Font;
          DialogUnits := GetAveCharSize(Canvas);
          BorderStyle := bsDialog;
          Caption := ACaption;
          ClientWidth := MulDiv(180, DialogUnits.X, 4);
          Position := poScreenCenter;
          Prompt := TLabel.Create(Form);
          with Prompt do
          begin
            Parent := Form;
            Caption := APrompt;
            Left := MulDiv(8, DialogUnits.X, 4);
            Top := MulDiv(8, DialogUnits.Y, 8);
            Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
            WordWrap := True;
          end;
          Edit := TEdit.Create(Form);
          with Edit do
          begin
            Parent := Form;
            Left := Prompt.Left;
            Top := Prompt.Top + Prompt.Height + 5;
            Width := MulDiv(164, DialogUnits.X, 4);
            MaxLength := 255;
            Text := Value;
            SelectAll;
          end;
          ButtonTop := Edit.Top + Edit.Height + 15;
          ButtonWidth := MulDiv(50, DialogUnits.X, 4);
          ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgOK;
            ModalResult := mrOk;
            Default := True;
            SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
              ButtonHeight);
          end;
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgCancel;
            ModalResult := mrCancel;
            Cancel := True;
            SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
              ButtonWidth, ButtonHeight);
            Form.ClientHeight := Top + Height + 13;          
          end;
          if ShowModal = mrOk then
          begin
            Value := Edit.Text;
            Result := True;
          end;
        finally
          Form.Free;
        end;
    end;
     
    function InputBox(const ACaption, APrompt, ADefault: string): string;
    begin
      Result := ADefault;
      InputQuery(ACaption, APrompt, Result);
    end;
    donc est ce que je rajoute du code dans la fonction InputQurey par exemple ici

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    with Edit do
          begin
            Parent := Form;
            Left := Prompt.Left;
            Top := Prompt.Top + Prompt.Height + 5;
            Width := MulDiv(164, DialogUnits.X, 4);
            MaxLength := 255;
            Text := Value;
            SelectAll;
          end;
    est ce que je rajoute


  9. #9
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 042
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 042
    Points : 40 952
    Points
    40 952
    Billets dans le blog
    62
    Par défaut
    Bonjour,

    vous ne m'avez pas compris ! vous ne modifiez pas Dialogs.pas, vous vous inspirez du code source et dans votre programme (ou dans une unité bien à vous que vous pourrez ensuite utiliser pour d'autres programmes)

    dans cette unité ou dans le programme vous créez la fonction par exemple MonInputQuery

    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
    function MonInputQuery(const ACaption, APrompt: string;
      var Value: string): Boolean;
    var
      Form: TForm;
      Prompt: TLabel;
      Edit: TEdit;
      DialogUnits: TPoint;
      ButtonTop, ButtonWidth, ButtonHeight: Integer;
    begin
      Result := False;
      Form := TForm.Create(Application);
      with Form do
        try
          Canvas.Font := Font;
          DialogUnits := GetAveCharSize(Canvas);
          BorderStyle := bsDialog;
          Caption := ACaption;
          ClientWidth := MulDiv(180, DialogUnits.X, 4);
          Position := poScreenCenter;
          Prompt := TLabel.Create(Form);
          with Prompt do
          begin
            Parent := Form;
            Caption := APrompt;
            Left := MulDiv(8, DialogUnits.X, 4);
            Top := MulDiv(8, DialogUnits.Y, 8);
            Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
            WordWrap := True;
          end;
          Edit := TEdit.Create(Form);
          with Edit do
          begin
            Parent := Form;
            Left := Prompt.Left;
            Top := Prompt.Top + Prompt.Height + 5;
            Width := MulDiv(164, DialogUnits.X, 4);
            MaxLength := 255;
            Text := Value;
            SelectAll;
          end;
          ButtonTop := Edit.Top + Edit.Height + 15;
          ButtonWidth := MulDiv(50, DialogUnits.X, 4);
          ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgOK;
            ModalResult := mrOk;
            Default := True;
            SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
              ButtonHeight);
          end;
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgCancel;
            ModalResult := mrCancel;
            Cancel := True;
            SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
              ButtonWidth, ButtonHeight);
            Form.ClientHeight := Top + Height + 13;          
          end;
          if ShowModal = mrOk then
          begin
            Value := Edit.Text;
            Result := True;
          end;
        finally
          Form.Free;
        end;
    end;
     
    function MonInputBox(const ACaption, APrompt, ADefault: string): string;
    begin
      Result := ADefault;
      InputQuery(ACaption, APrompt, Result);
    end;
    et oui vous changez les propriétés des composants comme vous le souhaitez.
    Attention ! les calculs de tailles seront peut-être aussi à modifier
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  10. #10
    Membre du Club
    Homme Profil pro
    Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Inscrit en
    Juin 2011
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 227
    Points : 51
    Points
    51
    Par défaut
    Pour ne pas alourdir trop mon code j'ai temporairement modifier Dialogs.pas et j'ai effacer le Dialogs.dcu pour que ça reconstruit l'unité Dialogs.pas et ça marche super bien et pour le modification que j'ai fais dans InputQuery les voila:

    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
    function InputQuery(const ACaption, APrompt: string;
      var Value: string): Boolean;
    var
      Form: TForm;
      Prompt: TLabel;
      Edit: TEdit;
      DialogUnits: TPoint;
      ButtonTop, ButtonWidth, ButtonHeight: Integer;
    begin
      Result := False;
      Form := TForm.Create(Application);
      with Form do
        try
          Canvas.Font := Font;
    	  Font.Name:='Arial'; //ligne que j'ai ajouté
    	  Font.size:=12; //ligne que j'ai ajouté
    	  Font.Style:=[fsBold]; //ligne que j'ai ajouté
          DialogUnits := GetAveCharSize(Canvas);
          BorderStyle := bsDialog;
          Caption := ACaption;
          ClientWidth := MulDiv(180, DialogUnits.X, 4);
          Position := poScreenCenter;
          Prompt := TLabel.Create(Form);
          with Prompt do
          begin
            Parent := Form;
            Caption := APrompt;
            Left := MulDiv(8, DialogUnits.X, 4);
            Top := MulDiv(8, DialogUnits.Y, 8);
            Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
            WordWrap := True;
            Font.Name:='Arial'; //ligne que j'ai ajouté
    	Font.size:=12; //ligne que j'ai ajouté
            Font.Style:=[fsBold]; //ligne que j'ai ajouté
          end;
          Edit := TEdit.Create(Form);
          with Edit do
          begin
            Parent := Form;
            Left := Prompt.Left;
            Top := Prompt.Top + Prompt.Height + 5;
            Width := MulDiv(164, DialogUnits.X, 4);
            MaxLength := 255;
            Text := Value;
    	Font.Name:='Arial'; //ligne que j'ai ajouté
    	Font.size:=12; //ligne que j'ai ajouté
    	Font.Style:=[fsBold]; //ligne que j'ai ajouté
            SelectAll;
          end;
          ButtonTop := Edit.Top + Edit.Height + 15;
          ButtonWidth := MulDiv(50, DialogUnits.X, 4);
          ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
          with TButton.Create(Form) do
          begin
            Parent := Form;
            Caption := SMsgDlgOK;
            ModalResult := mrOk;
            Default := True;
            SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
              ButtonHeight);
          end;
          with TButton.Create(Form) do
          begin
            Parent := Form;
    		Font.Name:='Arial';
    		Font.size:=12;
    		Font.Style:=[fsBold];
            Caption := SMsgDlgCancel;
            ModalResult := mrCancel;
            Cancel := True;
            SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
              ButtonWidth, ButtonHeight);
            Form.ClientHeight := Top + Height + 13;          
          end;
          if ShowModal = mrOk then
          begin
            Value := Edit.Text;
            Result := True;
          end;
        finally
          Form.Free;
        end;
    end;
    pour les lignes que j'ai ajouté les voilà:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Font.Name:='Arial';
    Font.size:=12;
    Font.Style:=[fsBold];

  11. #11
    Membre du Club
    Homme Profil pro
    Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Inscrit en
    Juin 2011
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Tutulaire d'un Master Academique en Réseaux et Systèmes repartis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 227
    Points : 51
    Points
    51
    Par défaut
    Citation Envoyé par SergioMaster Voir le message
    Bonjour,
    vous ne modifiez pas Dialogs.pas, vous vous inspirez du code source et dans votre programme (ou dans une unité bien à vous que vous pourrez ensuite utiliser pour d'autres programmes)

    Merci @SergioMaster, j'ai compris ce que voulez vous dire mais cette modification je vais l'utiliser juste pour programme actuel, y'aura pas pour d'autres.

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

Discussions similaires

  1. [CSS] centrer le contenu de <table>
    Par H-bil dans le forum Mise en page CSS
    Réponses: 14
    Dernier message: 10/06/2006, 16h44
  2. [VB6]Comment centrer le contenu d'une cellule
    Par zackrel dans le forum VB 6 et antérieur
    Réponses: 15
    Dernier message: 19/05/2006, 20h02
  3. [HTML] Centrer le contenu d'une zone de texte
    Par beegees dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 16/03/2006, 00h34
  4. [HTML] Centrer le contenu d'une zone de texte
    Par beegees dans le forum Balisage (X)HTML et validation W3C
    Réponses: 13
    Dernier message: 15/03/2006, 17h10
  5. [CSS] Centrer le contenu d'une Div
    Par bolo dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 09/03/2006, 19h18

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