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 :

action dans listbox


Sujet :

Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif
    Homme Profil pro
    Electronicien
    Inscrit en
    Août 2008
    Messages
    376
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electronicien
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2008
    Messages : 376
    Par défaut action dans listbox
    Bonjour,

    Je suis en train d'écrire une petite application permettant l'installation d'une successions de programmes en fonction de différents critères (autorisation, configuration, poste, version windows).

    Pour l'instant j'arrive à sélectionner les programmes à installer en fonction des critères cités ci-dessus et à les lister dans une listbox.

    j'aimerai deux mode d'installation des applications , un mode automatique et un mode manuel, pour l'instant j'essais de faire le mode manuel en exécutant l'installation en cliquant 2 fois sur la ligne concernant le programme, seulement en faisant OnDblClick=AUTOClick et apparemment ça m'exécute toute la liste de programme et pas seulement le programme que je souhaite installer.

    Comment puis-je faire pour exécuter seulement la ligne double cliqué dans ma listbox ?

    Merci

  2. #2
    Membre très actif
    Homme Profil pro
    Electronicien
    Inscrit en
    Août 2008
    Messages
    376
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electronicien
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2008
    Messages : 376
    Par défaut
    Quelqu'un aurai une suggestion

  3. #3
    Membre Expert

    Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2002
    Messages
    1 296
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2002
    Messages : 1 296
    Par défaut
    Quel est le code de AutoClick?

    La ligne sélectionnée peut être retrouvé grâce à la propriété ItemIndex de la ListBox.

  4. #4
    Membre très actif
    Homme Profil pro
    Electronicien
    Inscrit en
    Août 2008
    Messages
    376
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electronicien
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2008
    Messages : 376
    Par défaut
    voici mon 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
    155
    156
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ShellAPI;
     
    type
      TForm1 = class(TForm)
        AUTO: TButton;
        Label1: TLabel;
        GroupBox1: TGroupBox;
        Portable: TRadioButton;
        Bureau: TRadioButton;
        GroupBox2: TGroupBox;
        Seven: TRadioButton;
        XP: TRadioButton;
        ListBox1: TListBox;
        ENTER: TButton;
        ComboBox1: TComboBox;
        procedure AUTOClick(Sender: TObject);
        procedure PortableClick(Sender: TObject);
        procedure SevenClick(Sender: TObject);
        procedure BureauClick(Sender: TObject);
        procedure XPClick(Sender: TObject);
        procedure ENTERClick(Sender: TObject);
        procedure ComboBox1Change(Sender: TObject);
        procedure ListBox1Click(Sender: TObject);
      private
        { Déclarations privées }
      public
     
        { Déclarations publiques }
      end;
     
    var
    Form1: TForm1;
    port,sev,bur,wxp:boolean;
    teamviewer,Dropbox,Msql,ixxat,MPLAB,FTDI,IFM,VALENCE,VENSCO,InitMysql : integer;
    manu_teamviewer,manu_Dropbox,manu_Msql,manu_ixxat,manu_MPLAB,manu_FTDI,manu_IFM,manu_VALENCE,manu_VENSCO,manu_InitMysql : integer;
    niv:integer;
     
    implementation
     
    {$R *.dfm}
     
     
     
     
    procedure TForm1.AUTOClick(Sender: TObject);
    begin
     
     
    if (Dropbox=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Dropbox.exe',nil,Nil,SW_SHOWDEFAULT);
    if (Msql=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\mysql-5.5.1-m2-win32.msi',nil,Nil,SW_SHOWDEFAULT);
    if ((ixxat=1) and sev ) then ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\VCI_2_18_4_2308.exe',nil,Nil,SW_SHOWDEFAULT);
    if (((ixxat=1) and wxp ) or (manu_ixxat=1) ) then ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\vci216+sp2.exe',nil,Nil,SW_SHOWDEFAULT);
    if (MPLAB=1) then ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\MPLAB_IDE_v8_63\setup.exe',nil,Nil,SW_SHOWDEFAULT);
    if (FTDI=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\CDM_2.02.04.exe',nil,Nil,SW_SHOWDEFAULT);
    if (teamviewer=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\TeamViewer_Setup_fr-wv.exe',nil,Nil,SW_SHOWDEFAULT);
    if (IFM=1) then ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Maintenance\setup.exe',nil,Nil,SW_SHOWDEFAULT);
    if (VALENCE=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Module_Diag_XP_12.9.msi',nil,Nil,SW_SHOWDEFAULT);
    if (VENSCO=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Vansco_USB_DLA_Driver_V1.7.exe',nil,Nil,SW_SHOWDEFAULT);
    if (InitMysql=1) then  ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Vansco_USB_DLA_Driver_V1.7.exe',nil,Nil,SW_SHOWDEFAULT);
     
     
     
     
     
    end;
     
    procedure TForm1.PortableClick(Sender: TObject);
    begin
    port:=Portable.Checked;
    bur:=false;
     
    end;
     
    procedure TForm1.SevenClick(Sender: TObject);
    begin
     
    sev:=Seven.Checked;
    wxp:=false;
    end;
     
    procedure TForm1.BureauClick(Sender: TObject);
    begin
    bur:=Bureau.checked;
    port:=false;
     
    end;
     
    procedure TForm1.XPClick(Sender: TObject);
    begin
    wxp:=xp.checked;
    sev:=false;
    end;
     
     
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    niv:=StrToInt(combobox1.Text);
     
    end;
     
    procedure select();
    begin
     
     
      if ((port or bur) and (niv>=0) ) then  Dropbox:=1 else  Dropbox:=0;
      if (port and (niv>=0) ) then  Msql:=1 else  Msql:=0;
      if (port and (niv>=2) ) then  ixxat:=1 else  ixxat:=0;
      if (port and (niv>=3) ) then  MPLAB:=1 else  MPLAB:=0;
      if (port and (niv>=0) ) then  FTDI:=1 else  FTDI:=0;
      if (port and (niv>=0) ) then  teamviewer:=1 else  teamviewer:=0;
      if (port and (niv>=3) ) then  IFM:=1 else  IFM:=0;
      if (port and (niv>=3) ) then  VALENCE:=1 else VALENCE:=0;
      if (port and (niv>=3) ) then  VENSCO:=1 else  VENSCO:=0;
      if (port and (niv>=0) ) then  InitMysql:=1 else InitMysql:=0;
     
    end;
     
    procedure TForm1.ENTERClick(Sender: TObject);
    var
    MyList:TStringList;
     
    begin
    select();
    listbox1.Clear;
     
    MyList :=TStringList.Create;
     
    try
     
    if (Dropbox=1) then MyList.Add('Install Dropbox');
    if (Msql=1) then MyList.Add('Install Msql');
    if (ixxat=1) then MyList.Add('Install ixxat');
    if (MPLAB=1) then MyList.Add('Install MPLAB');
    if (FTDI=1) then MyList.Add('Install FTDI');
    if (teamviewer=1) then MyList.Add('Install teamviewer');
    if (IFM=1) then MyList.Add('Install IFM');
    if (VALENCE=1) then MyList.Add('Install VALENCE');
    if (VENSCO=1) then MyList.Add('Install VENSCO');
    if (InitMysql=1) then MyList.Add('Install InitMysql');
     
    begin
    ListBox1.Items.AddStrings(MyList);
    end;
     
    finally
    MyList.Free;
     
    end;
     
    end;
    en faite c'est dans" l'inspecteur d'objet" concernant la listbox1 , l'événement que j'ai mis OnBdlClick à AUTOclick j'avoue que je ne sais pas rélement ce que ça peu bien faire.

  5. #5
    Membre très actif
    Homme Profil pro
    Electronicien
    Inscrit en
    Août 2008
    Messages
    376
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electronicien
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2008
    Messages : 376
    Par défaut
    J'ai oublié la fin
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    procedure TForm1.ListBox1Click(Sender: TObject);
    begin
     
    if (listbox1.Items=('Install ixxat')) then manu_ixxat:=1;
     
    end;
     
    end.
    C'est d'ailleur à ce niveau la que je doit intervenir ?

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

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

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 041
    Par défaut
    Question Conne : Pourquoi ne pas utiliser InnoSetup, Install Shield si c'est pour automatiser l'installation de module dont dépend ton application ?

    Sinon, utilise une TCheckListBox, ou tu peux cocher et décocher des items
    Ton Bouton Auto lira les Checked[] pour savoir quel programme installé
    En Auto, tout est coché par défaut
    En Manuel, tu laisse le choix à l'utilisateur !

    Tu ne peux pas mettre AutoClick comme gestionnaire pour ta ListBox, le code n'est pas conçu pour gérer des items

    Tu dois gérer comme tu as commencé avec tes manu_ ...
    Mais faudrait que tu les utilises !



    Sinon, faudrait reprendre les bases de la programmation Delphi, il existe le type boolean qui sera plus pertinent que tes integer en valeur 0/1
    Cela complique la lecture du code (très mal indenté d'ailleurs)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    procedure TForm1.ListBox1Click(Sender: TObject);
    begin
     
    if (listbox1.Items=('Install ixxat')) then manu_ixxat:=1;
     
    end;
    Ce code ne compile même pas, lit donc la documentation au lieu d'inventer des syntaxes fantaisistes !

    tu dois plutôt écrire ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    procedure TForm1.ListBox1DblClick(Sender: TObject);
    begin
     
      if (listbox1.Items[ListBox1.ItemIndex]= 'Install Dropbox') then 
        ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\Dropbox.exe',nil,Nil,SW_SHOWDEFAULT)
      else if (listbox1.Items[ListBox1.ItemIndex]= 'Install ixxat') then
        ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\mysql-5.5.1-m2-win32.msi',nil,Nil,SW_SHOWDEFAULT)
      else if (listbox1.Items[ListBox1.ItemIndex]= 'Install Msql') then
        ShellExecute(Handle,'open','\\pvifiler1.pvi.local\Commun\BEE\Install_SAV\VCI_2_18_4_2308.exe',nil,Nil,SW_SHOWDEFAULT)
      else if ...
     
    end;
    Evidemment, avec une gestion de la propriétés Objects[] (issu de la TStrings) via la propriété Items du TListBox, on pourrait avoir un code nettement plus élégant comme dans le sujet Combobox - renvoyer une valeur
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

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

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

Discussions similaires

  1. Centrer un texte dans ListBox, dans OnDrawItem
    Par Sunchaser dans le forum C++Builder
    Réponses: 3
    Dernier message: 21/03/2005, 01h46
  2. [JSP]meme action dans 2 jsp
    Par zach dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 24/02/2005, 08h34
  3. Image dans listbox
    Par jabaka dans le forum C++Builder
    Réponses: 4
    Dernier message: 19/02/2005, 22h35
  4. [C#] Drop dans ListBox
    Par Freeman166 dans le forum Windows Forms
    Réponses: 8
    Dernier message: 26/01/2005, 22h46
  5. [C#] Déclencher action dans Repeater avec LinkButton
    Par globeriding dans le forum ASP.NET
    Réponses: 13
    Dernier message: 13/05/2004, 15h29

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