Click here to Skip to main content
15,352,155 members
Home / Discussions / C#
   

C#

 
GeneralRe: GDI + package help Pin
Heath Stewart6-Jan-04 17:27
protectorHeath Stewart6-Jan-04 17:27 
GeneralUsing a txtbox as output window Pin
Melanius6-Jan-04 11:10
MemberMelanius6-Jan-04 11:10 
GeneralRe: Using a txtbox as output window Pin
hxxbin6-Jan-04 11:26
Memberhxxbin6-Jan-04 11:26 
GeneralRe: Using a txtbox as output window Pin
Melanius6-Jan-04 11:38
MemberMelanius6-Jan-04 11:38 
GeneralRe: Using a txtbox as output window Pin
Kentamanos6-Jan-04 11:41
MemberKentamanos6-Jan-04 11:41 
GeneralRe: Using a txtbox as output window Pin
Melanius6-Jan-04 13:17
MemberMelanius6-Jan-04 13:17 
GeneralRe: Using a txtbox as output window Pin
Heath Stewart6-Jan-04 17:21
protectorHeath Stewart6-Jan-04 17:21 
GeneralRe: Using a txtbox as output window Pin
leppie6-Jan-04 13:58
Memberleppie6-Jan-04 13:58 
Just drop this on your form, somewhere visible, and use Console as normal.
#region License
/*	Xacc .net CLR Toolkit
	Copyright (C) 2003-2004  leppie @ ataris.co.za
*
*	This program is free software; you can redistribute it and/or modify
*	it under the terms of the GNU General Public License as published by
*	the Free Software Foundation; either version 2 of the License, or
*	(at your option) any later version.
*
*	This program is distributed in the hope that it will be useful,	
*	but WITHOUT ANY WARRANTY; without even the implied warranty of	
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	
*	GNU General Public License for more details.
*	You should have received a copy of the GNU General Public License
*	along with this program; if not, write to the Free Software	
*	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
#endregion

using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace Xacc.Controls
{
  public class WinConsole : System.Windows.Forms.RichTextBox
  {
    class MessageWriter : TextWriter
    {
      public override System.Text.Encoding Encoding
      {
        get	{	return System.Text.Encoding.Default;}
      }

      public delegate void MessageWriterHandler(string text);

      MessageWriterHandler handler;

      public MessageWriter(MessageWriterHandler handler)
      {
        this.handler = handler;
      }

      public override void WriteLine(string format)
      {
        Write(format + NewLine);
      }

      public override void Write(string format)
      {
        if (handler != null)
          handler(format);
      }
    }

    private System.ComponentModel.Container components = null;

    public WinConsole()
    {
      InitializeComponent();
      SetStyle(ControlStyles.Selectable, false);
      Console.SetOut( new MessageWriter(
        new MessageWriter.MessageWriterHandler(Messg)));
    }

    Control GetFocus(Control p)
    {
      Control sender = null;
      foreach (Control c in  p.Controls)
      {
        if (c.Focused)
          return c;

        if (c.HasChildren)
        {
          sender = GetFocus(c);
          if (sender != null)
          {
            return sender;
          }
        }
      }
      return null;
    }

    void Messg(string text)
    {
      Control sender = GetFocus(TopLevelControl);
      Select();
      AppendText(text);
      SelectionStart = TextLength;
      ScrollToCaret();
      if (sender != null)
        sender.Select();
    }

    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if( components != null )
          components.Dispose();
      }
      base.Dispose( disposing );
    }

    #region Component Designer generated code

    private void InitializeComponent()
    {
      this.BackColor = System.Drawing.SystemColors.Info;
      this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      this.Font = new System.Drawing.Font("Lucida Console", 9F,
        System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
        ((System.Byte)(0)));
      this.ReadOnly = true;
      this.WordWrap = false;

    }
    #endregion
  }
}


leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

GeneralRe: Using a txtbox as output window Pin
Luther Baker6-Jan-04 18:33
MemberLuther Baker6-Jan-04 18:33 
Generalusing a C++ dialog window from C# Pin
misterbear6-Jan-04 10:14
Membermisterbear6-Jan-04 10:14 
GeneralRe: using a C++ dialog window from C# Pin
Mazdak6-Jan-04 10:44
MemberMazdak6-Jan-04 10:44 
GeneralRe: using a C++ dialog window from C# Pin
Heath Stewart6-Jan-04 17:19
protectorHeath Stewart6-Jan-04 17:19 
GeneralRe: using a C++ dialog window from C# Pin
misterbear7-Jan-04 0:29
Membermisterbear7-Jan-04 0:29 
GeneralRe: using a C++ dialog window from C# Pin
Heath Stewart7-Jan-04 3:00
protectorHeath Stewart7-Jan-04 3:00 
GeneralAutoresizing two panels with one splitter Pin
RB@Emphasys6-Jan-04 9:49
MemberRB@Emphasys6-Jan-04 9:49 
GeneralRe: Autoresizing two panels with one splitter Pin
Heath Stewart6-Jan-04 17:17
protectorHeath Stewart6-Jan-04 17:17 
GeneralRe: Autoresizing two panels with one splitter Pin
Luther Baker6-Jan-04 18:47
MemberLuther Baker6-Jan-04 18:47 
GeneralRe: Autoresizing two panels with one splitter Pin
Heath Stewart6-Jan-04 18:55
protectorHeath Stewart6-Jan-04 18:55 
GeneralRe: Autoresizing two panels with one splitter Pin
RB@Emphasys7-Jan-04 3:57
MemberRB@Emphasys7-Jan-04 3:57 
GeneralCompare files Pin
Gary Kirkham6-Jan-04 9:13
MemberGary Kirkham6-Jan-04 9:13 
GeneralRe: Compare files Pin
Mazdak6-Jan-04 9:22
MemberMazdak6-Jan-04 9:22 
GeneralRe: Compare files Pin
Kentamanos6-Jan-04 11:13
MemberKentamanos6-Jan-04 11:13 
GeneralListView and ProgressBar Pin
Guinness4Strength6-Jan-04 8:30
MemberGuinness4Strength6-Jan-04 8:30 
GeneralRe: ListView and ProgressBar Pin
Heath Stewart6-Jan-04 17:15
protectorHeath Stewart6-Jan-04 17:15 
GeneralGetting info out of datagrid cell Pin
obelisk296-Jan-04 8:17
Memberobelisk296-Jan-04 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.