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

VB.NET Discussion :

inclure un console dans une winform


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Inscrit en
    Avril 2010
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 2
    Par défaut inclure un console dans une winform
    Bonjour, je travaille avec vbnet 2008. Je voudrais savoir si c'est possible d' inclure une console dans un formulaire. Merci

  2. #2
    Expert confirmé Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Par défaut
    Quel est le but ?
    a) récupérer les instructions Console de ton programme ?
    b) lancer un programme console et rediriger ses sorties vers un control (Textbox, Listbox, ...) de ton appli ?

    pour b), voir ci-dessous :
    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
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
     
    namespace CGStdOutput
    {
      public partial class Form1 : Form
      {
         public Form1( ) { InitializeComponent( ); }
     
         private Process _process = null;
     
         private void _btnRun_Click( object sender, EventArgs e )
         {
          _btnRun.Enabled = false;
          if( null != _process ) _process.Dispose( );
          _process = new Process( );
          _process.StartInfo.FileName = "Le_nom_du_proframe_console.exe";
          _process.StartInfo.UseShellExecute = false;
          _process.EnableRaisingEvents = true;
          _process.StartInfo.CreateNoWindow = true;
          _process.StartInfo.RedirectStandardOutput = true;
          _process.OutputDataReceived+=new DataReceivedEventHandler
                                       (OnOutputDataReceived);
          _process.Exited += new EventHandler( OnProcessExited );
          _process.Start( );
          _process.BeginOutputReadLine( );
         }
     
       /// Standard Output event handler - called when standard output text is    
       /// available fromthe launched process.
       /// This event handler gets called from a different thread than the main
       /// UIthread. As such we need to use a delegate to access the UI thread.
       void OnOutputDataReceived( object sender, DataReceivedEventArgs e )
       { // We use an anonymous delegate here
         if( _listBox.InvokeRequired && !String.IsNullOrEmpty( e.Data ) )
           _listBox.Invoke( new MethodInvoker( 
                        delegate( ) { _listBox.Items.Add( e.Data ); } ) );
       }
     
        /// Called when process exits
        void OnProcessExited( object sender, EventArgs e )
        { // We use an anonymous delegate here
          if( _btnRun.InvokeRequired )
            _btnRun.Invoke( new MethodInvoker(
                    delegate( ) { _btnRun.Enabled = true; } ) );
        }
      }
    }

Discussions similaires

  1. Inclure un programme externe dans une winform
    Par furtif1 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 21/05/2010, 23h17
  2. Inclure code XML dans une page HTML ?
    Par kpatoulu dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 24/10/2005, 14h59
  3. Inclure un SELECT dans une requète Update
    Par carolinebelle dans le forum Langage SQL
    Réponses: 2
    Dernier message: 19/07/2005, 14h19
  4. Réponses: 1
    Dernier message: 19/08/2004, 12h52
  5. [XSLT] inclure du XSL dans une balise html
    Par iaa dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 05/08/2002, 15h57

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