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. General Programming
  3. C / C++ / MFC
  4. Efficient way to delete lines from CEdit

Efficient way to delete lines from CEdit

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 3 Posters 0 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.
  • E Offline
    E Offline
    EiSl
    wrote on last edited by
    #1

    Hello all, I've got a CEdit (read-only) in which continuously lines are added at the end (debugging stuff). Of course... if I do nothing, its memory usage will grow and grow (64k Max for Win9x, 'unlimitted' for WinNT/2k). What I want to do is to delete the first line when it passed a predefined maximum amount of lines. But... CEdit doesn't implement a 'delete-line' method. The only way I've found out was: -First select the line(s), than replace the selection with nothing. This sounds CPU-consuming to me... Does anyone knows an efficient way to do this? Thanks in advanced, EiSl

    T L 2 Replies Last reply
    0
    • E EiSl

      Hello all, I've got a CEdit (read-only) in which continuously lines are added at the end (debugging stuff). Of course... if I do nothing, its memory usage will grow and grow (64k Max for Win9x, 'unlimitted' for WinNT/2k). What I want to do is to delete the first line when it passed a predefined maximum amount of lines. But... CEdit doesn't implement a 'delete-line' method. The only way I've found out was: -First select the line(s), than replace the selection with nothing. This sounds CPU-consuming to me... Does anyone knows an efficient way to do this? Thanks in advanced, EiSl

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      I think there's no other option than select/replace with nothing. Is this a real problem? Tomasz Sowinski -- http://www.shooltz.com.pl

      1 Reply Last reply
      0
      • E EiSl

        Hello all, I've got a CEdit (read-only) in which continuously lines are added at the end (debugging stuff). Of course... if I do nothing, its memory usage will grow and grow (64k Max for Win9x, 'unlimitted' for WinNT/2k). What I want to do is to delete the first line when it passed a predefined maximum amount of lines. But... CEdit doesn't implement a 'delete-line' method. The only way I've found out was: -First select the line(s), than replace the selection with nothing. This sounds CPU-consuming to me... Does anyone knows an efficient way to do this? Thanks in advanced, EiSl

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

        Better you should create a loop that replace the first line with the second, the second with the third... and you should call this loop after verify wheather the comming line are going to exceed the limit. :rose:

        E 1 Reply Last reply
        0
        • L Lost User

          Better you should create a loop that replace the first line with the second, the second with the third... and you should call this loop after verify wheather the comming line are going to exceed the limit. :rose:

          E Offline
          E Offline
          EiSl
          wrote on last edited by
          #4

          Thanks for your reaction :rolleyes: ! Just a summary of what you suggested: 1. First get access to complete memory block in CEdit 2. Do the loop-stuff as you suggested (outside the scope of CEdit) Probably by using memmove 3. Give this block of memory back to CEdit Now a little question... :confused: Let's say we're talking about 1000 lines of average 50 characters in width. What do you know about your method that it's probably faster than the 'select-and-replace-with-nothing' method? Curious about your answer, EiSl

          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