The following code is in the EDIT_MakeFit() function:
if ((es->buffer_limit > 0) && (size > es->buffer_limit)) { EDIT_NOTIFY_PARENT(es, EN_MAXTEXT, "EN_MAXTEXT"); return FALSE; } if ((es->buffer_limit > 0) && (size > es->buffer_limit)) size = es->buffer_limit;
Obviously, the second IF condition is never true, since it's the same as the prior IF, which does a 'return FALSE'.
EDIT_MakeFit() is ONLY called by EDIT_EM_ReplaceSel(), so it sppears that the second IF is attempting to limit the amount of text that is replaced to the buffer_limit. Obviously, the first IF just notifies the parent that the limit would be exceeded, then returns without modifying the edit control.
Although EDIT_MakeFit() is only called from one place, EDIT_EM_ReplaceSel() is called all over the place, enumerated below. Can anyone tell me if any of these invocations should (a) fail without replacing, (b) replace the limited amount of text, or (c) ignore the limit?
EDIT_WM_Clear() - Processes WM_CLEAR message - I assume it's moot here... Processing of EM_REPLACESEL message. See note below... EDIT_EM_Undo() - Processes EM_UNDO and WM_UNDO messages EDIT_WM_Char() - Process WM_CHAR message EDIT_WM_Create() - Processes WM_CREATE message - I assume it's moot here... EDIT_WM_Paste - Process WM_PASTE message EDIT_WM_SetText - Process WM_SETTEXT message. See note below...
Note: Under the message EM_LIMITTEXT, MSDN states that WM_SETTEXT will not adhear to the limit, but doesn't mention any other text modification messages. The man pages for the other messages do not mention how it's action is effected by the limit. MSDN does state "The EM_LIMITTEXT message limits only the text the user can enter."
Unfortunately, I don't have a MS Windows box readily available to test some of these things out on...
- - - - - - - - -
Another question about this code from controls/edit.c/EDIT_WM_Char():
/* Protect read-only edit control from modification */ if(es->style & ES_READONLY) return; /* BECAUSE OF THIS... */
control = GetKeyState(VK_CONTROL) & 0x8000;
switch (c) { case '\r': /* If the edit doesn't want the return and it's not a multiline edit, do nothing */ if(!(es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN)) break; case '\n': if (es->style & ES_MULTILINE) { if (es->style & ES_READONLY) {
/* ... WE NEVER GET HERE! */
EDIT_MoveHome(es, FALSE); EDIT_MoveDown_ML(es, FALSE); } else { static const WCHAR cr_lfW[] = {'\r','\n',0}; EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE); } } break;
The place that I marked "/* BECAUSE OF THIS... */" means that the code marked by "/* ... WE NEVER GET HERE! */" will never get executed.
My question: In a read only multiline edit control, should a newline move the cursor to the beginning of the next line of text in the control? (I could make this change, but don't have any way of testing it...)
- - - - -
Thanks for the help,
Carl