Non display characters for selection count
-
I misunderstood what you were attempting. You are using the
GetSel()
method to get the starting and ending positions of the control's selected text, correct? I tried that and with all of the text in the control selected, I found thatCR
andLF
are (like I would expect) considered two separate characters. In other words, start = 0 and end = 7."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
I use the Streamout api to get whatever is in the control the edit control has 4 lines at the end of each line is X0D0A CRLF I have to count the 0X0D0A as 1 character for the SetSel api when determining the pos I want to use in the selection thanks
So your end game is just to programmatically insert/replace some characters some place in the edit control?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
The text is included in the count for the cold I count as 1 character for porpouses of selection not 2 bytes
-
So your end game is just to programmatically insert/replace some characters some place in the edit control?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
The documentation at EM_GETSELTEXT message (Windows)[^] does not explicitly say whether it does, or does not. But a simple test should prove it one way or another.
Well, This is Familiar, in particular with the multi threaded question you asked earlier. MFC cannot realy handle multiple threads. No one seems to know why, I have asked the question before. At any rate, the only way MFC objects can communicate between threads is with the Old Fashioned WDK Kernel Function ::SendMessage(hWnd, Param1,Param2); In MFC you create your Message as WM_USER+(X), Create a Message Handler, and, manually add it to the message map. Any attempt to call an MFC Object from a different thread than in which it was created always ultimately lead to failure. The Symptoms are: Works, Add a Virtual Function: It stops Working Hope this helps
Bram van Kampen
-
I just tried this with an ordinary Edit control, and it returns both CR LF in the count.
You did not try this in a Multi Threaded Environment, as explained in the question previous of this :)
Bram van Kampen
-
Well, This is Familiar, in particular with the multi threaded question you asked earlier. MFC cannot realy handle multiple threads. No one seems to know why, I have asked the question before. At any rate, the only way MFC objects can communicate between threads is with the Old Fashioned WDK Kernel Function ::SendMessage(hWnd, Param1,Param2); In MFC you create your Message as WM_USER+(X), Create a Message Handler, and, manually add it to the message map. Any attempt to call an MFC Object from a different thread than in which it was created always ultimately lead to failure. The Symptoms are: Works, Add a Virtual Function: It stops Working Hope this helps
Bram van Kampen
-
You did not try this in a Multi Threaded Environment, as explained in the question previous of this :)
Bram van Kampen
-
Well, This is Familiar, in particular with the multi threaded question you asked earlier. MFC cannot realy handle multiple threads. No one seems to know why, I have asked the question before. At any rate, the only way MFC objects can communicate between threads is with the Old Fashioned WDK Kernel Function ::SendMessage(hWnd, Param1,Param2); In MFC you create your Message as WM_USER+(X), Create a Message Handler, and, manually add it to the message map. Any attempt to call an MFC Object from a different thread than in which it was created always ultimately lead to failure. The Symptoms are: Works, Add a Virtual Function: It stops Working Hope this helps
Bram van Kampen
Relevance? :confused:
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Sorry Richard, No I Did Not intend this for you. This topic became a Sort of a Labyrinth. The Original Person is evidently out of his/her depth! (S)he is still hammering the subject I see. I try to help, as we all do, but can get frustrated when good advise is ignored, as, I am sure you do to. Regards, Bram. :( ;) ;)
Bram van Kampen
-
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
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