Jump to content

Ajutor idee .net Form

Recommended Posts


Am si eu nevoie sa rulez un terminal intr o aplicatie de tip Form.
Pentru a intelege mai usoara idee, o sa fac o mica schema.
As vrea :
Un exe ( acel exe as fie full screen, inclusiv sa acopere bara windows, asta am rezolvat cu
        Call CenterToScreen()
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.WindowState = FormWindowState.Maximized
        Form2.Visible = True)

In acel exe sa existe doar un buton de exit undeva sus iar in partea de mijloc sa arate cam asa:



In spatele cmd-ului fiind aplicatia form, iar in fata cmd-ul.

Se poate implementa direct acel cmd in form? exista vreo modalitate de "crop" a form-ului in asa fel sa pot utiliza cmd ul, dar sa fie 'lock' in acel form, eventual cmd ul sa nu aiba acele optiuni de minimize, close, fullscreen.

Sau aveti alta idee?

Exemplul cu cmd ul este doar pt a intelege mai bine ce vreau sa spun, in esenta am nevoie sa rulez un exe intr un form, dar sa se vada doar o parte din acel exe...

Link to comment
Share on other sites

  • Active Members
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace MyNamespace
    public partial class MyForm : Form
        private Process cmdProcess;

        public MyForm()

        private void InitializeCmd()
            cmdProcess = new Process();
            cmdProcess.StartInfo.FileName = "cmd.exe";
            cmdProcess.StartInfo.CreateNoWindow = true;
            cmdProcess.StartInfo.UseShellExecute = false;
            cmdProcess.StartInfo.RedirectStandardInput = true;
            cmdProcess.StartInfo.RedirectStandardOutput = true;
            cmdProcess.StartInfo.RedirectStandardError = true;

            // ascunde bara de titlu si butoanele
            cmdProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            StreamWriter cmdStreamWriter = cmdProcess.StandardInput;
            StreamReader cmdStreamReader = cmdProcess.StandardOutput;
            StreamReader cmdErrorReader = cmdProcess.StandardError;

            // adaugă controlul la form
            TextBox cmdControl = new TextBox();
            cmdControl.Multiline = true;
            cmdControl.Dock = DockStyle.Fill;
            cmdControl.ScrollBars = ScrollBars.Vertical;
            cmdControl.Font = new System.Drawing.Font("Courier New", 10);

            // afișează output-ul din terminal în control
            cmdStreamReader.BaseStream.BeginRead(new byte[1], 0, 0, null, null);
            cmdStreamReader.DataReceived += (s, e) =>
                if (!string.IsNullOrEmpty(e.Data))
                    cmdControl.Invoke(new Action(() =>
                        cmdControl.AppendText(e.Data + Environment.NewLine);

            // citește input de la utilizator și trimite la terminal
            cmdControl.KeyDown += (s, e) =>
                if (e.KeyCode == Keys.Enter)

            // afișează erorile în consolă
            cmdErrorReader.BaseStream.BeginRead(new byte[1], 0, 0, null, null);
            cmdErrorReader.DataReceived += (s, e) =>
                if (!string.IsNullOrEmpty(e.Data))

        private void MyForm_FormClosing(object sender, FormClosingEventArgs e)


  • Like 1
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...