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, 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
                  • 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.

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

                    Christian Graus wrote:

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

                    Yes, that's well spotted. However for the purpose I want to use it, I would pass the File Open info through the 'Environment', and default to an error screen, if someone just doubleclicked on it in windows explorer, they should get an eror message stating that is NOT a Stand Alone Application.

                    Christian Graus wrote:

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

                    When we started writing in 1995, MFC was Free. The MFC 4.2 Compiler is still our weapon of choice, and has not failed us sofar. :)

                    Bram van Kampen

                    C L 2 Replies Last reply
                    0
                    • R Robert Surtees

                      less file.txt

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

                      Robert Surtees wrote:

                      less file.txt

                      ???? :)

                      Bram van Kampen

                      R 1 Reply Last reply
                      0
                      • B Bram van Kampen

                        Christian Graus wrote:

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

                        Yes, that's well spotted. However for the purpose I want to use it, I would pass the File Open info through the 'Environment', and default to an error screen, if someone just doubleclicked on it in windows explorer, they should get an eror message stating that is NOT a Stand Alone Application.

                        Christian Graus wrote:

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

                        When we started writing in 1995, MFC was Free. The MFC 4.2 Compiler is still our weapon of choice, and has not failed us sofar. :)

                        Bram van Kampen

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

                        *grin* yes, I am just saying that the tool to compile the code he gave you, is quite free for you to download and thus make the app work as you want.

                        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
                        • 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
                          #25

                          MSDN:

                          Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: For single line text box controls, if the MaxLength property is set to 0, the maximum number of characters the user can enter is 2147483646 or an amount based on available memory, whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 4294967295 or an amount based on available memory, whichever is smaller. Windows Millennium Edition Platform Note: For single line text box controls, if the MaxLength property is set to 0, the maximum number of characters the user can enter is 32,766 or an amount based on available memory, whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 65,535 or an amount based on available memory, whichever is smaller.

                          Windows ME has a limit of 64K. For others, the limit is 4GB. Since nobody uses ME, I'd say the real limit is 4GB. :)

                          [Forum Guidelines]

                          N 1 Reply Last reply
                          0
                          • B Bram van Kampen

                            Robert Surtees wrote:

                            less file.txt

                            ???? :)

                            Bram van Kampen

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

                            Bram van Kampen wrote:

                            ????

                            It's a better version of more. Been around since the beginning of time. Wiki[^] A windows version[^]

                            1 Reply Last reply
                            0
                            • N Nish Nishant

                              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 Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #27

                              Yes, for the number of lines he's talking about, I think a smarter solution is needed than to just put it all into a RTB.

                              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

                                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

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

                                Bram van Kampen wrote:

                                Notepad loads it Sofar No Problems, it Takes a Long Time

                                FYI, if you turn off Word Wrap, it will load faster. And I think Word Pad will load any text file instantly. Though, like you say, it facilitates modification. Perhaps you could experiment with setting the files as readonly?

                                [Forum Guidelines]

                                1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  MSDN:

                                  Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: For single line text box controls, if the MaxLength property is set to 0, the maximum number of characters the user can enter is 2147483646 or an amount based on available memory, whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 4294967295 or an amount based on available memory, whichever is smaller. Windows Millennium Edition Platform Note: For single line text box controls, if the MaxLength property is set to 0, the maximum number of characters the user can enter is 32,766 or an amount based on available memory, whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 65,535 or an amount based on available memory, whichever is smaller.

                                  Windows ME has a limit of 64K. For others, the limit is 4GB. Since nobody uses ME, I'd say the real limit is 4GB. :)

                                  [Forum Guidelines]

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

                                  aspdotnetdev wrote:

                                  Since nobody uses ME, I'd say the real limit is 4GB.

                                  Touche! :)

                                  Regards, Nish


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

                                  1 Reply 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.

                                    S Offline
                                    S Offline
                                    S Senthil Kumar
                                    wrote on last edited by
                                    #30

                                    Christian Graus wrote:

                                    and at least 8 seconds to compile the most basic app....

                                    Really? It depends on what you call basic, but that's way too slow - on my laptop, compiling a project with ~10 files takes 2-3 seconds, max.

                                    Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                    1 Reply Last reply
                                    0
                                    • B Bram van Kampen

                                      Christian Graus wrote:

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

                                      Yes, that's well spotted. However for the purpose I want to use it, I would pass the File Open info through the 'Environment', and default to an error screen, if someone just doubleclicked on it in windows explorer, they should get an eror message stating that is NOT a Stand Alone Application.

                                      Christian Graus wrote:

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

                                      When we started writing in 1995, MFC was Free. The MFC 4.2 Compiler is still our weapon of choice, and has not failed us sofar. :)

                                      Bram van Kampen

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #31

                                      Bram van Kampen wrote:

                                      When we started writing in 1995, MFC was Free

                                      With 15+ years of windows GUI development you should be able to knock up a text viewer quicker than you can knock up your wife.

                                      L 1 Reply Last reply
                                      0
                                      • B Bram van Kampen

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

                                        Bram van Kampen

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

                                        If you want to create an app yourself and you don't want to use managed code, just allow the user to page through the file in 32KB chunks. Create a right arrow button that will go the next 32K and a left arrow button that will go to the previous 32K. And maybe allow the user to specify how many bytes into the file to start the loading. There are more sophisticated techniques, but that shouldn't take too long to code.

                                        [Forum Guidelines]

                                        1 Reply 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
                                          Dario Solera
                                          wrote on last edited by
                                          #33

                                          Christian Graus wrote:

                                          It takes VS 2008 20 seconds to start on my machine

                                          4 seconds on mine, plus 10 seconds to rebuild a 120kloc, 16 projects solution. :cool: Time to buy a new PC Christian?

                                          If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Photos/CP Flickr Group - ScrewTurn Wiki v3

                                          P 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