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. How to obtain column number in a file

How to obtain column number in a file

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiontutorialvisual-studio
2 Posts 2 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.
  • S Offline
    S Offline
    Saqib Razzaq
    wrote on last edited by
    #1

    I've created MFC application with Doc/View support. My view class is inherited from CRichEditView class. I need to obtain the row and column number of the current cursor position. The following function gets the current line number. GetRichEditCtrl().LineFromChar(-1); The question is "How can I get the column number"? The ideal example is the Visual C++ IDE that shows the row and column of the cursor in the status bar. The row and column updates whenever the cursor changes.

    R 1 Reply Last reply
    0
    • S Saqib Razzaq

      I've created MFC application with Doc/View support. My view class is inherited from CRichEditView class. I need to obtain the row and column number of the current cursor position. The following function gets the current line number. GetRichEditCtrl().LineFromChar(-1); The question is "How can I get the column number"? The ideal example is the Visual C++ IDE that shows the row and column of the cursor in the status bar. The row and column updates whenever the cursor changes.

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      A quite complicated solution : Use GetSel to retrieve the caracter number. Make a loop on LineFromChar with parameter the character number, which you decrement until LineFromChar changes. Then, the first number minus the final one should give you the pos.

      long int i,j;
      m_RichEditCtrl.GetSel(&i,&j);
      i=(i

      ~RaGE();

      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