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

Langage Delphi Discussion :

Redémarrer une application


Sujet :

Langage Delphi

  1. #21
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 345
    Points : 3 123
    Points
    3 123
    Par défaut
    Bonjour,

    j'ai testé ton code en élaguant beaucoup de choses impossibles à reproduire facilement. J'arrive bien à libérer le fichier ini dans le Create de la form et dans son Destroy.

    Si tu as des erreurs de violation quand tu ajoutes des Ficini.free c'est surement que tu essayes d'écrire ou de lire alors que Ficini est détruit.
    Tu dois pouvoir tester cela avec des points d'arrêt + F8 pour localiser l'instruction qui fait planter ?

    A+
    Charly

  2. #22
    Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2006
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Tarn et Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : Services à domicile

    Informations forums :
    Inscription : Octobre 2006
    Messages : 74
    Points : 50
    Points
    50
    Par défaut
    Bonjour Charly

    J'ai tenté de faire comme tu dis avec les points d’arrêts mais je maitrise pas du tout cette manip

    J'avoue que plus j'essaye de modifier ce code, et plus il me fait tourner en bourrique sans y voir la solution...

    Voici le code complet de la fiche

    Si tu peux y déceler la faille, je t'en serai gré

    A+
    Beauserge

    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
    {Fiche principale de l'application - Accueil}
    unit MenuPrincipal;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Menus, ExtCtrls, ComCtrls, Buttons, IniFiles, ShellAPI,
      Registry, ActiveX, ComObj, ShlObj ;
     {ShellApi déclare le retrait de l'icone dans barre des taches = On Close}
     {Registry, ActiveX, ComObj et ShlObj servent à la création des prodécures
     raccourcis et options diverses}
     
    Const WM_MYMESSAGE = WM_USER+100; // numéro de message utilisé plus bas.
     
    type
        TAccueil = class(TForm)
        MainMenu1: TMainMenu; // paramétres pour Menu Main
        Fichier1: TMenuItem;
        Apropos1: TMenuItem;
        Bureautique1: TMenuItem;
        Basededonnes1: TMenuItem;
        Internet1: TMenuItem;
        Gestionperso1: TMenuItem;
        Jeux1: TMenuItem;
        Divers1: TMenuItem;
        Mp31: TMenuItem;
        Disquedur1: TMenuItem;
        Graphisme1: TMenuItem;
        Utilitaires1: TMenuItem;
        ProgrammationHTML1: TMenuItem;
        ProgrammationAppli1: TMenuItem;
        Restaurer1: TMenuItem;
        ProgressBar1 : TprogressBar;
        Quitter1: TMenuItem;
    	  Imprimer1: TMenuItem;
        N2: TMenuItem;
        Logiciels1: TMenuItem;
        Renommerbureautique: TMenuItem;
        Renommerbasedonnees: TMenuItem;
        Renommerdisquedur: TMenuItem;
        Renommerdivers: TMenuItem;
        Renommergestionperso: TMenuItem;
        Renommerinternet: TMenuItem;
        Renommerjeux: TMenuItem;
        Renommermp3: TMenuItem;
        RenommerProgAppli: TMenuItem;
        RenommerProghtml: TMenuItem;
        Renommerutilitaires: TMenuItem;
        PrintDialog1: TPrintDialog;
        PopupMenu1: TPopupMenu;
        Fermerdfinitivement1: TMenuItem;
        Montrerappli: TMenuItem;
        Cacherappli: TMenuItem;
        Panelplan: TPanel;
    	  GroupBox1: TGroupBox;
        Label1: TLabel;
        GroupBox2: TGroupBox;
        Button3: TButton;
        Button4: TButton;
        Open: TOpenDialog;
        SaveDialog1: TSaveDialog;
        Im2: TImage;
        Label3: TLabel;
    	  SpeedButton1: TSpeedButton;
        Image: TImage;
        Imaj: TImage;
        N4: TMenuItem;
        Aide1: TMenuItem;
        Guide1: TMenuItem;
        Labeldrag: TLabel;
        Renommergraphisme: TMenuItem;
        EditChemin: TEdit;
        Parcourir1: TBitBtn;
        Btlog1: TButton;
        Btlog2: TButton;
        Btlog3: TButton;
        Btlog4: TButton;
        Btlog5: TButton;
        Btlog6: TButton;
        Btlog7: TButton;
        Btlog8: TButton;
        Btlog9: TButton;
        Btlog10: TButton;
        Btlog11: TButton;
        Btlog12: TButton;
        SpeedBtnEffaceProg: TSpeedButton;
        procedure Fermer1Click(Sender: TObject);
        procedure Bureautique1Click(Sender: TObject);
        procedure Apropos1Click(Sender: TObject);
        procedure Quitter1Click(Sender: TObject);
        procedure FormActivate(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure Imprimer1Click(Sender: TObject);
        procedure Fermerdfinitivement1Click(Sender: TObject);
        procedure MontrerappliClick(Sender: TObject);
        procedure CacherappliClick(Sender: TObject);
    	  procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Parcourir1Click(Sender: TObject);
        procedure Restaurer1Click(Sender: TObject);
        procedure RenommerbureautiqueClick(Sender: TObject);
        procedure FormKeyDown(Sender: TObject; var Key: Word;
          Shift: TShiftState);
        procedure SpeedButton1Click(Sender: TObject);
        procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Guide1Click(Sender: TObject);
        procedure Graphisme1Click(Sender: TObject);
        procedure RenommergraphismeClick(Sender: TObject);
        procedure Basededonnes1Click(Sender: TObject);
        procedure RenommerbasedonneesClick(Sender: TObject);
        procedure Disquedur1Click(Sender: TObject);
    	  procedure RenommerdisquedurClick(Sender: TObject);
        procedure Divers1Click(Sender: TObject);
        procedure RenommerdiversClick(Sender: TObject);
        procedure Gestionperso1Click(Sender: TObject);
        procedure RenommergestionpersoClick(Sender: TObject);
        procedure Internet1Click(Sender: TObject);
        procedure RenommerinternetClick(Sender: TObject);
        procedure Jeux1Click(Sender: TObject);
        procedure RenommerjeuxClick(Sender: TObject);
        procedure Mp31Click(Sender: TObject);
        procedure Renommermp3Click(Sender: TObject);
        procedure ProgrammationAppli1Click(Sender: TObject);
        procedure RenommerProgAppliClick(Sender: TObject);
        procedure ProgrammationHTML1Click(Sender: TObject);
        procedure RenommerProghtmlClick(Sender: TObject);
        procedure Utilitaires1Click(Sender: TObject);
        procedure RenommerutilitairesClick(Sender: TObject);
     
        procedure AjouterProg;
        procedure Btlog1Click(Sender: TObject);
        procedure Btlog2Click(Sender: TObject);
        procedure Btlog3Click(Sender: TObject);
        procedure Btlog4Click(Sender: TObject);
        procedure Btlog5Click(Sender: TObject);
        procedure Btlog6Click(Sender: TObject);
        procedure Btlog7Click(Sender: TObject);
        procedure Btlog8Click(Sender: TObject);
        procedure Btlog9Click(Sender: TObject);
        procedure Btlog10Click(Sender: TObject);
        procedure Btlog11Click(Sender: TObject);
        procedure Btlog12Click(Sender: TObject);
        procedure SpeedBtnEffaceProgClick(Sender: TObject);
     
     
     
      private
        { Déclarations privées }
        procedure TrayMessage(var Msg: TMessage); message WM_MYMESSAGE;
     
      public
    	 { Déclarations publiques }
       procedure AfficheNomsBoutons; // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       procedure LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       procedure Sauvernomfiches; // procedure perso - pour enregistrer nom des fiches dans fichier .ini - utile lorsqu'une une fiche est renommée
       procedure LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
     
      end;
     
    var
      Accueil: TAccueil;
      items : TMenuItem;
      NotifyStruc : TNotifyIconData; // Structure de l'icone
      FicIni : TIniFile ;  // pour déclarer fichier .ini (drag drop raccourcis)
      bReload: Boolean = False; // variable pour redemarrage ListLog
     
     implementation
    uses bureautiquelog, Boitepropos, Hint, Guide, graphismelog, basededonneeslog, disquedurlog,
         diverslog, gestionpersolog, internetlog,jeuxlog, mp3log, programmationapplicationslog,
    	  programmationhtmllog, utilitaireslog ;
    {$R *.DFM}
     
    var
    combien:Integer; // Combien de programmes actuellement
     
    procedure TAccueil.TrayMessage(var Msg: TMessage);// message WM_MYMESSAGE;
    //Le fait d'avoir déclaré dans Accueil procedure TrayMessage(var Msg: TMessage); message WM_MYMESSAGE;
    //et d'avoir fait NotifyStruc.uCallbackMessage := WM_MYMESSAGE indique au programme que tout message destiné à la petite icone (try icons)
    //doit déclencher la procédure TrayMessage
    var coordonnes_souris :TPoint;
    begin
      //('Bouton droit pressé on affiche le menu pop');
      if (Msg.LParam=WM_RBUTTONDOWN) then
      begin
        GetCursorPos(coordonnes_souris);//récupération de la position de la souris
        SetForegroundWindow(Handle); // mise en avant plan de l'application
    	 PopupMenu1.Popup(coordonnes_souris.x,coordonnes_souris.y); //affichage du menu
      end;
      if (Msg.LParam=WM_LBUTTONDOWN) then { Bouton gauche préssé }
       ShowWindow(Application.Handle, SW_SHOW); // affiche la grande icone dans 
      end;                                      // la barre des taches
     
    procedure TAccueil.Fermer1Click(Sender: TObject);
    begin
         close;   // ferme l'application
    end;
     
    procedure TAccueil.Guide1Click(Sender: TObject);
    begin
    	  Aide.ShowModal;
    end;
     
    procedure TAccueil.Apropos1Click(Sender: TObject);
    begin
          APropos.ShowModal; // pour ouvrir fenetre A-Propos
    end;     // showmodal oblige l'utilisateur à fermer la fenetre pour continuer
     
    procedure TAccueil.Quitter1Click(Sender: TObject);
    begin
    if MessageDlg('Voulez-vous vraiment quitter l''application ?', mtConfirmation,
    	[mbYes, mbNo],0)= mrYes then
    	Close;  // demande confirmation avant de quitter l'application
    end;
     
    procedure TAccueil.FormActivate(Sender: TObject);
    begin
    	   WindowState:=wsNormal; // permet d'avoir la fiche telle qu'à la conception
    end;
     
     
    // procedure perso - pour enregistrer nom des fiches dans fichier .ini - utile lorsqu'une une fiche est renommée
    procedure TAccueil.Sauvernomfiches;
    begin
        FicIni.WriteString('Element','Bureautique', Logiciels1.Items[0].caption);
    	  FicIni.WriteString('Element','Base de données', Logiciels1.Items[2].caption);
    	  FicIni.WriteString('Element','Disque dur', Logiciels1.Items[4].caption);
    	  FicIni.WriteString('Element','Divers', Logiciels1.Items[6].caption);
    	  FicIni.WriteString('Element','Gestion perso', Logiciels1.Items[8].caption);
    	  FicIni.WriteString('Element','Graphisme', Logiciels1.Items[10].caption);
    	  FicIni.WriteString('Element','Internet', Logiciels1.Items[13].caption);
    	  FicIni.WriteString('Element','Jeux', Logiciels1.Items[15].caption);
    	  FicIni.WriteString('Element','Mp3', Logiciels1.Items[17].caption);
    	  FicIni.WriteString('Element','Programmation Applications', Logiciels1.Items[19].caption);
    	  FicIni.WriteString('Element','Programmation HTML', Logiciels1.Items[21].caption);
        FicIni.WriteString('Element','Utilitaires', Logiciels1.Items[23].caption);
    end;
     
    // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
    procedure TAccueil.AfficheNomsBoutons;
    begin
      Btlog1.caption :=Logiciels1.Items[0].caption + ' (F1)';
      Btlog2.caption :=Logiciels1.Items[2].caption + ' (F2)';
      Btlog3.caption :=Logiciels1.Items[4].caption + ' (F3)' ;
      Btlog4.caption :=Logiciels1.Items[6].caption + ' (F4)';
      Btlog5.caption :=Logiciels1.Items[8].caption + ' (F5)';
      Btlog6.caption :=Logiciels1.Items[10].caption + ' (F6)';
      Btlog7.caption :=Logiciels1.Items[13].caption + ' (F7)';
      Btlog8.caption :=Logiciels1.Items[15].caption + ' (F8)';
      Btlog9.caption :=Logiciels1.Items[17].caption + ' (F9)';
      Btlog10.caption :=Logiciels1.Items[19].caption + ' (F10)';
      Btlog11.caption :=Logiciels1.Items[21].caption + ' (F11)';
      Btlog12.caption :=Logiciels1.Items[23].caption + ' (F12)';
    end;
     
    // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
    procedure TAccueil.LibelleRenomItems;
    begin
      Logiciels1.items[1].Caption :='Renommer fiche ' + Logiciels1.Items[0].caption;
      Logiciels1.items[3].Caption :='Renommer fiche ' + Logiciels1.Items[2].caption;
      Logiciels1.items[5].Caption :='Renommer fiche ' + Logiciels1.Items[4].caption;
      Logiciels1.items[7].Caption :='Renommer fiche ' + Logiciels1.Items[6].caption;
      Logiciels1.items[9].Caption :='Renommer fiche ' + Logiciels1.Items[8].caption;
      Logiciels1.items[11].Caption :='Renommer fiche ' + Logiciels1.Items[10].caption;
      Logiciels1.items[14].Caption :='Renommer fiche ' + Logiciels1.Items[13].caption;
      Logiciels1.items[16].Caption :='Renommer fiche ' + Logiciels1.Items[15].caption;
      Logiciels1.items[18].Caption :='Renommer fiche ' + Logiciels1.Items[17].caption;
      Logiciels1.items[20].Caption :='Renommer fiche ' + Logiciels1.Items[19].caption;
      Logiciels1.items[22].Caption :='Renommer fiche ' + Logiciels1.Items[21].caption;
      Logiciels1.items[24].Caption :='Renommer fiche ' + Logiciels1.Items[23].caption;
    end;
     
     
     // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
    procedure TAccueil.LimiterItems;
    var
     S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12:string; //  variable pour limiter caractéres dans items.Caption
      type
      TShortCaption = string[19];  // variable (limite) en nombre de caractéres dans items.Caption
      begin
       S1:= Logiciels1.Items[0].caption;
           Logiciels1.Items[0].caption := TShortCaption(S1);
              S2:= Logiciels1.Items[2].caption;
               Logiciels1.Items[2].caption := TShortCaption(S2);
                 S3:= Logiciels1.Items[4].caption;
                   Logiciels1.Items[4].caption := TShortCaption(S3);
                     S4:= Logiciels1.Items[6].caption;
                      Logiciels1.Items[6].caption := TShortCaption(S4);
                        S5:= Logiciels1.Items[8].caption;
                          Logiciels1.Items[8].caption := TShortCaption(S5);
                            S6:= Logiciels1.Items[10].caption;
                             Logiciels1.Items[10].caption := TShortCaption(S6);
                               S7:= Logiciels1.Items[13].caption;
                                 Logiciels1.Items[13].caption := TShortCaption(S7);
                                   S8:= Logiciels1.Items[15].caption;
                                    Logiciels1.Items[15].caption := TShortCaption(S8);
                                      S9:= Logiciels1.Items[17].caption;
                                       Logiciels1.Items[17].caption := TShortCaption(S9);
                                         S10:= Logiciels1.Items[19].caption;
                                           Logiciels1.Items[19].caption := TShortCaption(S10);
                                             S11:= Logiciels1.Items[21].caption;
                                                Logiciels1.Items[21].caption := TShortCaption(S11);
                                                  S12:= Logiciels1.Items[23].caption;
                                                    Logiciels1.Items[23].caption := TShortCaption(S12);
                                                     end;
     
     {PERMET DE LIRE LES PARAMETRES SAUVEGARDES DES OPTIONS RENOMMER LA FICHE
    DANS LE FICHIER .ini}
    procedure TAccueil.FormCreate(Sender: TObject);
    var
      hinte:string; // pour structure icone
      j:integer;    // pour structure icone
      x:integer; // pour drag drop raccourci
     begin
      FicIni := TIniFile.Create(ExtractFilePath(Application.ExeName)+ 'ListLog.ini');
     	// ExtractFilePath pour que le .ini se trouve dans le même directory que l'exécutable
      Logiciels1.Items[0].caption := FicIni.ReadString('Element','Bureautique', caption);
      Logiciels1.Items[2].caption := FicIni.ReadString('Element','Base de données', caption);
      Logiciels1.Items[4].caption := FicIni.ReadString('Element','Disque dur', caption);
      Logiciels1.Items[6].caption := FicIni.ReadString('Element','Divers', caption);
      Logiciels1.Items[8].caption := FicIni.ReadString('Element','Gestion perso', caption);
      Logiciels1.Items[10].caption := FicIni.ReadString('Element','Graphisme', caption);
      Logiciels1.Items[13].caption := FicIni.ReadString('Element','Internet', caption);
      Logiciels1.Items[15].caption := FicIni.ReadString('Element','Jeux', caption);
      Logiciels1.Items[17].caption := FicIni.ReadString('Element','Mp3', caption);
      Logiciels1.Items[19].caption := FicIni.ReadString('Element','Programmation Applications', caption);
      Logiciels1.Items[21].caption := FicIni.ReadString('Element','Programmation HTML', caption);
      Logiciels1.Items[23].caption := FicIni.ReadString('Element','Utilitaires', caption);
     
       AfficheNomsBoutons;// procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
     
      Screen.Cursor:=crHourGlass;  // pour drag drop
      Combien:=-1;                // pour drap drop
    	for x:=0 to 16 do  // Installer les programmes drap drop   - maximum 15 icones
    begin
      if FicIni.ReadString('Programmes',IntToStr(x),'')<>''
      then AjouterProg;
      notifyStruc.cbSize:=SizeOf(notifyStruc);  // code relatif à structure icone
      notifyStruc.Wnd:=Handle;
      notifyStruc.uID:=1;
      NotifyStruc.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      { On verra WM_MYMESSAGE plus tard }
      NotifyStruc.uCallbackMessage := WM_MYMESSAGE;
      { Definit que l'icone de l'application sera l'icone par défaut }
      NotifyStruc.hIcon :=  Application.Icon.Handle;
      { Définir l'Hint de l'icône, c-a-d le texte qui sera affiché quand la souris reste longtemps dessus }
      hinte:='Cliquez moi pour ouvrir menu ListLog !';
      for j:=0 to length(hinte)-1 do NotifyStruc.szTip[j] := hinte[j+1];
    	NotifyStruc.szTip[length(hinte)]:=#0;
    	 Shell_NotifyIcon(NIM_ADD,@NotifyStruc);//ajoute la petite icône dans la barre des taches
    	   end;
          Screen.Cursor:=crDefault;// fin installation programmes
         end;
     
     
    {PERMET D'ENREGISTRER LES PARAMETRES DES OPTIONS RENOMMER LA FICHE
    DANS LE FICHIER .ini}
    procedure TAccueil.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    	  FicIni.WriteString('Element','Bureautique', Logiciels1.Items[0].caption);
    	  FicIni.WriteString('Element','Base de données', Logiciels1.Items[2].caption);
    	  FicIni.WriteString('Element','Disque dur', Logiciels1.Items[4].caption);
    	  FicIni.WriteString('Element','Divers', Logiciels1.Items[6].caption);
    	  FicIni.WriteString('Element','Gestion perso', Logiciels1.Items[8].caption);
    	  FicIni.WriteString('Element','Graphisme', Logiciels1.Items[10].caption);
    	  FicIni.WriteString('Element','Internet', Logiciels1.Items[13].caption);
    	  FicIni.WriteString('Element','Jeux', Logiciels1.Items[15].caption);
    	  FicIni.WriteString('Element','Mp3', Logiciels1.Items[17].caption);
    	  FicIni.WriteString('Element','Programmation Applications', Logiciels1.Items[19].caption);
    	  FicIni.WriteString('Element','Programmation HTML', Logiciels1.Items[21].caption);
        FicIni.WriteString('Element','Utilitaires', Logiciels1.Items[23].caption);
      if (@NotifyStruc<>NIL) then   //retire la petite icône de la barre des taches
    	   Shell_NotifyIcon(NIM_DELETE,@NotifyStruc);
    end;
     
    procedure TAccueil.Imprimer1Click(Sender: TObject);
    var i: integer;
    begin
    if PrintDialog1.Execute then begin
    	  print;
    if (PrintDialog1.Copies > 1) then
       for i:= 1 to PrintDialog1.Copies - 1 do
         Print;
    end;
    end;
     
    procedure TAccueil.Fermerdfinitivement1Click(Sender: TObject);
    begin
         Close; // Fermer la fiche depuis Menu Pop
    end;
     
    procedure TAccueil.MontrerappliClick(Sender: TObject);
    begin
         Show; // Rend visible l'application depuis icone MenuPop dans barre des taches
    end;
     
    procedure TAccueil.CacherappliClick(Sender: TObject);
    begin
         Hide;// Fait disparaitre l'application depuis icône MenuPop dans barre des tâches
    end;
     
    {==============================================================}
    {solution en créant un raccourci dans le dossier               }
    {c:\windows\Menu Démarrer\Programmes\démarrage                 }
    {==============================================================}
     
    {fonction qui permet de créer un raccourci}
    procedure CreFicLien(FicSource, FicRaccourci :string);
    var
      PersistFile : IPersistFile;
      ShellLink : IShellLink;
      RaccourciWC : array[0..MAX_PATH] of WideChar;
    begin
      if UpperCase(extractFileExt(FicRaccourci))<>'.LNK' then
      FicRaccourci:=FicRaccourci+'.lnk';
      ShellLink:=CreateComObject(CLSID_ShellLink) as IShellLink;
      ShellLink.QueryInterface(IPersistFile, PersistFile);
      ShellLink.SetDescription('');
      ShellLink.SetPath(PChar(FicSource));
      ShellLink.SetShowCmd(SW_SHOW);
      MultiByteToWideChar(CP_ACP, 0, PChar(FicRaccourci), -1, @RaccourciWC, MAX_PATH);
      PersistFile.Save(RaccourciWC, true);
    end;
     
    {permet obtenir le nom du dossier qui contient les raccourcis sur les programmes qui sont en AutoRun}
    function DossierStartUp:String; // obtenir le nom du dossier qui contient les raccourcis sur les programmes qui sont en AutoRun
    Var Reg:TRegistry;
    begin
      Reg:=TRegistry.Create;
      Reg.RootKey:=HKEY_CURRENT_USER;
      Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',false);
      result:=Reg.ReadString('StartUp')+'\';
      Reg.free;
    end;
     
    {rend un programme Autorun par ajout d'un raccourci}
    procedure AutoRunRaccourci(FichierADemarrer:string);
    begin
      if MessageDlg('Ajouter un raccourci: vous souhaitez mettre le programme '+ FichierADemarrer+' en Autorun',
    				 mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    	 CreFicLien(FichierADemarrer, DossierStartUp+ExtractFileName(FichierADemarrer));
    end;
     
    {éfface le raccourci pour ne plus mettre le programme en autorun}
    procedure AutoRunSuppression(FichierADemarrer:string);
    begin
      if MessageDlg('Supprimer un raccourci: vous souhaitez ne plus mettre le programme '+ FichierADemarrer+' en Autorun',
    				 mtConfirmation, [mbYes, mbNo], 0) = mrYes then
          deleteFile(DossierStartUp+ExtractFileName(FichierADemarrer)+'.lnk');
    end;
     
    { PROCEDURES BOUTONS POUR OPTIONS ECRITES CI-DESSUS }
     
    {Appelle la boite de dialogue d'ouverture fichier}
    procedure TAccueil.Parcourir1Click(Sender: TObject);
    begin
         if Open.Execute then Editchemin.Text:=Open.FileName;
    end;
     
    // Ajout d'un raccourci
    procedure TAccueil.Button3Click(Sender: TObject);
    begin
    	  AutoRunRaccourci(Editchemin.Text);
    end;
     
    // Suppression d'un raccourci
    procedure TAccueil.Button4Click(Sender: TObject);
    begin
    	  AutoRunSuppression(Editchemin.Text);
    end;
     
    { =============== FIN DES PROCEDURES BOUTONS  ============== }
    {Procédures pour ouvrir Fiches LOGICIELS via Menu Main}
    procedure TAccueil.Bureautique1Click(Sender: TObject);
    begin
    	   bureautique.show;  //  pour ouvrir fiche bureautique
    end;
     
    procedure TAccueil.Basededonnes1Click(Sender: TObject);
    begin
    	  basededonnees.show;
    end;
     
    procedure TAccueil.Disquedur1Click(Sender: TObject);
    begin
    	   disquedur.show;
    end;
     
    procedure TAccueil.Divers1Click(Sender: TObject);
    begin
          divers.show;
    end;
     
    procedure TAccueil.Gestionperso1Click(Sender: TObject);
    begin
          gestionperso.show;
    end;
     
    procedure TAccueil.Graphisme1Click(Sender: TObject);
    begin
    	   graphisme.show;
    end;
     
    procedure TAccueil.Internet1Click(Sender: TObject);
    begin
    	   internet.show;
    end;
     
    procedure TAccueil.Jeux1Click(Sender: TObject);
    begin
          jeux.show;
    end;
     
    procedure TAccueil.Mp31Click(Sender: TObject);
    begin
          mp3.show;
    end;
     
    procedure TAccueil.ProgrammationAppli1Click(Sender: TObject);
    begin
    	   programmationapplications.show;
    end;
     
    procedure TAccueil.ProgrammationHTML1Click(Sender: TObject);
    begin
    	   programmationhtml.show;
    end;
     
    procedure TAccueil.Utilitaires1Click(Sender: TObject);
    begin
          utilitaires.show;
    end;
     
    // Procédures pour ouvrir Fiches LOGICIELS via Click Boutons
    procedure TAccueil.Btlog1Click(Sender: TObject);
    begin
     bureautique.show;  //  pour ouvrir fiche bureautique
    end;
     
    procedure TAccueil.Btlog2Click(Sender: TObject);
    begin
     basededonnees.show;
    end;
     
    procedure TAccueil.Btlog3Click(Sender: TObject);
    begin
     disquedur.show;
    end;
     
    procedure TAccueil.Btlog4Click(Sender: TObject);
    begin
    divers.show;
    end;
     
    procedure TAccueil.Btlog5Click(Sender: TObject);
    begin
    gestionperso.show;
    end;
     
    procedure TAccueil.Btlog6Click(Sender: TObject);
    begin
    graphisme.show;
    end;
     
    procedure TAccueil.Btlog7Click(Sender: TObject);
    begin
     internet.show;
    end;
     
    procedure TAccueil.Btlog8Click(Sender: TObject);
    begin
     jeux.show;
    end;
     
    procedure TAccueil.Btlog9Click(Sender: TObject);
    begin
     mp3.show;
    end;
     
    procedure TAccueil.Btlog10Click(Sender: TObject);
    begin
    programmationapplications.show;
    end;
     
    procedure TAccueil.Btlog11Click(Sender: TObject);
    begin
      programmationhtml.show;
    end;
     
    procedure TAccueil.Btlog12Click(Sender: TObject);
    begin
      utilitaires.show;
    end;
     
     
    {FIN des procédures pour ouvrir les fiches}
     
    {CODES pour restaurer les noms des fiches LOGICIELS par défaut}
    procedure TAccueil.Restaurer1Click(Sender: TObject);
    begin
    if MessageDlg('Etes-vous sur de vouloir restaurer les noms des fiches LOGICIELS par défaut ? '
    +#13+'Vos paramétres personnalisés seront supprimés !! ' ,
    mtWarning, [mbYes, mbNo],0) = mryes then
    Logiciels1.items[0].caption := 'Bureautique'; // fiche 1 bureautique
    Logiciels1.items[2].caption := 'Base de données'; // fiche 2 base de données
    Logiciels1.items[4].caption := 'Disque Dur'; // fiche 3 disque dur
    Logiciels1.items[6].caption := 'Divers'; // fiche 4 divers
    Logiciels1.items[8].caption := 'Gestion perso'; // fiche 5 gestion perso
    Logiciels1.items[10].caption := 'Graphisme'; // fiche 6 graphisme
    Logiciels1.items[13].caption := 'Internet'; // fiche 7 internet
    Logiciels1.items[15].caption := 'Jeux'; // fiche 8 jeux
    Logiciels1.items[17].caption := 'Mp3'; // fiche 9 mp3
    Logiciels1.items[19].caption := 'Applications'; // fiche 10 programmation Application
    Logiciels1.items[21].caption := 'Programmation HTML'; // fiche 11 programmation Html
    Logiciels1.items[23].caption := 'Utilitaires'; // fiche 12 utilitaires
       begin
       AfficheNomsBoutons; // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
    end;
    end;
     
    //=== DEBUT PROCEDURES POUR RENOMMER FICHES LOGICIELS PAR UTILISATEUR ==//
     
     procedure TAccueil.RenommerbureautiqueClick(Sender: TObject);
    begin
    	 if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[0].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[0].caption);
    bureautique.caption := Logiciels1.Items[0].caption;
    		end;
        Logiciels1.items[1].Caption :='Renommer fiche ' + Logiciels1.Items[0].caption;
        Btlog1.caption :=Logiciels1.Items[0].caption + ' (F1)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerbasedonneesClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[2].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[2].caption);
    basededonnees.caption := Logiciels1.Items[2].caption;
    		end;
        Logiciels1.items[3].Caption :='Renommer fiche ' + Logiciels1.Items[2].caption;
        Btlog2.caption :=Logiciels1.Items[2].caption + ' (F2)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerdisquedurClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[4].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[4].caption);
    disquedur.caption := Logiciels1.Items[4].caption;
    		end;
         Logiciels1.items[5].Caption :='Renommer fiche ' + Logiciels1.Items[4].caption;
         Btlog3.caption :=Logiciels1.Items[4].caption + ' (F3)' ;
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerdiversClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[6].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[6].caption);
    divers.caption := Logiciels1.Items[6].caption;
    		end;
         Logiciels1.items[7].Caption :='Renommer fiche ' + Logiciels1.Items[6].caption;
         Btlog4.caption :=Logiciels1.Items[6].caption + ' (F4)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommergestionpersoClick(Sender: TObject);
    begin
         if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[8].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[8].caption);
    gestionperso.caption := Logiciels1.Items[8].caption;
    		end;
         Logiciels1.items[9].Caption :='Renommer fiche ' + Logiciels1.Items[8].caption;
         Btlog5.caption :=Logiciels1.Items[8].caption + ' (F5)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommergraphismeClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[10].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[10].caption);
    graphisme.caption := Logiciels1.Items[10].caption;
    		end;
         Logiciels1.items[11].Caption :='Renommer fiche ' + Logiciels1.Items[10].caption;
         Btlog6.caption :=Logiciels1.Items[10].caption + ' (F6)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerinternetClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[13].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[13].caption);
    internet.caption := Logiciels1.Items[13].caption;
    		end;
       Logiciels1.items[14].Caption :='Renommer fiche ' + Logiciels1.Items[13].caption;
       Btlog7.caption :=Logiciels1.Items[13].caption + ' (F7)';
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
       Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerjeuxClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[15].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[15].caption);
    jeux.caption := Logiciels1.Items[15].caption;
    		end;
         Logiciels1.items[16].Caption :='Renommer fiche ' + Logiciels1.Items[15].caption;
         Btlog8.caption :=Logiciels1.Items[15].caption + ' (F8)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.Renommermp3Click(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[17].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[17].caption);
    mp3.caption := Logiciels1.Items[17].caption;
    		end;
        Logiciels1.items[18].Caption :='Renommer fiche ' + Logiciels1.Items[17].caption;
        Btlog9.caption :=Logiciels1.Items[17].caption + ' (F9)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerProgAppliClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[19].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[19].caption);
    programmationapplications.caption := Logiciels1.Items[19].caption;
    		end;
         Logiciels1.items[20].Caption :='Renommer fiche ' + Logiciels1.Items[19].caption;
         Btlog10.caption :=Logiciels1.Items[19].caption + ' (F10)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerProghtmlClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[21].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[21].caption);
    programmationhtml.caption := Logiciels1.Items[21].caption;
    		end;
         Logiciels1.items[22].Caption :='Renommer fiche ' + Logiciels1.Items[21].caption;
         Btlog11.caption :=Logiciels1.Items[21].caption + ' (F11)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerutilitairesClick(Sender: TObject);
    begin
         if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[23].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[23].caption);
    utilitaires.caption := Logiciels1.Items[23].caption;
    		end;
         Logiciels1.items[24].Caption :='Renommer fiche ' + Logiciels1.Items[23].caption;
         Btlog12.caption :=Logiciels1.Items[23].caption + ' (F12)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
    //= FIN DES PROCEDURES POUR RENOMMER FICHES LOGICIELS =//
     
    {PROCEDURES POUR DRAP DROP RACCOURCIS}
    procedure TAccueil.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
    if Key=vk_Escape then Close;
    end;
     
    {AJOUTER UN PROGRAMME EN RACCOURCI}
    procedure TAccueil.SpeedButton1Click(Sender: TObject);
    begin
     if Open.Execute then
       begin
       FicIni.WriteString('Programmes',IntToStr(Combien+1),Open.FileName);
       AjouterProg;
    	end;
    end;
     
    {Faire apparaitre les programmes}
    Procedure TAccueil.AjouterProg;
    var
    Limage:TObject;
    Icone:TIcon;
    LeProg:String;
    begin
    Inc(Combien);
    // Nom du programme
    LeProg:=FicIni.ReadString('Programmes',IntToStr(Combien),'');
    // Créer l'image qui recevra l'icone du programme.
    // ça peut être un bouton ou tout ce que tu veux.
    Icone:=TIcon.Create;
    Limage:=Timage.Create(self);
    TImage(Limage).Parent:= Accueil;
    TImage(Limage).Top:=70; // Distance à partir du haut de la fiche (données d'origine = 50)
    TImage(Limage).Left:=Combien*(32+15)+15;
    TImage(Limage).AutoSize:=True;
    TImage(Limage).Picture.Icon:=Imaj.Picture.Icon;
    TImage(Limage).OnMouseDown:=ImageMouseDown;
    TImage(Limage).Hint:='N''existe PLUS !!';
    TImage(Limage).ShowHint:=True;
    TImage(Limage).Name:='Image'+IntToStr(Combien);
    TImage(Limage).Tag:=Combien;
       // Si le Programme existe BIEN alors afficher SON icone...
       if FileExists(LeProg) then
       begin
       // Récupérer l'icone.
       Icone.Handle:=ExtractIcon(Handle,Pchar(LeProg),0);
          if Icone.Handle<>0
          then TImage(Limage).Picture.Icon:=Icone;
    	TImage(Limage).Hint:=ExtractFileName(LeProg);
    	end
       // Sinon afficher Image Par Defaut.
    	else TImage(Limage).Picture.Assign(Image.Picture);
    Icone.Free;
    end;
     
    {Lancer le programme ou supprimer le programme}
    procedure TAccueil.ImageMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
    Prog, Chemin:String;
    Objet:TObject;
    Memoire:TStringList;
    W:Word;
    begin
    	if ssCtrl in Shift then   // Si Ctrl Appuyé, on va Draguer !!!
       begin
    	Timage(Sender).BeginDrag(True);
       Exit;
    	end;
    Prog:=Ficini.ReadString('Programmes',IntToStr(Timage(Sender).Tag),'');
       if Button=mbLeft then // Click Gauche, Démmarer le programme.
       begin
       Screen.Cursor:=crHourGlass;
       // ShowMessage(IntToStr(Timage(Sender).Tag)+'"'+Prog+'"');
       Chemin:=ExtractFilePath(Prog);
       W:=ShellExecute(Handle,'OPEN',Pchar(Prog),Nil,PChar(Chemin),sw_show);
       Screen.Cursor:=crDefault;
        if W<33
          then ShowMessage('Impossible de lancer: '+Prog);
    	end;
    	 if Button=mbRight then // Supprimer un programme:
    	begin
     // Si demande de suppression , demander confirmation.
    	 if x<>-500 then
    		if MessageDlg('Supprimer  '+Prog+' ???',mtWarning,[mbYes,mbNo],0)=mrNo
    		then Exit;
    	// Supprimer le programme
       FicIni.WriteString('Programmes',IntToStr(Timage(Sender).Tag),'');
    	Memoire:=TStringList.Create; //Mettre en mémoire les AUTRES programmes.
    	   for x:=0 to Combien  do
          begin
             if FicIni.ReadString('Programmes',IntToStr(x),'')<>''
             then Memoire.Add(FicIni.ReadString('Programmes',IntToStr(x),''));
          Objet:=FindComponent('Image'+IntToStr(x));  // Supprimer les images
    	   Timage(Objet).Free;
          end;
    	FicIni.EraseSection('Programmes'); // Effacer la section Programmes du fichier Ini
       Combien:=-1;
          for x:=0 to Memoire.Count-1 do
          begin
          // Recréer la section Programmes du fichier Ini
          FicIni.WriteString('Programmes',IntToStr(x),Memoire[x]);
    	   // Réinstaller les programmes restant.
          AjouterProg;
          end;
       Memoire.Free;
       end;
    end;
     
    // Effacer tous les raccourcis programmes (pour libérer place pour drag and drop)
    procedure TAccueil.SpeedBtnEffaceProgClick(Sender: TObject);
    begin
     if MessageDlg('Voulez vous vraiment effacer les raccourcis programmes de cette fiche ?' + #13 + '               ! un redémarrage de LISTLOG est impératif !', mtwarning, [mbYes, mbNo],0) =mrYes then
    		begin
          FicIni.EraseSection('Programmes'); // Effacer la section Programmes du fichier Ini
           Close;
          bReload := True;  // redemarrage ListLog
          FicIni.Free;
        end;
    end;
     
    end.

    Citation Envoyé par Charly910 Voir le message
    Bonjour,

    j'ai testé ton code en élaguant beaucoup de choses impossibles à reproduire facilement. J'arrive bien à libérer le fichier ini dans le Create de la form et dans son Destroy.

    Si tu as des erreurs de violation quand tu ajoutes des Ficini.free c'est surement que tu essayes d'écrire ou de lire alors que Ficini est détruit.
    Tu dois pouvoir tester cela avec des points d'arrêt + F8 pour localiser l'instruction qui fait planter ?

    A+
    Charly

  3. #23
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 345
    Points : 3 123
    Points
    3 123
    Par défaut
    Il faudrait que tu joignes le fichier dfm car sinon c'est très long de reconstituer dans une Form ...

  4. #24
    Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2006
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Tarn et Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : Services à domicile

    Informations forums :
    Inscription : Octobre 2006
    Messages : 74
    Points : 50
    Points
    50
    Par défaut
    Oui bien sur, excuse moi - Voici le fichier DFM dans le Zip

    A+
    Beauserge
    Fichiers attachés Fichiers attachés

  5. #25
    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
    re,

    tu ne ferais pas appel à FicIni dans une de tes unités ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    uses bureautiquelog, Boitepropos, Hint, Guide, graphismelog, basededonneeslog, disquedurlog,
         diverslog, gestionpersolog, internetlog,jeuxlog, mp3log, programmationapplicationslog,
    	  programmationhtmllog, utilitaireslog ;
    normalement si tu mets FicIni.Free; dans le OnDestroy de la fiche ça devrait le faire à moins d'une tentative d'accès après la libération !!!
    mais c'est peu probable si c'est la fiche principale.

  6. #26
    Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2006
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Tarn et Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : Services à domicile

    Informations forums :
    Inscription : Octobre 2006
    Messages : 74
    Points : 50
    Points
    50
    Par défaut
    Effectivement Charly, bien vu - j'ai placé le FicIni.free dans le OnDestroy et il n'y a plus d'erreur violation. c'est déja un premiers pas.

    Par contre, le problème du redémarrage après le click sur le bouton SpeedBtnEffaceProgClick (soit le vidage de la section Programmes du fichIni) est toujours là si il y a un icone sur la fiche ???.
    A l'inverse, s'il n'y a pas d’icône sur la fiche, le même clic sur le bouton fait redémarrer le programme correctement ce qui est parfait !
    D'ou peut provenir cette anomalie ?

    Pour répondre à ta question, je fais appel à FicIni en lecture et en écriture dans les autres unités mais pas FicIni.free ? est ce un problème ?
    Devrais je aussi libérer le ficIni dans le OnDestroy de chaque fiche ?

    Je te joins le code et DFM d'une des autres fiches (elles sont toutes identiques au niveau du code, seul le nom des fiches changent), afin que tu regarde si une procédure pourrait interférer ..

    A+
    Beauserge
    Fichiers attachés Fichiers attachés

  7. #27
    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 Beauserge Voir le message
    Effectivement Charly, bien vu - j'ai placé le FicIni.free dans le OnDestroy et il n'y a plus d'erreur violation. c'est déja un premiers pas.
    Je m'en doutai un peu.
    En fait quand tu libérais FicIni dans le OnClose de ta fiche principale les unités "Log" essayaient d'écrire dans le fichier alors que FicIni n'existait plus.
    En le plaçant dans le OnDestroy on évite ce genre désagrément. ... au passage moi c'est Cirec.

    Citation Envoyé par Beauserge Voir le message
    Par contre, le problème du redémarrage après le click sur le bouton SpeedBtnEffaceProgClick (soit le vidage de la section Programmes du fichIni) est toujours là si il y a un icone sur la fiche ???.
    A l'inverse, s'il n'y a pas d’icône sur la fiche, le même clic sur le bouton fait redémarrer le programme correctement ce qui est parfait !
    D'ou peut provenir cette anomalie ?
    Utilises tu un composant ou un code qui permet de limiter l'application à une instance à la fois ?
    parce que que vu le nombre d'items sauvegardés par l'unité BureautiqueLog.pas multiplié par nombre d'unités Log ça pourrait expliquer que le programme soit encore en mémoire alors que le deuxième frappe à la porte.
    Comme le suggérait sgmsg avec un deuxième programme qui se charge de vérifier si l'application est encore en mémoire et de la relancer, ça fonctionne bien mieux.

    Citation Envoyé par Beauserge Voir le message
    Pour répondre à ta question, je fais appel à FicIni en lecture et en écriture dans les autres unités mais pas FicIni.free ? est ce un problème ?
    Devrais je aussi libérer le ficIni dans le OnDestroy de chaque fiche ?
    Non non non surtout pas sinon tu auras une violation d'accès assurée.

    Citation Envoyé par Beauserge Voir le message
    Je te joins le code et DFM d'une des autres fiches (elles sont toutes identiques au niveau du code, seul le nom des fiches changent), afin que tu regarde si une procédure pourrait interférer ..
    non mais je rejoins ce qui a déjà été dit à savoir penser à une gestion différente de la sauvegarde parce que là il y a beaucoup d'écriture et de lecture un peu partout.

    Cordialement,
    @+

  8. #28
    Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2006
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Tarn et Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : Services à domicile

    Informations forums :
    Inscription : Octobre 2006
    Messages : 74
    Points : 50
    Points
    50
    Par défaut
    Merci Cirec pour tes éclaircissements et explications.

    A ma connaissance, je n'utilises pas de composant qui permet de limiter l'application à une instance à la fois ?
    J'ai regardé également dans le code des unités au cas où mais je n'ai rien vu qui pourrait ressembler à cela.

    Pour ce qui est de revoir différemment la gestion de la sauvegarde, c'est sur - je sais que le code à été mal pensé au départ mais vu la quantité d'écriture dans ce programme, c'est un travail Titanesque, donc je verrai ça plus tard.

    Merci en tout cas à tous pour votre aide sur ce sujet.


    Cordialement
    Beauserge

  9. #29
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 345
    Points : 3 123
    Points
    3 123
    Par défaut
    Bonjour,

    J'ai chargé ton code et enlevé les références aux autres fenêtre.
    Ton code fonctionne chez moi, en ajoutant ou supprimant les items "programmes" de FicIni. Pas de plantage avec le Ficini.free. Le redémarrage se fait bien après effacement des items.

    Seul Pb : l'affichage de nouveaux raccourcis (par mon bouton Button1 en haut à droite) nécessite un redémarrage car je ne fait que modifier FicIni avec ce bouton.

    Voici le code très peu modifié :

    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
    {Fiche principale de l'application - Accueil}
    unit MenuPrincipal;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Menus, ExtCtrls, ComCtrls, Buttons, IniFiles, ShellAPI,
      Registry, ActiveX, ComObj, ShlObj ;
     {ShellApi déclare le retrait de l'icone dans barre des taches = On Close}
     {Registry, ActiveX, ComObj et ShlObj servent à la création des prodécures
     raccourcis et options diverses}
     
    Const WM_MYMESSAGE = WM_USER+100; // numéro de message utilisé plus bas.
     
    type
        TAccueil = class(TForm)
        MainMenu1: TMainMenu; // paramétres pour Menu Main
        Fichier1: TMenuItem;
        Apropos1: TMenuItem;
        Bureautique1: TMenuItem;
        Basededonnes1: TMenuItem;
        Internet1: TMenuItem;
        Gestionperso1: TMenuItem;
        Jeux1: TMenuItem;
        Divers1: TMenuItem;
        Mp31: TMenuItem;
        Disquedur1: TMenuItem;
        Graphisme1: TMenuItem;
        Utilitaires1: TMenuItem;
        ProgrammationHTML1: TMenuItem;
        ProgrammationAppli1: TMenuItem;
        Restaurer1: TMenuItem;
        ProgressBar1 : TprogressBar;
        Quitter1: TMenuItem;
    	  Imprimer1: TMenuItem;
        N2: TMenuItem;
        Logiciels1: TMenuItem;
        Renommerbureautique: TMenuItem;
        Renommerbasedonnees: TMenuItem;
        Renommerdisquedur: TMenuItem;
        Renommerdivers: TMenuItem;
        Renommergestionperso: TMenuItem;
        Renommerinternet: TMenuItem;
        Renommerjeux: TMenuItem;
        Renommermp3: TMenuItem;
        RenommerProgAppli: TMenuItem;
        RenommerProghtml: TMenuItem;
        Renommerutilitaires: TMenuItem;
        PrintDialog1: TPrintDialog;
        PopupMenu1: TPopupMenu;
        Fermerdfinitivement1: TMenuItem;
        Montrerappli: TMenuItem;
        Cacherappli: TMenuItem;
        Panelplan: TPanel;
    	  GroupBox1: TGroupBox;
        Label1: TLabel;
        GroupBox2: TGroupBox;
        Button3: TButton;
        Button4: TButton;
        Open: TOpenDialog;
        SaveDialog1: TSaveDialog;
        Im2: TImage;
        Label3: TLabel;
    	  SpeedButton1: TSpeedButton;
        Image: TImage;
        Imaj: TImage;
        N4: TMenuItem;
        Aide1: TMenuItem;
        Guide1: TMenuItem;
        Labeldrag: TLabel;
        Renommergraphisme: TMenuItem;
        EditChemin: TEdit;
        Parcourir1: TBitBtn;
        Btlog1: TButton;
        Btlog2: TButton;
        Btlog3: TButton;
        Btlog4: TButton;
        Btlog5: TButton;
        Btlog6: TButton;
        Btlog7: TButton;
        Btlog8: TButton;
        Btlog9: TButton;
        Btlog10: TButton;
        Btlog11: TButton;
        Btlog12: TButton;
        SpeedBtnEffaceProg: TSpeedButton;
        Button1: TButton;
        procedure Fermer1Click(Sender: TObject);
        procedure Bureautique1Click(Sender: TObject);
        procedure Apropos1Click(Sender: TObject);
        procedure Quitter1Click(Sender: TObject);
        procedure FormActivate(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure Imprimer1Click(Sender: TObject);
        procedure Fermerdfinitivement1Click(Sender: TObject);
        procedure MontrerappliClick(Sender: TObject);
        procedure CacherappliClick(Sender: TObject);
    	  procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Parcourir1Click(Sender: TObject);
        procedure Restaurer1Click(Sender: TObject);
        procedure RenommerbureautiqueClick(Sender: TObject);
        procedure FormKeyDown(Sender: TObject; var Key: Word;
          Shift: TShiftState);
        procedure SpeedButton1Click(Sender: TObject);
        procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Guide1Click(Sender: TObject);
        procedure Graphisme1Click(Sender: TObject);
        procedure RenommergraphismeClick(Sender: TObject);
        procedure Basededonnes1Click(Sender: TObject);
        procedure RenommerbasedonneesClick(Sender: TObject);
        procedure Disquedur1Click(Sender: TObject);
    	  procedure RenommerdisquedurClick(Sender: TObject);
        procedure Divers1Click(Sender: TObject);
        procedure RenommerdiversClick(Sender: TObject);
        procedure Gestionperso1Click(Sender: TObject);
        procedure RenommergestionpersoClick(Sender: TObject);
        procedure Internet1Click(Sender: TObject);
        procedure RenommerinternetClick(Sender: TObject);
        procedure Jeux1Click(Sender: TObject);
        procedure RenommerjeuxClick(Sender: TObject);
        procedure Mp31Click(Sender: TObject);
        procedure Renommermp3Click(Sender: TObject);
        procedure ProgrammationAppli1Click(Sender: TObject);
        procedure RenommerProgAppliClick(Sender: TObject);
        procedure ProgrammationHTML1Click(Sender: TObject);
        procedure RenommerProghtmlClick(Sender: TObject);
        procedure Utilitaires1Click(Sender: TObject);
        procedure RenommerutilitairesClick(Sender: TObject);
     
        procedure AjouterProg;
        procedure Btlog1Click(Sender: TObject);
        procedure Btlog2Click(Sender: TObject);
        procedure Btlog3Click(Sender: TObject);
        procedure Btlog4Click(Sender: TObject);
        procedure Btlog5Click(Sender: TObject);
        procedure Btlog6Click(Sender: TObject);
        procedure Btlog7Click(Sender: TObject);
        procedure Btlog8Click(Sender: TObject);
        procedure Btlog9Click(Sender: TObject);
        procedure Btlog10Click(Sender: TObject);
        procedure Btlog11Click(Sender: TObject);
        procedure Btlog12Click(Sender: TObject);
        procedure SpeedBtnEffaceProgClick(Sender: TObject);
        procedure Button1Click(Sender: TObject);
     
     
     
      private
        { Déclarations privées }
        procedure TrayMessage(var Msg: TMessage); message WM_MYMESSAGE;
     
      public
    	 { Déclarations publiques }
       procedure AfficheNomsBoutons; // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       procedure LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       procedure Sauvernomfiches; // procedure perso - pour enregistrer nom des fiches dans fichier .ini - utile lorsqu'une une fiche est renommée
       procedure LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
     
      end;
     
    var
      Accueil: TAccueil;
      items : TMenuItem;
      NotifyStruc : TNotifyIconData; // Structure de l'icone
      FicIni : TIniFile ;  // pour déclarer fichier .ini (drag drop raccourcis)
      bReload: Boolean = False; // variable pour redemarrage ListLog
     
     implementation
    { uses bureautiquelog, Boitepropos, Hint, Guide, graphismelog, basededonneeslog, disquedurlog,
         diverslog, gestionpersolog, internetlog,jeuxlog, mp3log, programmationapplicationslog,
    	  programmationhtmllog, utilitaireslog ;  }
    {$R *.DFM}
     
    var
    combien:Integer; // Combien de programmes actuellement
     
    procedure TAccueil.TrayMessage(var Msg: TMessage);// message WM_MYMESSAGE;
    //Le fait d'avoir déclaré dans Accueil procedure TrayMessage(var Msg: TMessage); message WM_MYMESSAGE;
    //et d'avoir fait NotifyStruc.uCallbackMessage := WM_MYMESSAGE indique au programme que tout message destiné à la petite icone (try icons)
    //doit déclencher la procédure TrayMessage
    var coordonnes_souris :TPoint;
    begin
      //('Bouton droit pressé on affiche le menu pop');
      if (Msg.LParam=WM_RBUTTONDOWN) then
      begin
        GetCursorPos(coordonnes_souris);//récupération de la position de la souris
        SetForegroundWindow(Handle); // mise en avant plan de l'application
    	 PopupMenu1.Popup(coordonnes_souris.x,coordonnes_souris.y); //affichage du menu
      end;
      if (Msg.LParam=WM_LBUTTONDOWN) then { Bouton gauche préssé }
       ShowWindow(Application.Handle, SW_SHOW); // affiche la grande icone dans 
      end;                                      // la barre des taches
     
    procedure TAccueil.Fermer1Click(Sender: TObject);
    begin
         close;   // ferme l'application
    end;
     
    procedure TAccueil.Guide1Click(Sender: TObject);
    begin
    //	  Aide.ShowModal;
    end;
     
    procedure TAccueil.Apropos1Click(Sender: TObject);
    begin
    //      APropos.ShowModal; // pour ouvrir fenetre A-Propos
    end;     // showmodal oblige l'utilisateur à fermer la fenetre pour continuer
     
    procedure TAccueil.Quitter1Click(Sender: TObject);
    begin
    if MessageDlg('Voulez-vous vraiment quitter l''application ?', mtConfirmation,
    	[mbYes, mbNo],0)= mrYes then
    	Close;  // demande confirmation avant de quitter l'application
    end;
     
    procedure TAccueil.FormActivate(Sender: TObject);
    begin
    	   WindowState:=wsNormal; // permet d'avoir la fiche telle qu'à la conception
    end;
     
     
    // procedure perso - pour enregistrer nom des fiches dans fichier .ini - utile lorsqu'une une fiche est renommée
    procedure TAccueil.Sauvernomfiches;
    begin
        FicIni.WriteString('Element','Bureautique', Logiciels1.Items[0].caption);
    	  FicIni.WriteString('Element','Base de données', Logiciels1.Items[2].caption);
    	  FicIni.WriteString('Element','Disque dur', Logiciels1.Items[4].caption);
    	  FicIni.WriteString('Element','Divers', Logiciels1.Items[6].caption);
    	  FicIni.WriteString('Element','Gestion perso', Logiciels1.Items[8].caption);
    	  FicIni.WriteString('Element','Graphisme', Logiciels1.Items[10].caption);
    	  FicIni.WriteString('Element','Internet', Logiciels1.Items[13].caption);
    	  FicIni.WriteString('Element','Jeux', Logiciels1.Items[15].caption);
    	  FicIni.WriteString('Element','Mp3', Logiciels1.Items[17].caption);
    	  FicIni.WriteString('Element','Programmation Applications', Logiciels1.Items[19].caption);
    	  FicIni.WriteString('Element','Programmation HTML', Logiciels1.Items[21].caption);
        FicIni.WriteString('Element','Utilitaires', Logiciels1.Items[23].caption);
    end;
     
    // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
    procedure TAccueil.AfficheNomsBoutons;
    begin
      Btlog1.caption :=Logiciels1.Items[0].caption + ' (F1)';
      Btlog2.caption :=Logiciels1.Items[2].caption + ' (F2)';
      Btlog3.caption :=Logiciels1.Items[4].caption + ' (F3)' ;
      Btlog4.caption :=Logiciels1.Items[6].caption + ' (F4)';
      Btlog5.caption :=Logiciels1.Items[8].caption + ' (F5)';
      Btlog6.caption :=Logiciels1.Items[10].caption + ' (F6)';
      Btlog7.caption :=Logiciels1.Items[13].caption + ' (F7)';
      Btlog8.caption :=Logiciels1.Items[15].caption + ' (F8)';
      Btlog9.caption :=Logiciels1.Items[17].caption + ' (F9)';
      Btlog10.caption :=Logiciels1.Items[19].caption + ' (F10)';
      Btlog11.caption :=Logiciels1.Items[21].caption + ' (F11)';
      Btlog12.caption :=Logiciels1.Items[23].caption + ' (F12)';
    end;
     
    // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
    procedure TAccueil.LibelleRenomItems;
    begin
      Logiciels1.items[1].Caption :='Renommer fiche ' + Logiciels1.Items[0].caption;
      Logiciels1.items[3].Caption :='Renommer fiche ' + Logiciels1.Items[2].caption;
      Logiciels1.items[5].Caption :='Renommer fiche ' + Logiciels1.Items[4].caption;
      Logiciels1.items[7].Caption :='Renommer fiche ' + Logiciels1.Items[6].caption;
      Logiciels1.items[9].Caption :='Renommer fiche ' + Logiciels1.Items[8].caption;
      Logiciels1.items[11].Caption :='Renommer fiche ' + Logiciels1.Items[10].caption;
      Logiciels1.items[14].Caption :='Renommer fiche ' + Logiciels1.Items[13].caption;
      Logiciels1.items[16].Caption :='Renommer fiche ' + Logiciels1.Items[15].caption;
      Logiciels1.items[18].Caption :='Renommer fiche ' + Logiciels1.Items[17].caption;
      Logiciels1.items[20].Caption :='Renommer fiche ' + Logiciels1.Items[19].caption;
      Logiciels1.items[22].Caption :='Renommer fiche ' + Logiciels1.Items[21].caption;
      Logiciels1.items[24].Caption :='Renommer fiche ' + Logiciels1.Items[23].caption;
    end;
     
     
     // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
    procedure TAccueil.LimiterItems;
    var
     S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12:string; //  variable pour limiter caractéres dans items.Caption
      type
      TShortCaption = string[19];  // variable (limite) en nombre de caractéres dans items.Caption
      begin
       S1:= Logiciels1.Items[0].caption;
           Logiciels1.Items[0].caption := TShortCaption(S1);
              S2:= Logiciels1.Items[2].caption;
               Logiciels1.Items[2].caption := TShortCaption(S2);
                 S3:= Logiciels1.Items[4].caption;
                   Logiciels1.Items[4].caption := TShortCaption(S3);
                     S4:= Logiciels1.Items[6].caption;
                      Logiciels1.Items[6].caption := TShortCaption(S4);
                        S5:= Logiciels1.Items[8].caption;
                          Logiciels1.Items[8].caption := TShortCaption(S5);
                            S6:= Logiciels1.Items[10].caption;
                             Logiciels1.Items[10].caption := TShortCaption(S6);
                               S7:= Logiciels1.Items[13].caption;
                                 Logiciels1.Items[13].caption := TShortCaption(S7);
                                   S8:= Logiciels1.Items[15].caption;
                                    Logiciels1.Items[15].caption := TShortCaption(S8);
                                      S9:= Logiciels1.Items[17].caption;
                                       Logiciels1.Items[17].caption := TShortCaption(S9);
                                         S10:= Logiciels1.Items[19].caption;
                                           Logiciels1.Items[19].caption := TShortCaption(S10);
                                             S11:= Logiciels1.Items[21].caption;
                                                Logiciels1.Items[21].caption := TShortCaption(S11);
                                                  S12:= Logiciels1.Items[23].caption;
                                                    Logiciels1.Items[23].caption := TShortCaption(S12);
                                                     end;
     
     {PERMET DE LIRE LES PARAMETRES SAUVEGARDES DES OPTIONS RENOMMER LA FICHE
    DANS LE FICHIER .ini}
    procedure TAccueil.FormCreate(Sender: TObject);
    var
      hinte:string; // pour structure icone
      j:integer;    // pour structure icone
      x:integer; // pour drag drop raccourci
     begin
      FicIni := TIniFile.Create(ExtractFilePath(Application.ExeName)+ 'ListLog.ini');
     	// ExtractFilePath pour que le .ini se trouve dans le même directory que l'exécutable
      Logiciels1.Items[0].caption := FicIni.ReadString('Element','Bureautique', caption);
      Logiciels1.Items[2].caption := FicIni.ReadString('Element','Base de données', caption);
      Logiciels1.Items[4].caption := FicIni.ReadString('Element','Disque dur', caption);
      Logiciels1.Items[6].caption := FicIni.ReadString('Element','Divers', caption);
      Logiciels1.Items[8].caption := FicIni.ReadString('Element','Gestion perso', caption);
      Logiciels1.Items[10].caption := FicIni.ReadString('Element','Graphisme', caption);
      Logiciels1.Items[13].caption := FicIni.ReadString('Element','Internet', caption);
      Logiciels1.Items[15].caption := FicIni.ReadString('Element','Jeux', caption);
      Logiciels1.Items[17].caption := FicIni.ReadString('Element','Mp3', caption);
      Logiciels1.Items[19].caption := FicIni.ReadString('Element','Programmation Applications', caption);
      Logiciels1.Items[21].caption := FicIni.ReadString('Element','Programmation HTML', caption);
      Logiciels1.Items[23].caption := FicIni.ReadString('Element','Utilitaires', caption);
     
       AfficheNomsBoutons;// procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
     
      Screen.Cursor:=crHourGlass;  // pour drag drop
      Combien:=-1;                // pour drap drop
    	for x:=0 to 16 do  // Installer les programmes drap drop   - maximum 15 icones
    begin
      if FicIni.ReadString('Programmes',IntToStr(x),'')<>''
      then AjouterProg;
      notifyStruc.cbSize:=SizeOf(notifyStruc);  // code relatif à structure icone
      notifyStruc.Wnd:=Handle;
      notifyStruc.uID:=1;
      NotifyStruc.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      { On verra WM_MYMESSAGE plus tard }
      NotifyStruc.uCallbackMessage := WM_MYMESSAGE;
      { Definit que l'icone de l'application sera l'icone par défaut }
      NotifyStruc.hIcon :=  Application.Icon.Handle;
      { Définir l'Hint de l'icône, c-a-d le texte qui sera affiché quand la souris reste longtemps dessus }
      hinte:='Cliquez moi pour ouvrir menu ListLog !';
      for j:=0 to length(hinte)-1 do NotifyStruc.szTip[j] := hinte[j+1];
    	NotifyStruc.szTip[length(hinte)]:=#0;
    	 Shell_NotifyIcon(NIM_ADD,@NotifyStruc);//ajoute la petite icône dans la barre des taches
    	   end;
          Screen.Cursor:=crDefault;// fin installation programmes
         end;
     
     
    {PERMET D'ENREGISTRER LES PARAMETRES DES OPTIONS RENOMMER LA FICHE
    DANS LE FICHIER .ini}
    procedure TAccueil.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    	  FicIni.WriteString('Element','Bureautique', Logiciels1.Items[0].caption);
    	  FicIni.WriteString('Element','Base de données', Logiciels1.Items[2].caption);
    	  FicIni.WriteString('Element','Disque dur', Logiciels1.Items[4].caption);
    	  FicIni.WriteString('Element','Divers', Logiciels1.Items[6].caption);
    	  FicIni.WriteString('Element','Gestion perso', Logiciels1.Items[8].caption);
    	  FicIni.WriteString('Element','Graphisme', Logiciels1.Items[10].caption);
    	  FicIni.WriteString('Element','Internet', Logiciels1.Items[13].caption);
    	  FicIni.WriteString('Element','Jeux', Logiciels1.Items[15].caption);
    	  FicIni.WriteString('Element','Mp3', Logiciels1.Items[17].caption);
    	  FicIni.WriteString('Element','Programmation Applications', Logiciels1.Items[19].caption);
    	  FicIni.WriteString('Element','Programmation HTML', Logiciels1.Items[21].caption);
        FicIni.WriteString('Element','Utilitaires', Logiciels1.Items[23].caption);
      if (@NotifyStruc<>NIL) then   //retire la petite icône de la barre des taches
    	   Shell_NotifyIcon(NIM_DELETE,@NotifyStruc);
     
           FicIni.Free;
      if bReload then
        Begin
    //      Showmessage('Redémarrage !');
          ShellExecute(0,'OPEN','ListLog.exe', Nil, Nil, SW_SHOW);
    //      Showmessage('Redémarrage Fait');
        End ;
     
    end;
     
    procedure TAccueil.Imprimer1Click(Sender: TObject);
    var i: integer;
    begin
    if PrintDialog1.Execute then begin
    	  print;
    if (PrintDialog1.Copies > 1) then
       for i:= 1 to PrintDialog1.Copies - 1 do
         Print;
    end;
    end;
     
    procedure TAccueil.Fermerdfinitivement1Click(Sender: TObject);
    begin
         Close; // Fermer la fiche depuis Menu Pop
    end;
     
    procedure TAccueil.MontrerappliClick(Sender: TObject);
    begin
         Show; // Rend visible l'application depuis icone MenuPop dans barre des taches
    end;
     
    procedure TAccueil.CacherappliClick(Sender: TObject);
    begin
         Hide;// Fait disparaitre l'application depuis icône MenuPop dans barre des tâches
    end;
     
    {==============================================================}
    {solution en créant un raccourci dans le dossier               }
    {c:\windows\Menu Démarrer\Programmes\démarrage                 }
    {==============================================================}
     
    {fonction qui permet de créer un raccourci}
    procedure CreFicLien(FicSource, FicRaccourci :string);
    var
      PersistFile : IPersistFile;
      ShellLink : IShellLink;
      RaccourciWC : array[0..MAX_PATH] of WideChar;
    begin
      if UpperCase(extractFileExt(FicRaccourci))<>'.LNK' then
      FicRaccourci:=FicRaccourci+'.lnk';
      ShellLink:=CreateComObject(CLSID_ShellLink) as IShellLink;
      ShellLink.QueryInterface(IPersistFile, PersistFile);
      ShellLink.SetDescription('');
      ShellLink.SetPath(PChar(FicSource));
      ShellLink.SetShowCmd(SW_SHOW);
      MultiByteToWideChar(CP_ACP, 0, PChar(FicRaccourci), -1, @RaccourciWC, MAX_PATH);
      PersistFile.Save(RaccourciWC, true);
    end;
     
    {permet obtenir le nom du dossier qui contient les raccourcis sur les programmes qui sont en AutoRun}
    function DossierStartUp:String; // obtenir le nom du dossier qui contient les raccourcis sur les programmes qui sont en AutoRun
    Var Reg:TRegistry;
    begin
      Reg:=TRegistry.Create;
      Reg.RootKey:=HKEY_CURRENT_USER;
      Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',false);
      result:=Reg.ReadString('StartUp')+'\';
      Reg.free;
    end;
     
    {rend un programme Autorun par ajout d'un raccourci}
    procedure AutoRunRaccourci(FichierADemarrer:string);
    begin
      if MessageDlg('Ajouter un raccourci: vous souhaitez mettre le programme '+ FichierADemarrer+' en Autorun',
    				 mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    	 CreFicLien(FichierADemarrer, DossierStartUp+ExtractFileName(FichierADemarrer));
    end;
     
    {éfface le raccourci pour ne plus mettre le programme en autorun}
    procedure AutoRunSuppression(FichierADemarrer:string);
    begin
      if MessageDlg('Supprimer un raccourci: vous souhaitez ne plus mettre le programme '+ FichierADemarrer+' en Autorun',
    				 mtConfirmation, [mbYes, mbNo], 0) = mrYes then
          deleteFile(DossierStartUp+ExtractFileName(FichierADemarrer)+'.lnk');
    end;
     
    { PROCEDURES BOUTONS POUR OPTIONS ECRITES CI-DESSUS }
     
    {Appelle la boite de dialogue d'ouverture fichier}
    procedure TAccueil.Parcourir1Click(Sender: TObject);
    begin
         if Open.Execute then Editchemin.Text:=Open.FileName;
    end;
     
    // Ajout d'un raccourci
    procedure TAccueil.Button3Click(Sender: TObject);
    begin
    	  AutoRunRaccourci(Editchemin.Text);
    end;
     
    // Suppression d'un raccourci
    procedure TAccueil.Button4Click(Sender: TObject);
    begin
    	  AutoRunSuppression(Editchemin.Text);
    end;
     
    { =============== FIN DES PROCEDURES BOUTONS  ============== }
    {Procédures pour ouvrir Fiches LOGICIELS via Menu Main}
    procedure TAccueil.Bureautique1Click(Sender: TObject);
    begin
    //	   bureautique.show;  //  pour ouvrir fiche bureautique
    end;
     
    procedure TAccueil.Basededonnes1Click(Sender: TObject);
    begin
    //	  basededonnees.show;
    end;
     
    procedure TAccueil.Disquedur1Click(Sender: TObject);
    begin
    //	   disquedur.show;
    end;
     
    procedure TAccueil.Divers1Click(Sender: TObject);
    begin
    //      divers.show;
    end;
     
    procedure TAccueil.Gestionperso1Click(Sender: TObject);
    begin
    //      gestionperso.show;
    end;
     
    procedure TAccueil.Graphisme1Click(Sender: TObject);
    begin
    //	   graphisme.show;
    end;
     
    procedure TAccueil.Internet1Click(Sender: TObject);
    begin
    //	   internet.show;
    end;
     
    procedure TAccueil.Jeux1Click(Sender: TObject);
    begin
    //      jeux.show;
    end;
     
    procedure TAccueil.Mp31Click(Sender: TObject);
    begin
    //      mp3.show;
    end;
     
    procedure TAccueil.ProgrammationAppli1Click(Sender: TObject);
    begin
    //	   programmationapplications.show;
    end;
     
    procedure TAccueil.ProgrammationHTML1Click(Sender: TObject);
    begin
    //	   programmationhtml.show;
    end;
     
    procedure TAccueil.Utilitaires1Click(Sender: TObject);
    begin
    //      utilitaires.show;
    end;
     
    // Procédures pour ouvrir Fiches LOGICIELS via Click Boutons
    procedure TAccueil.Btlog1Click(Sender: TObject);
    begin
    // bureautique.show;  //  pour ouvrir fiche bureautique
    end;
     
    procedure TAccueil.Btlog2Click(Sender: TObject);
    begin
    // basededonnees.show;
    end;
     
    procedure TAccueil.Btlog3Click(Sender: TObject);
    begin
    // disquedur.show;
    end;
     
    procedure TAccueil.Btlog4Click(Sender: TObject);
    begin
    // divers.show;
    end;
     
    procedure TAccueil.Btlog5Click(Sender: TObject);
    begin
    // gestionperso.show;
    end;
     
    procedure TAccueil.Btlog6Click(Sender: TObject);
    begin
    // graphisme.show;
    end;
     
    procedure TAccueil.Btlog7Click(Sender: TObject);
    begin
    //  internet.show;
    end;
     
    procedure TAccueil.Btlog8Click(Sender: TObject);
    begin
    //  jeux.show;
    end;
     
    procedure TAccueil.Btlog9Click(Sender: TObject);
    begin
    //  mp3.show;
    end;
     
    procedure TAccueil.Btlog10Click(Sender: TObject);
    begin
    // programmationapplications.show;
    end;
     
    procedure TAccueil.Btlog11Click(Sender: TObject);
    begin
    //   programmationhtml.show;
    end;
     
    procedure TAccueil.Btlog12Click(Sender: TObject);
    begin
    //   utilitaires.show;
    end;
     
     
    {FIN des procédures pour ouvrir les fiches}
     
    {CODES pour restaurer les noms des fiches LOGICIELS par défaut}
    procedure TAccueil.Restaurer1Click(Sender: TObject);
    begin
    if MessageDlg('Etes-vous sur de vouloir restaurer les noms des fiches LOGICIELS par défaut ? '
    +#13+'Vos paramétres personnalisés seront supprimés !! ' ,
    mtWarning, [mbYes, mbNo],0) = mryes then
    Logiciels1.items[0].caption := 'Bureautique'; // fiche 1 bureautique
    Logiciels1.items[2].caption := 'Base de données'; // fiche 2 base de données
    Logiciels1.items[4].caption := 'Disque Dur'; // fiche 3 disque dur
    Logiciels1.items[6].caption := 'Divers'; // fiche 4 divers
    Logiciels1.items[8].caption := 'Gestion perso'; // fiche 5 gestion perso
    Logiciels1.items[10].caption := 'Graphisme'; // fiche 6 graphisme
    Logiciels1.items[13].caption := 'Internet'; // fiche 7 internet
    Logiciels1.items[15].caption := 'Jeux'; // fiche 8 jeux
    Logiciels1.items[17].caption := 'Mp3'; // fiche 9 mp3
    Logiciels1.items[19].caption := 'Applications'; // fiche 10 programmation Application
    Logiciels1.items[21].caption := 'Programmation HTML'; // fiche 11 programmation Html
    Logiciels1.items[23].caption := 'Utilitaires'; // fiche 12 utilitaires
       begin
       AfficheNomsBoutons; // procedure perso - permet d'afficher le noms des fiches à l'identique sur les boutons
       LibelleRenomItems; // procedure perso - permet d'afficher le libellé des options pour renommer à l'identique aux fiches
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
    end;
    end;
     
    //=== DEBUT PROCEDURES POUR RENOMMER FICHES LOGICIELS PAR UTILISATEUR ==//
     
     procedure TAccueil.RenommerbureautiqueClick(Sender: TObject);
    begin
    	 if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[0].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[0].caption);
    // bureautique.caption := Logiciels1.Items[0].caption;
    		end;
        Logiciels1.items[1].Caption :='Renommer fiche ' + Logiciels1.Items[0].caption;
        Btlog1.caption :=Logiciels1.Items[0].caption + ' (F1)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerbasedonneesClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[2].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[2].caption);
    // basededonnees.caption := Logiciels1.Items[2].caption;
    		end;
        Logiciels1.items[3].Caption :='Renommer fiche ' + Logiciels1.Items[2].caption;
        Btlog2.caption :=Logiciels1.Items[2].caption + ' (F2)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerdisquedurClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[4].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[4].caption);
    // disquedur.caption := Logiciels1.Items[4].caption;
    		end;
         Logiciels1.items[5].Caption :='Renommer fiche ' + Logiciels1.Items[4].caption;
         Btlog3.caption :=Logiciels1.Items[4].caption + ' (F3)' ;
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerdiversClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[6].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[6].caption);
    // divers.caption := Logiciels1.Items[6].caption;
    		end;
         Logiciels1.items[7].Caption :='Renommer fiche ' + Logiciels1.Items[6].caption;
         Btlog4.caption :=Logiciels1.Items[6].caption + ' (F4)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommergestionpersoClick(Sender: TObject);
    begin
         if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[8].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[8].caption);
     // gestionperso.caption := Logiciels1.Items[8].caption;
    		end;
         Logiciels1.items[9].Caption :='Renommer fiche ' + Logiciels1.Items[8].caption;
         Btlog5.caption :=Logiciels1.Items[8].caption + ' (F5)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommergraphismeClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[10].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[10].caption);
    // graphisme.caption := Logiciels1.Items[10].caption;
    		end;
         Logiciels1.items[11].Caption :='Renommer fiche ' + Logiciels1.Items[10].caption;
         Btlog6.caption :=Logiciels1.Items[10].caption + ' (F6)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerinternetClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[13].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[13].caption);
    // internet.caption := Logiciels1.Items[13].caption;
    		end;
       Logiciels1.items[14].Caption :='Renommer fiche ' + Logiciels1.Items[13].caption;
       Btlog7.caption :=Logiciels1.Items[13].caption + ' (F7)';
       LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
       Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerjeuxClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[15].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[15].caption);
    // jeux.caption := Logiciels1.Items[15].caption;
    		end;
         Logiciels1.items[16].Caption :='Renommer fiche ' + Logiciels1.Items[15].caption;
         Btlog8.caption :=Logiciels1.Items[15].caption + ' (F8)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.Renommermp3Click(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[17].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[17].caption);
    // mp3.caption := Logiciels1.Items[17].caption;
    		end;
        Logiciels1.items[18].Caption :='Renommer fiche ' + Logiciels1.Items[17].caption;
        Btlog9.caption :=Logiciels1.Items[17].caption + ' (F9)';
        LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerProgAppliClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[19].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[19].caption);
    // programmationapplications.caption := Logiciels1.Items[19].caption;
    		end;
         Logiciels1.items[20].Caption :='Renommer fiche ' + Logiciels1.Items[19].caption;
         Btlog10.caption :=Logiciels1.Items[19].caption + ' (F10)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerProghtmlClick(Sender: TObject);
    begin
    	  if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[21].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[21].caption);
    // programmationhtml.caption := Logiciels1.Items[21].caption;
    		end;
         Logiciels1.items[22].Caption :='Renommer fiche ' + Logiciels1.Items[21].caption;
         Btlog11.caption :=Logiciels1.Items[21].caption + ' (F11)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
        Sauvernomfiches;
    end;
     
    procedure TAccueil.RenommerutilitairesClick(Sender: TObject);
    begin
         if MessageDlg('Voulez vous changer le nom de cette fiche ?', mtconfirmation, [mbYes, mbNo],0) =mrYes then
    		begin
    Logiciels1.items[23].Caption := InputBox('Changer le nom de cet élément menu','Saisissez le nouveau nom (maximum 18 caractères)', Logiciels1.items[23].caption);
    // utilitaires.caption := Logiciels1.Items[23].caption;
    		end;
         Logiciels1.items[24].Caption :='Renommer fiche ' + Logiciels1.Items[23].caption;
         Btlog12.caption :=Logiciels1.Items[23].caption + ' (F12)';
         LimiterItems; // procedure perso - permet de limiter en nombre de caractéres dans items.Caption
         Sauvernomfiches;
    end;
    //= FIN DES PROCEDURES POUR RENOMMER FICHES LOGICIELS =//
     
    {PROCEDURES POUR DRAP DROP RACCOURCIS}
    procedure TAccueil.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
    if Key=vk_Escape then Close;
    end;
     
    {AJOUTER UN PROGRAMME EN RACCOURCI}
    procedure TAccueil.SpeedButton1Click(Sender: TObject);
    begin
     if Open.Execute then
       begin
       FicIni.WriteString('Programmes',IntToStr(Combien+1),Open.FileName);
       AjouterProg;
    	end;
    end;
     
    {Faire apparaitre les programmes}
    Procedure TAccueil.AjouterProg;
    var
    Limage:TObject;
    Icone:TIcon;
    LeProg:String;
    begin
    Inc(Combien);
    // Nom du programme
    LeProg:=FicIni.ReadString('Programmes',IntToStr(Combien),'');
    // Créer l'image qui recevra l'icone du programme.
    // ça peut être un bouton ou tout ce que tu veux.
    Icone:=TIcon.Create;
    Limage:=Timage.Create(self);
    TImage(Limage).Parent:= Accueil;
    TImage(Limage).Top:=70; // Distance à partir du haut de la fiche (données d'origine = 50)
    TImage(Limage).Left:=Combien*(32+15)+15;
    TImage(Limage).AutoSize:=True;
    TImage(Limage).Picture.Icon:=Imaj.Picture.Icon;
    TImage(Limage).OnMouseDown:=ImageMouseDown;
    TImage(Limage).Hint:='N''existe PLUS !!';
    TImage(Limage).ShowHint:=True;
    TImage(Limage).Name:='Image'+IntToStr(Combien);
    TImage(Limage).Tag:=Combien;
       // Si le Programme existe BIEN alors afficher SON icone...
       if FileExists(LeProg) then
       begin
       // Récupérer l'icone.
       Icone.Handle:=ExtractIcon(Handle,Pchar(LeProg),0);
          if Icone.Handle<>0
          then TImage(Limage).Picture.Icon:=Icone;
    	TImage(Limage).Hint:=ExtractFileName(LeProg);
    	end
       // Sinon afficher Image Par Defaut.
    	else TImage(Limage).Picture.Assign(Image.Picture);
    Icone.Free;
    end;
     
    {Lancer le programme ou supprimer le programme}
    procedure TAccueil.ImageMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
    Prog, Chemin:String;
    Objet:TObject;
    Memoire:TStringList;
    W:Word;
    begin
    	if ssCtrl in Shift then   // Si Ctrl Appuyé, on va Draguer !!!
       begin
    	Timage(Sender).BeginDrag(True);
       Exit;
    	end;
    Prog:=Ficini.ReadString('Programmes',IntToStr(Timage(Sender).Tag),'');
       if Button=mbLeft then // Click Gauche, Démmarer le programme.
       begin
       Screen.Cursor:=crHourGlass;
       // ShowMessage(IntToStr(Timage(Sender).Tag)+'"'+Prog+'"');
       Chemin:=ExtractFilePath(Prog);
       W:=ShellExecute(Handle,'OPEN',Pchar(Prog),Nil,PChar(Chemin),sw_show);
       Screen.Cursor:=crDefault;
        if W<33
          then ShowMessage('Impossible de lancer: '+Prog);
    	end;
    	 if Button=mbRight then // Supprimer un programme:
    	begin
     // Si demande de suppression , demander confirmation.
    	 if x<>-500 then
    		if MessageDlg('Supprimer  '+Prog+' ???',mtWarning,[mbYes,mbNo],0)=mrNo
    		then Exit;
    	// Supprimer le programme
       FicIni.WriteString('Programmes',IntToStr(Timage(Sender).Tag),'');
    	Memoire:=TStringList.Create; //Mettre en mémoire les AUTRES programmes.
    	   for x:=0 to Combien  do
          begin
             if FicIni.ReadString('Programmes',IntToStr(x),'')<>''
             then Memoire.Add(FicIni.ReadString('Programmes',IntToStr(x),''));
          Objet:=FindComponent('Image'+IntToStr(x));  // Supprimer les images
    	   Timage(Objet).Free;
          end;
    	FicIni.EraseSection('Programmes'); // Effacer la section Programmes du fichier Ini
       Combien:=-1;
          for x:=0 to Memoire.Count-1 do
          begin
          // Recréer la section Programmes du fichier Ini
          FicIni.WriteString('Programmes',IntToStr(x),Memoire[x]);
    	   // Réinstaller les programmes restant.
          AjouterProg;
          end;
       Memoire.Free;
       end;
    end;
     
    // Effacer tous les raccourcis programmes (pour libérer place pour drag and drop)
    procedure TAccueil.SpeedBtnEffaceProgClick(Sender: TObject);
    begin
     if MessageDlg('Voulez vous vraiment effacer les raccourcis programmes de cette fiche ?' + #13 + '               ! un redémarrage de LISTLOG est impératif !', mtwarning, [mbYes, mbNo],0) =mrYes then
    		begin
          FicIni.EraseSection('Programmes'); // Effacer la section Programmes du fichier Ini
          bReload := True;  // redemarrage ListLog
          Close ;
        end;
    end;
     
    procedure TAccueil.Button1Click(Sender: TObject);
    begin
       Combien := Combien + 1 ;
       FicIni.WriteString('Programmes',IntToStr(Combien),'Prog'+IntToStr(Combien)) ;
       ShowMessage('Programme '+IntToStr(Combien)+ ' ajouté dans FicIni') ;
    end;
     
    end.
    A+
    Charly

  10. #30
    Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2006
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Tarn et Garonne (Midi Pyrénées)

    Informations professionnelles :
    Secteur : Services à domicile

    Informations forums :
    Inscription : Octobre 2006
    Messages : 74
    Points : 50
    Points
    50
    Par défaut
    J'ai essayé avec ton code mais le problème est toujours le même.

    Si j'efface la section Programmes à vide (c'est à dire s'il n'y a pas d’icône sur la fiche), le redémarrage fonctionne très bien mais si il y a un ou plusieurs icônes sur la fiche, ils sont bien effacés mais le programme ne redémarre pas ??

    Comme je ne vois pas de solution, je pense que je vais plutôt ajouter un bouton qui servira de redémarrage manuel au lieu d'inclure cette option avec la procédure d'effacement de la section

    Merci Charly pour ton aide et tes conseils

    A+
    Beauserge

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. redémarrer une application
    Par aroussi_sanaa dans le forum Général Java
    Réponses: 3
    Dernier message: 11/09/2009, 00h54
  2. Réponses: 16
    Dernier message: 13/10/2008, 17h32
  3. Redémarrer une application
    Par rangdalf dans le forum Windows Forms
    Réponses: 3
    Dernier message: 15/03/2008, 07h13
  4. redémarrer une application
    Par reloadead dans le forum Langage
    Réponses: 5
    Dernier message: 20/06/2007, 15h12
  5. Comment redémarrer une application?
    Par liv dans le forum MFC
    Réponses: 5
    Dernier message: 24/01/2005, 14h40

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