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. Non display characters for selection count

Non display characters for selection count

Scheduled Pinned Locked Moved C / C++ / MFC
21 Posts 5 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.
  • F ForNow

    Hi I have 3 rows of text in my rich edit. At the end of each line I move a carriage return line feed, to force a new line /r/n. Do these 2 bytes count as 2 characters when determining the count for the selection Thanks

    L Offline
    L Offline
    leon de boer
    wrote on last edited by
    #21

    EM_GETSELTEXT is explicit

    This message returns the number of characters copied, not including the terminating null character.

    The call is terminated by the null character and if you have CR,LF they will count as characters The return is a CHARACTER COUNT, if your edit box is unicode mode it still reflects the character NOT THE NUMBER OF BYTES. Hence when providing a buffer you are best to use an array of TCHAR rather than a standard byte array to allow for size difference. Also note when size a TCHAR array use _countof DO NOT use sizeof for the same reason. Standard unicode aware coding practice. Several of the comments have confusion between CHARACTER and BYTE within the meaning of the windows API. No such confusion exists.

    In vino veritas

    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