Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Text Viewer

Text Viewer

Scheduled Pinned Locked Moved The Lounge
76 Posts 45 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Bram van Kampen

    Hi, Does anyone know of a Text Viewer, (for basic .txt Files) which does NOT facilitate editing or Saving. :)

    Bram van Kampen

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #2

    No, but I am sure it would take about 30 seconds to write one.

    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

    D B A 3 Replies Last reply
    0
    • C Christian Graus

      No, but I am sure it would take about 30 seconds to write one.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      D Offline
      D Offline
      DABBee
      wrote on last edited by
      #3

      That'd be if you could install VS on a 386 then ?

      Candy: Here's the plan: we changes our names, move to a distant island, and disguise ourselves as a family of traveling donkey polishers.

      C 1 Reply Last reply
      0
      • D DABBee

        That'd be if you could install VS on a 386 then ?

        Candy: Here's the plan: we changes our names, move to a distant island, and disguise ourselves as a family of traveling donkey polishers.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #4

        It takes VS 2008 20 seconds to start on my machine, and at least 8 seconds to compile the most basic app....

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        D S D J 4 Replies Last reply
        0
        • C Christian Graus

          No, but I am sure it would take about 30 seconds to write one.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          B Offline
          B Offline
          Bram van Kampen
          wrote on last edited by
          #5

          Hi,

          Christian Graus wrote:

          No, but I am sure it would take about 30 seconds to write one.

          Well I thought that, until I tried. The CEdit Control turns Gray if you make it 'Read Only', and limits to 32757 lines. Try a ListBox instead, and you are limited to 32757 lines, and you have to implement the Edit\Copy Interface and Selection Interface yourself. Notepad has None of these limitations, but allows a User to Modify and save. Googeling the question results in solutions which pride themsevelves in advanced Editing features, exactly what I Do NOT want! Hence the Question. Regards, :)

          Bram van Kampen

          C N R 3 Replies Last reply
          0
          • C Christian Graus

            It takes VS 2008 20 seconds to start on my machine, and at least 8 seconds to compile the most basic app....

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            D Offline
            D Offline
            DABBee
            wrote on last edited by
            #6

            6 secs to start and populate the Start page (don't ask me why I haven't disabled that, I don't know why.) Compiling is OK but I don't work on large projects....

            Candy: Here's the plan: we changes our names, move to a distant island, and disguise ourselves as a family of traveling donkey polishers.

            P 1 Reply Last reply
            0
            • B Bram van Kampen

              Hi,

              Christian Graus wrote:

              No, but I am sure it would take about 30 seconds to write one.

              Well I thought that, until I tried. The CEdit Control turns Gray if you make it 'Read Only', and limits to 32757 lines. Try a ListBox instead, and you are limited to 32757 lines, and you have to implement the Edit\Copy Interface and Selection Interface yourself. Notepad has None of these limitations, but allows a User to Modify and save. Googeling the question results in solutions which pride themsevelves in advanced Editing features, exactly what I Do NOT want! Hence the Question. Regards, :)

              Bram van Kampen

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #7

              Is the 32757 line limit a major issue ? Because the rest seems easy to deal with. Just don't make it read only, but write code to reject all keypresses.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              B G 2 Replies Last reply
              0
              • B Bram van Kampen

                Hi, Does anyone know of a Text Viewer, (for basic .txt Files) which does NOT facilitate editing or Saving. :)

                Bram van Kampen

                A Offline
                A Offline
                AspDotNetDev
                wrote on last edited by
                #8

                Form1.cs:

                using System;
                using System.Collections.Generic;
                using System.ComponentModel;
                using System.Data;
                using System.Drawing;
                using System.Text;
                using System.Windows.Forms;

                namespace WindowsApplication1
                {
                public partial class Form1 : Form
                {
                public Form1()
                {
                InitializeComponent();
                }

                    private void textBox1\_DragDrop(object sender, DragEventArgs e)
                    {
                        string\[\] files = (string\[\])e.Data.GetData(DataFormats.FileDrop);
                        StringBuilder sb = new StringBuilder();
                        foreach (string path in files)
                        {
                            if (System.IO.Directory.Exists(path))
                            {
                                AppendFolder(sb, path);
                            }
                            else
                            {
                                sb.AppendLine(System.IO.File.ReadAllText(path));
                            }
                        }
                        textBox1.Text = sb.ToString();
                    }
                
                    private void AppendFolder(StringBuilder sb, string path)
                    {
                        string\[\] files = System.IO.Directory.GetFiles(path);
                        foreach (string subpath in files)
                        {
                            if (System.IO.Directory.Exists(subpath))
                            {
                                AppendFolder(sb, subpath);
                            }
                            else
                            {
                                sb.AppendLine(System.IO.File.ReadAllText(subpath));
                            }
                        }
                    }
                
                    private void textBox1\_DragEnter(object sender, DragEventArgs e)
                    {
                        if (e.Data.GetDataPresent(DataFormats.FileDrop))
                        {
                            e.Effect = DragDropEffects.Copy;
                        }
                    }
                }
                

                }

                Form1.Designer.cs:

                namespace WindowsApplication1
                {
                partial class Form1
                {
                /// <summary>
                /// Required designer variable.
                /// </summary>
                private System.ComponentModel.IContainer components = null;

                    /// <summary>
                    /// Clean up any resources being used.
                    /// </summary>
                    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
                    protected override void Dispose(bool disposing)
                    {
                        if (disposing && (components != null))
                        {
                            components.Dispose();
                        }
                        base.Dispose(disposing);
                    }
                
                    #region Windows Form Designer generated code
                
                    /// <
                
                B C N 3 Replies Last reply
                0
                • C Christian Graus

                  Is the 32757 line limit a major issue ? Because the rest seems easy to deal with. Just don't make it read only, but write code to reject all keypresses.

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  B Offline
                  B Offline
                  Bram van Kampen
                  wrote on last edited by
                  #9

                  Christian Graus wrote:

                  Is the 32757 line limit a major issue ? Because the rest seems easy to deal with. Just don't make it read only, but write code to reject all keypresses.

                  Yes, it is! We have Basic Log Files, which record transactions in ASCII, and which would cover up to six years of trading. The biggest sofar contans 425,000 lines. it is not accessed very frequently, but, the concern is that we have no tool to access it which disallows modification. Notepad loads it Sofar No Problems, it Takes a Long Time, No Problem, but it facilitates modification.

                  Bram van Kampen

                  C A L P N 6 Replies Last reply
                  0
                  • C Christian Graus

                    No, but I am sure it would take about 30 seconds to write one.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    A Offline
                    A Offline
                    AspDotNetDev
                    wrote on last edited by
                    #10

                    Took me a few minutes. The drag/drop logic tripped me up a bit.

                    [Forum Guidelines]

                    J 1 Reply Last reply
                    0
                    • A AspDotNetDev

                      Form1.cs:

                      using System;
                      using System.Collections.Generic;
                      using System.ComponentModel;
                      using System.Data;
                      using System.Drawing;
                      using System.Text;
                      using System.Windows.Forms;

                      namespace WindowsApplication1
                      {
                      public partial class Form1 : Form
                      {
                      public Form1()
                      {
                      InitializeComponent();
                      }

                          private void textBox1\_DragDrop(object sender, DragEventArgs e)
                          {
                              string\[\] files = (string\[\])e.Data.GetData(DataFormats.FileDrop);
                              StringBuilder sb = new StringBuilder();
                              foreach (string path in files)
                              {
                                  if (System.IO.Directory.Exists(path))
                                  {
                                      AppendFolder(sb, path);
                                  }
                                  else
                                  {
                                      sb.AppendLine(System.IO.File.ReadAllText(path));
                                  }
                              }
                              textBox1.Text = sb.ToString();
                          }
                      
                          private void AppendFolder(StringBuilder sb, string path)
                          {
                              string\[\] files = System.IO.Directory.GetFiles(path);
                              foreach (string subpath in files)
                              {
                                  if (System.IO.Directory.Exists(subpath))
                                  {
                                      AppendFolder(sb, subpath);
                                  }
                                  else
                                  {
                                      sb.AppendLine(System.IO.File.ReadAllText(subpath));
                                  }
                              }
                          }
                      
                          private void textBox1\_DragEnter(object sender, DragEventArgs e)
                          {
                              if (e.Data.GetDataPresent(DataFormats.FileDrop))
                              {
                                  e.Effect = DragDropEffects.Copy;
                              }
                          }
                      }
                      

                      }

                      Form1.Designer.cs:

                      namespace WindowsApplication1
                      {
                      partial class Form1
                      {
                      /// <summary>
                      /// Required designer variable.
                      /// </summary>
                      private System.ComponentModel.IContainer components = null;

                          /// <summary>
                          /// Clean up any resources being used.
                          /// </summary>
                          /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
                          protected override void Dispose(bool disposing)
                          {
                              if (disposing && (components != null))
                              {
                                  components.Dispose();
                              }
                              base.Dispose(disposing);
                          }
                      
                          #region Windows Form Designer generated code
                      
                          /// <
                      
                      B Offline
                      B Offline
                      Bram van Kampen
                      wrote on last edited by
                      #11

                      Hi, Looks Fine. However I cannot compile that. Could you send me a Compiled version of that? I'll include you in the Credits. (Better: Include your Contribution in the Compiled Version) email: bramvankampen@aol.com :) :) :) regards

                      Bram van Kampen

                      C 1 Reply Last reply
                      0
                      • A AspDotNetDev

                        Form1.cs:

                        using System;
                        using System.Collections.Generic;
                        using System.ComponentModel;
                        using System.Data;
                        using System.Drawing;
                        using System.Text;
                        using System.Windows.Forms;

                        namespace WindowsApplication1
                        {
                        public partial class Form1 : Form
                        {
                        public Form1()
                        {
                        InitializeComponent();
                        }

                            private void textBox1\_DragDrop(object sender, DragEventArgs e)
                            {
                                string\[\] files = (string\[\])e.Data.GetData(DataFormats.FileDrop);
                                StringBuilder sb = new StringBuilder();
                                foreach (string path in files)
                                {
                                    if (System.IO.Directory.Exists(path))
                                    {
                                        AppendFolder(sb, path);
                                    }
                                    else
                                    {
                                        sb.AppendLine(System.IO.File.ReadAllText(path));
                                    }
                                }
                                textBox1.Text = sb.ToString();
                            }
                        
                            private void AppendFolder(StringBuilder sb, string path)
                            {
                                string\[\] files = System.IO.Directory.GetFiles(path);
                                foreach (string subpath in files)
                                {
                                    if (System.IO.Directory.Exists(subpath))
                                    {
                                        AppendFolder(sb, subpath);
                                    }
                                    else
                                    {
                                        sb.AppendLine(System.IO.File.ReadAllText(subpath));
                                    }
                                }
                            }
                        
                            private void textBox1\_DragEnter(object sender, DragEventArgs e)
                            {
                                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                                {
                                    e.Effect = DragDropEffects.Copy;
                                }
                            }
                        }
                        

                        }

                        Form1.Designer.cs:

                        namespace WindowsApplication1
                        {
                        partial class Form1
                        {
                        /// <summary>
                        /// Required designer variable.
                        /// </summary>
                        private System.ComponentModel.IContainer components = null;

                            /// <summary>
                            /// Clean up any resources being used.
                            /// </summary>
                            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
                            protected override void Dispose(bool disposing)
                            {
                                if (disposing && (components != null))
                                {
                                    components.Dispose();
                                }
                                base.Dispose(disposing);
                            }
                        
                            #region Windows Form Designer generated code
                        
                            /// <
                        
                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #12

                        Does it allow more than 32767 lines ? It occured to me that part of of the issue could be that the op didn't want managed code, and that it would be tricker with the older MFC controls perhaps.

                        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                        A B 2 Replies Last reply
                        0
                        • C Christian Graus

                          Does it allow more than 32767 lines ? It occured to me that part of of the issue could be that the op didn't want managed code, and that it would be tricker with the older MFC controls perhaps.

                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                          A Offline
                          A Offline
                          AspDotNetDev
                          wrote on last edited by
                          #13

                          Yeah, you just set the MaxLength property to 0.

                          [Forum Guidelines]

                          1 Reply Last reply
                          0
                          • B Bram van Kampen

                            Hi, Looks Fine. However I cannot compile that. Could you send me a Compiled version of that? I'll include you in the Credits. (Better: Include your Contribution in the Compiled Version) email: bramvankampen@aol.com :) :) :) regards

                            Bram van Kampen

                            C Offline
                            C Offline
                            Christian Graus
                            wrote on last edited by
                            #14

                            You should get him to add file/open functionality instead of just drag/drop. The Express Edition of C# is, however, free.

                            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                            A B 2 Replies Last reply
                            0
                            • C Christian Graus

                              Does it allow more than 32767 lines ? It occured to me that part of of the issue could be that the op didn't want managed code, and that it would be tricker with the older MFC controls perhaps.

                              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                              B Offline
                              B Offline
                              Bram van Kampen
                              wrote on last edited by
                              #15

                              All our Code is in MFC. We do not use Managed Code.

                              Bram van Kampen

                              A 1 Reply Last reply
                              0
                              • C Christian Graus

                                You should get him to add file/open functionality instead of just drag/drop. The Express Edition of C# is, however, free.

                                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                A Offline
                                A Offline
                                AspDotNetDev
                                wrote on last edited by
                                #16

                                Christian Graus wrote:

                                You should get him to add file/open functionality instead of just drag/drop

                                Haha, I'm done with charity for the day. Maybe you'd like to incorporate Syslog exception logging, printing functionality, syntax highlighting, layout settings, and so on?

                                Christian Graus wrote:

                                The Express Edition of C# is, however, free.

                                Bingo.

                                [Forum Guidelines]

                                1 Reply Last reply
                                0
                                • B Bram van Kampen

                                  Christian Graus wrote:

                                  Is the 32757 line limit a major issue ? Because the rest seems easy to deal with. Just don't make it read only, but write code to reject all keypresses.

                                  Yes, it is! We have Basic Log Files, which record transactions in ASCII, and which would cover up to six years of trading. The biggest sofar contans 425,000 lines. it is not accessed very frequently, but, the concern is that we have no tool to access it which disallows modification. Notepad loads it Sofar No Problems, it Takes a Long Time, No Problem, but it facilitates modification.

                                  Bram van Kampen

                                  C Offline
                                  C Offline
                                  Christian Graus
                                  wrote on last edited by
                                  #17

                                  Hmmm... if I was going to read 425,000 lines of text, I expect I'd offer search throughout the entire document, but I would not present it all to the user, I'd page it, and/or show as much as I got out of a search.

                                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                  1 Reply Last reply
                                  0
                                  • B Bram van Kampen

                                    Hi, Does anyone know of a Text Viewer, (for basic .txt Files) which does NOT facilitate editing or Saving. :)

                                    Bram van Kampen

                                    R Offline
                                    R Offline
                                    Robert Surtees
                                    wrote on last edited by
                                    #18

                                    less file.txt

                                    B 1 Reply Last reply
                                    0
                                    • A AspDotNetDev

                                      Form1.cs:

                                      using System;
                                      using System.Collections.Generic;
                                      using System.ComponentModel;
                                      using System.Data;
                                      using System.Drawing;
                                      using System.Text;
                                      using System.Windows.Forms;

                                      namespace WindowsApplication1
                                      {
                                      public partial class Form1 : Form
                                      {
                                      public Form1()
                                      {
                                      InitializeComponent();
                                      }

                                          private void textBox1\_DragDrop(object sender, DragEventArgs e)
                                          {
                                              string\[\] files = (string\[\])e.Data.GetData(DataFormats.FileDrop);
                                              StringBuilder sb = new StringBuilder();
                                              foreach (string path in files)
                                              {
                                                  if (System.IO.Directory.Exists(path))
                                                  {
                                                      AppendFolder(sb, path);
                                                  }
                                                  else
                                                  {
                                                      sb.AppendLine(System.IO.File.ReadAllText(path));
                                                  }
                                              }
                                              textBox1.Text = sb.ToString();
                                          }
                                      
                                          private void AppendFolder(StringBuilder sb, string path)
                                          {
                                              string\[\] files = System.IO.Directory.GetFiles(path);
                                              foreach (string subpath in files)
                                              {
                                                  if (System.IO.Directory.Exists(subpath))
                                                  {
                                                      AppendFolder(sb, subpath);
                                                  }
                                                  else
                                                  {
                                                      sb.AppendLine(System.IO.File.ReadAllText(subpath));
                                                  }
                                              }
                                          }
                                      
                                          private void textBox1\_DragEnter(object sender, DragEventArgs e)
                                          {
                                              if (e.Data.GetDataPresent(DataFormats.FileDrop))
                                              {
                                                  e.Effect = DragDropEffects.Copy;
                                              }
                                          }
                                      }
                                      

                                      }

                                      Form1.Designer.cs:

                                      namespace WindowsApplication1
                                      {
                                      partial class Form1
                                      {
                                      /// <summary>
                                      /// Required designer variable.
                                      /// </summary>
                                      private System.ComponentModel.IContainer components = null;

                                          /// <summary>
                                          /// Clean up any resources being used.
                                          /// </summary>
                                          /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
                                          protected override void Dispose(bool disposing)
                                          {
                                              if (disposing && (components != null))
                                              {
                                                  components.Dispose();
                                              }
                                              base.Dispose(disposing);
                                          }
                                      
                                          #region Windows Form Designer generated code
                                      
                                          /// <
                                      
                                      N Offline
                                      N Offline
                                      Nish Nishant
                                      wrote on last edited by
                                      #19

                                      A TextBox??? Geez! That's limited to 64 KB or around that. Can't believe you didn't use a RichTextBox. Shame on you. Now you'll get featured in the Coding Horrors forum ;P

                                      Regards, Nish


                                      Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                                      My latest book : C++/CLI in Action / Amazon.com link

                                      A 2 Replies Last reply
                                      0
                                      • B Bram van Kampen

                                        Hi,

                                        Christian Graus wrote:

                                        No, but I am sure it would take about 30 seconds to write one.

                                        Well I thought that, until I tried. The CEdit Control turns Gray if you make it 'Read Only', and limits to 32757 lines. Try a ListBox instead, and you are limited to 32757 lines, and you have to implement the Edit\Copy Interface and Selection Interface yourself. Notepad has None of these limitations, but allows a User to Modify and save. Googeling the question results in solutions which pride themsevelves in advanced Editing features, exactly what I Do NOT want! Hence the Question. Regards, :)

                                        Bram van Kampen

                                        N Offline
                                        N Offline
                                        Nish Nishant
                                        wrote on last edited by
                                        #20

                                        You can use a rich text control and make it read only. It can display really large text files (once you get too large it will be very slow).

                                        Regards, Nish


                                        Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                                        My latest book : C++/CLI in Action / Amazon.com link

                                        C 1 Reply Last reply
                                        0
                                        • N Nish Nishant

                                          A TextBox??? Geez! That's limited to 64 KB or around that. Can't believe you didn't use a RichTextBox. Shame on you. Now you'll get featured in the Coding Horrors forum ;P

                                          Regards, Nish


                                          Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                                          My latest book : C++/CLI in Action / Amazon.com link

                                          A Offline
                                          A Offline
                                          AspDotNetDev
                                          wrote on last edited by
                                          #21

                                          Nishant Sivakumar wrote:

                                          That's limited to 64 KB or around that

                                          False.

                                          Nishant Sivakumar wrote:

                                          Shame on you.

                                          Shame on you for spreading misinformation. Now you'll get featured in the Replying Horrors forum ;P .

                                          [Forum Guidelines]

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups