IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Delphi Discussion :

Bug avec une ancienne application D6 et Windows 11


Sujet :

Delphi

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 585
    Détails du profil
    Informations personnelles :
    Âge : 72
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 585
    Par défaut Bug avec une ancienne application D6 et Windows 11
    Bonjour à toutes et à tous,

    J'essaye de comprendre le pourquoi sur cette source qui lit un fichier .mid qui fonctionnait avant et que maintenant au chargement du fichier j'ai un message "indice de liste hors limites".

    A toutes fin voici le code :

    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
     
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Gauges, StdCtrls, ExtCtrls, ComCtrls, MMSystem;
     
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Gauge1: TGauge;
        Timer1: TTimer;
        OpenDialog1: TOpenDialog;
        StatusBar1: TStatusBar;
        procedure Timer1Timer(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        Duree: String;
      protected
        function ExtractFileName(aFilename:String; WithExt: Boolean):String;
        function SecondesToJHMS(Time: Double): String;
      public
        procedure PlayMidi();
        procedure StopMidi();
      end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.dfm}
     
    function TForm1.ExtractFileName(aFilename:String; WithExt: Boolean):String;
    var i: Integer;
    begin
      aFileName := SysUtils.ExtractFileName(aFileName);
      if WithExt then Result := aFileName
      else
      begin
        Result := '';
        i :=0;
        while (aFileName[i] <> '.') do
        begin
         Result := Result + aFileName[i];
         Inc(i);
        end;
        Result := Trim(Result);
      end;
    end;
     
    function TForm1.SecondesToJHMS(Time: Double): String;
    var
      base,
      res,
      r: integer;
      SL: TStringList;
      I: integer;
      Num: Integer;
    begin
      Result := '';
      base := 60;
      Num := Trunc(Time);
      if num <= 0 then Result := '00';
      SL := TStringList.Create;
      While(Num>0) do
      begin
        res := Num div base;
        r := Num mod base;
        Num := res;
        SL.Add(IntToStr(r));
      end;
      for I := SL.Count -1 DownTo 0 do
      begin
        if (I = 0) then  Result := Result + Format('%.2u',[trunc( StrToInt(SL[I]) )])
        else
          Result := Result + Format('%.2u',[trunc( StrToInt(SL[I]) )]) +':';
      end;
      SL.Free;
    end;
     
     
    procedure  TForm1.PlayMidi();
    var
     TotalTime: array[0..128] of char;
     filename: String;
     
    begin
     if form1.Opendialog1.Execute then
     begin
       filename := form1.opendialog1.filename;
       MCISendString(PChar('close song'), nil, 0, 0);
       MCISendString(PChar('open ' + filename + ' alias song'),nil , 0, 0);
       MCISendString(PChar('set song time format ms'), 0, 0, 0);
       MCISendString(PChar('status song length'), TotalTime, 128, 0);
       MCISendString(PChar('play song'),nil, 0, 0);
     
       Gauge1.Progress := 0;
       Gauge1.MaxValue := strtoint(TotalTime);
       Timer1.Enabled := true;
     
       Duree := TrimRight(String(TotalTime));
       StatusBar1.Panels[0].Text := ExtractFileName(filename, False) + ' '
        + SecondesToJHMS(strtofloat(Duree) /1000);
       StatusBar1.Panels[1].Text := SecondesToJHMS(strtofloat(Duree) /1000);
     end;
    end;
     
    procedure  TForm1.StopMidi();
    begin
      Timer1.Enabled := false;
      MCISendString(PChar('stop song'), nil, 0, 0);
    end;
     
     
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      TimePos: array[0..128] of char;
    begin
      with Gauge1 do
      begin
        if progress < MaxValue then
        begin
          MCISendString(PChar('set song time format milliseconds'), nil, 0, 0);
          MCISendString(PChar('STATUS SONG POSITION'), TimePos, 128, 0);
          Gauge1.Progress := StrToInt(TimePos);
          StatusBar1.Panels[1].Text := SecondesToJHMS(strtofloat(Duree) /1000 );
          Duree := FloatToStr(strtofloat(Duree) - Timer1.Interval);
        end else Timer1.Enabled := False;
      end;
    end;
     
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      StopMidi();
    end;
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       PlayMidi();
    end;
     
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Timer1.Interval := 1000;
    end;
     
    end.
    Si quelqu'un a une solution merci d'avance la source en attache se compile bien.

    @+,

    cincap
    Fichiers attachés Fichiers attachés

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

Discussions similaires

  1. Bug avec une application sur Windows XP version anglaise
    Par QAYS dans le forum Bases de données
    Réponses: 8
    Dernier message: 22/06/2009, 09h23
  2. Faire communiquer Axapta(Dynamics Ax) avec une autre application
    Par Access Newbie dans le forum Microsoft Dynamics
    Réponses: 5
    Dernier message: 13/12/2007, 15h52
  3. Problème avec une fonction de GDK sous Windows !
    Par Franck.H dans le forum GTK+ avec C & C++
    Réponses: 9
    Dernier message: 08/06/2007, 13h57
  4. STL : Bug avec une list
    Par Winder dans le forum SL & STL
    Réponses: 1
    Dernier message: 10/05/2007, 04h03
  5. Projet lancé avec une autre application..COMMENT?
    Par zentaf dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 11/04/2007, 09h57

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