and just line width for single line controls */
INT region_posx; /* Position of cursor relative to region: */
INT region_posy; /* -1: to left, 0: within, 1: to right */
-#ifndef __REACTOS__
- EDITWORDBREAKPROC16 word_break_proc16;
-#endif
void *word_break_proc; /* 32-bit word break proc: ANSI or Unicode */
INT line_count; /* number of lines */
INT y_offset; /* scroll offset in number of lines */
LPINT tabs;
LINEDEF *first_line_def; /* linked list of (soft) linebreaks */
HLOCAL hloc32W; /* our unicode local memory block */
-#ifndef __REACTOS__
- HLOCAL16 hloc16; /* alias for 16-bit control receiving EM_GETHANDLE16
- or EM_SETHANDLE16 */
-#endif
HLOCAL hloc32A; /* alias for ANSI control receiving EM_GETHANDLE
or EM_SETHANDLE */
/*
(LPARAM)(es->hwndSelf)); \
} while(0)
+static const WCHAR empty_stringW[] = {0};
/*********************************************************************
*
{
INT ret;
-#ifndef __REACTOS__
- if (es->word_break_proc16) {
- HGLOBAL16 hglob16;
- SEGPTR segptr;
- INT countA;
- WORD args[5];
- DWORD result;
-
- countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
- hglob16 = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT, countA);
- segptr = WOWGlobalLock16(hglob16);
- WideCharToMultiByte(CP_ACP, 0, es->text + start, count, MapSL(segptr), countA, NULL, NULL);
- args[4] = SELECTOROF(segptr);
- args[3] = OFFSETOF(segptr);
- args[2] = index;
- args[1] = countA;
- args[0] = action;
- WOWCallback16Ex((DWORD)es->word_break_proc16, WCB16_PASCAL, sizeof(args), args, &result);
- ret = LOWORD(result);
- GlobalUnlock16(hglob16);
- GlobalFree16(hglob16);
- }
- else if (es->word_break_proc)
-#else
- if (es->word_break_proc)
-#endif
+ if (es->word_break_proc)
{
if(es->is_unicode)
{
countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
textA = HeapAlloc(GetProcessHeap(), 0, countA);
- if (textA == NULL)
- return 0;
+ if (textA == NULL) return 0;
WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
/* The buffer has been expanded, create a new line and
insert it into the link list */
LINEDEF *new_line = HeapAlloc(GetProcessHeap(), 0, sizeof(LINEDEF));
- if (new_line == NULL)
- break;
+ if (new_line == NULL) // reactos r33509
+ break; // reactos r33509
new_line->next = previous_line->next;
previous_line->next = new_line;
current_line = new_line;
}
/*********************************************************************
- *
- * EDIT_LockBuffer
- *
- * This acts as a LocalLock16(), but it locks only once. This way
- * you can call it whenever you like, without unlocking.
- *
- * Initially the edit control allocates a HLOCAL32 buffer
- * (32 bit linear memory handler). However, 16 bit application
- * might send an EM_GETHANDLE message and expect a HLOCAL16 (16 bit SEG:OFF
- * handler). From that moment on we have to keep using this 16 bit memory
- * handler, because it is supposed to be valid at all times after EM_GETHANDLE.
- * What we do is create a HLOCAL16 buffer, copy the text, and do pointer
- * conversion.
+ * EDIT_LockBuffer
*
*/
static void EDIT_LockBuffer(EDITSTATE *es)
{
-#ifndef __REACTOS__
- STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- HINSTANCE16 hInstance = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
-#endif
if (!es->text) {
- CHAR *textA = NULL;
+
+ CHAR *textA = NULL; // ReactOS Hacked!
UINT countA = 0;
-#ifndef __REACTOS__
- BOOL _16bit = FALSE;
-#endif
if(es->hloc32W)
{
textA = LocalLock(es->hloc32A);
countA = strlen(textA) + 1;
}
-#ifndef __REACTOS__
- else if(es->hloc16)
- {
- HANDLE16 oldDS = stack16->ds;
- TRACE("Synchronizing with 16-bit ANSI buffer\n");
- stack16->ds = hInstance;
- textA = MapSL(LocalLock16(es->hloc16));
- stack16->ds = oldDS;
- countA = strlen(textA) + 1;
- _16bit = TRUE;
- }
-#endif
}
else {
ERR("no buffer ... please report\n");
if(textA)
{
HLOCAL hloc32W_new;
- UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
- TRACE("%d bytes translated to %d WCHARs\n", countA, countW_new);
+ UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
if(countW_new > es->buffer_size + 1)
{
UINT alloc_size = ROUND_TO_GROW(countW_new * sizeof(WCHAR));
else
WARN("FAILED! Will synchronize partially\n");
}
+ es->text = LocalLock(es->hloc32W);
+ MultiByteToWideChar(CP_ACP, 0, textA, -1, es->text, es->buffer_size + 1);
+ LocalUnlock(es->hloc32A);
}
-
- /*TRACE("Locking 32-bit UNICODE buffer\n");*/
- es->text = LocalLock(es->hloc32W);
-
- if(textA)
- {
- MultiByteToWideChar(CP_ACP, 0, textA, countA, es->text, es->buffer_size + 1);
-#ifndef __REACTOS__
- if(_16bit)
- {
- HANDLE16 oldDS = stack16->ds;
- stack16->ds = hInstance;
- LocalUnlock16(es->hloc16);
- stack16->ds = oldDS;
- }
- else
-#endif
- LocalUnlock(es->hloc32A);
- }
+ else es->text = LocalLock(es->hloc32W);
}
if(es->flags & EF_APP_HAS_HANDLE) text_buffer_changed(es);
es->lock_count++;
if (force || (es->lock_count == 1)) {
if (es->hloc32W) {
- CHAR *textA = NULL;
UINT countA = 0;
UINT countW = get_text_length(es) + 1;
-#ifndef __REACTOS__
- STACK16FRAME* stack16 = NULL;
- HANDLE16 oldDS = 0;
-#endif
if(es->hloc32A)
{
else
WARN("FAILED! Will synchronize partially\n");
}
- textA = LocalLock(es->hloc32A);
+ WideCharToMultiByte(CP_ACP, 0, es->text, countW,
+ LocalLock(es->hloc32A), countA, NULL, NULL);
+ LocalUnlock(es->hloc32A);
}
-#ifndef __REACTOS__
- else if(es->hloc16)
- {
- UINT countA_new = WideCharToMultiByte(CP_ACP, 0, es->text, countW, NULL, 0, NULL, NULL);
- TRACE("Synchronizing with 16-bit ANSI buffer\n");
- TRACE("%d WCHARs translated to %d bytes\n", countW, countA_new);
-
- stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- oldDS = stack16->ds;
- stack16->ds = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
-
- countA = LocalSize16(es->hloc16);
- if(countA_new > countA)
- {
- HLOCAL16 hloc16_new;
- UINT alloc_size = ROUND_TO_GROW(countA_new);
- TRACE("Resizing 16-bit ANSI buffer from %d to %d bytes\n", countA, alloc_size);
- hloc16_new = LocalReAlloc16(es->hloc16, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
- if(hloc16_new)
- {
- es->hloc16 = hloc16_new;
- countA = LocalSize16(hloc16_new);
- TRACE("Real new size %d bytes\n", countA);
- }
- else
- WARN("FAILED! Will synchronize partially\n");
- }
- textA = MapSL(LocalLock16(es->hloc16));
- }
-#endif
-
- if(textA)
- {
- WideCharToMultiByte(CP_ACP, 0, es->text, countW, textA, countA, NULL, NULL);
-#ifndef __REACTOS__
- if(stack16)
- LocalUnlock16(es->hloc16);
- else
-#endif
- LocalUnlock(es->hloc32A);
- }
-
-#ifndef __REACTOS__
- if (stack16) stack16->ds = oldDS;
-#endif
LocalUnlock(es->hloc32W);
es->text = NULL;
}
INT vlc = get_vertical_line_count(es);
/* check if we are going to move too far */
if(es->y_offset + dy > es->line_count - vlc)
- dy = es->line_count - vlc - es->y_offset;
+ dy = max(es->line_count - vlc, 0) - es->y_offset;
/* Notification is done in EDIT_EM_LineScroll */
- if(dy)
+ if(dy) {
EDIT_EM_LineScroll(es, 0, dy);
+ return MAKELONG(dy, TRUE);
+ }
+
}
-#ifdef __REACTOS__
- return MAKELONG((SHORT)dy, (BOOL)TRUE);
-#else
- return MAKELONG((INT16)dy, (BOOL16)TRUE);
-#endif
+ return (LRESULT)FALSE;
}
}
-#ifndef __REACTOS__
-/*********************************************************************
- *
- * EM_GETHANDLE16
- *
- * Hopefully this won't fire back at us.
- * We always start with a buffer in 32 bit linear memory.
- * However, with this message a 16 bit application requests
- * a handle of 16 bit local heap memory, where it expects to find
- * the text.
- * It's a pitty that from this moment on we have to use this
- * local heap, because applications may rely on the handle
- * in the future.
- *
- * In this function we'll try to switch to local heap.
- */
-static HLOCAL16 EDIT_EM_GetHandle16(EDITSTATE *es)
-{
- CHAR *textA;
- UINT countA, alloc_size;
- STACK16FRAME* stack16;
- HANDLE16 oldDS;
-
- if (!(es->style & ES_MULTILINE))
- return 0;
-
- if (es->hloc16)
- return es->hloc16;
-
- stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- oldDS = stack16->ds;
- stack16->ds = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
-
- if (!LocalHeapSize16()) {
-
- if (!LocalInit16(stack16->ds, 0, GlobalSize16(stack16->ds))) {
- ERR("could not initialize local heap\n");
- goto done;
- }
- TRACE("local heap initialized\n");
- }
-
- countA = WideCharToMultiByte(CP_ACP, 0, es->text, -1, NULL, 0, NULL, NULL);
- alloc_size = ROUND_TO_GROW(countA);
-
- TRACE("Allocating 16-bit ANSI alias buffer\n");
- if (!(es->hloc16 = LocalAlloc16(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size))) {
- ERR("could not allocate new 16 bit buffer\n");
- goto done;
- }
-
- if (!(textA = MapSL(LocalLock16( es->hloc16)))) {
- ERR("could not lock new 16 bit buffer\n");
- LocalFree16(es->hloc16);
- es->hloc16 = 0;
- goto done;
- }
-
- WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL);
- LocalUnlock16(es->hloc16);
- es->flags |= EF_APP_HAS_HANDLE;
-
- TRACE("Returning %04X, LocalSize() = %d\n", es->hloc16, LocalSize16(es->hloc16));
-
-done:
- stack16->ds = oldDS;
- return es->hloc16;
-}
-#endif
-
-
/*********************************************************************
*
* EM_GETLINE
EDIT_UnlockBuffer(es, TRUE);
-#ifndef __REACTOS__
- if(es->hloc16)
- {
- STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- HANDLE16 oldDS = stack16->ds;
-
- stack16->ds = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
- LocalFree16(es->hloc16);
- stack16->ds = oldDS;
- es->hloc16 = 0;
- }
-#endif
-
if(es->is_unicode)
{
if(es->hloc32A)
}
-#ifndef __REACTOS__
-/*********************************************************************
- *
- * EM_SETHANDLE16
- *
- * FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ???
- *
- */
-static void EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc)
-{
- STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- HINSTANCE16 hInstance = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
- HANDLE16 oldDS = stack16->ds;
- INT countW, countA;
- HLOCAL hloc32W_new;
- WCHAR *textW;
- CHAR *textA;
-
- if (!(es->style & ES_MULTILINE))
- return;
-
- if (!hloc) {
- WARN("called with NULL handle\n");
- return;
- }
-
- EDIT_UnlockBuffer(es, TRUE);
-
- if(es->hloc32A)
- {
- LocalFree(es->hloc32A);
- es->hloc32A = NULL;
- }
-
- stack16->ds = hInstance;
- countA = LocalSize16(hloc);
- textA = MapSL(LocalLock16(hloc));
- countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
- if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
- {
- ERR("Could not allocate new unicode buffer\n");
- return;
- }
- textW = LocalLock(hloc32W_new);
- MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
- LocalUnlock(hloc32W_new);
- LocalUnlock16(hloc);
- stack16->ds = oldDS;
-
- if(es->hloc32W)
- LocalFree(es->hloc32W);
-
- es->hloc32W = hloc32W_new;
- es->hloc16 = hloc;
-
- es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
-
- es->flags |= EF_APP_HAS_HANDLE;
- EDIT_LockBuffer(es);
-
- es->x_offset = es->y_offset = 0;
- es->selection_start = es->selection_end = 0;
- EDIT_EM_EmptyUndoBuffer(es);
- es->flags &= ~EF_MODIFIED;
- es->flags &= ~EF_UPDATE;
- EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
- EDIT_UpdateText(es, NULL, TRUE);
- EDIT_EM_ScrollCaret(es);
- /* force scroll info update */
- EDIT_UpdateScrollInfo(es);
-}
-#endif
-
-
/*********************************************************************
*
* EM_SETLIMITTEXT
if (es->password_char == c)
return;
- style = GetWindowLongPtrW( es->hwndSelf, GWL_STYLE );
+ style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
es->password_char = c;
if (c) {
- SetWindowLongPtrW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
+ SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
es->style |= ES_PASSWORD;
} else {
- SetWindowLongPtrW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
+ SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
es->style &= ~ES_PASSWORD;
}
EDIT_UpdateText(es, NULL, TRUE);
es->tabs = NULL;
else {
es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
- if (es->tabs == NULL)
+ if (es->tabs == NULL) // reactos r33503
{
es->tabs_count = 0;
return FALSE;
- }
+ } // reactos r33503
memcpy(es->tabs, tabs, count * sizeof(INT));
}
return TRUE;
}
-#ifndef __REACTOS__
-/*********************************************************************
- *
- * EM_SETTABSTOPS16
- *
- */
-static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, const INT16 *tabs)
-{
- if (!(es->style & ES_MULTILINE))
- return FALSE;
- HeapFree(GetProcessHeap(), 0, es->tabs);
- es->tabs_count = count;
- if (!count)
- es->tabs = NULL;
- else {
- INT i;
- es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
- for (i = 0 ; i < count ; i++)
- es->tabs[i] = *tabs++;
- }
- return TRUE;
-}
-#endif
-
-
/*********************************************************************
*
* EM_SETWORDBREAKPROC
return;
es->word_break_proc = wbp;
-#ifndef __REACTOS__
- es->word_break_proc16 = NULL;
-#endif
-
- if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
- EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
- EDIT_UpdateText(es, NULL, TRUE);
- }
-}
-
-
-#ifndef __REACTOS__
-/*********************************************************************
- *
- * EM_SETWORDBREAKPROC16
- *
- */
-static void EDIT_EM_SetWordBreakProc16(EDITSTATE *es, EDITWORDBREAKPROC16 wbp)
-{
- if (es->word_break_proc16 == wbp)
- return;
- es->word_break_proc = NULL;
- es->word_break_proc16 = wbp;
if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
EDIT_UpdateText(es, NULL, TRUE);
}
}
-#endif
/*********************************************************************
ulength = strlenW(es->undo_text);
utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
- if (utext == NULL)
- return FALSE;
+ if (utext == NULL) // reactos r33503
+ return FALSE; // reactos r33503
strcpyW(utext, es->undo_text);
* controls without ES_WANTRETURN would attempt to detect whether it is inside
* a dialog box or not.
*/
-static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
+static inline BOOL EDIT_IsInsideDialog(EDITSTATE *es)
{
return (es->flags & EF_DIALOGMODE);
}
}
else if (es->style & ES_PASSWORD) {
/* clear selected text in password edit box even with empty clipboard */
- const WCHAR empty_strW[] = { 0 };
- EDIT_EM_ReplaceSel(es, TRUE, empty_strW, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, empty_stringW, TRUE, TRUE);
}
CloseClipboard();
}
*/
static inline void EDIT_WM_Clear(EDITSTATE *es)
{
- static const WCHAR empty_stringW[] = {0};
-
/* Protect read-only edit control from modification */
if(es->style & ES_READONLY)
return;
return 1;
}
+#if 0 // Removed see Revision 43925 comments.
+/*********************************************************************
+ *
+ * WM_COMMAND
+ *
+ */
+static void EDIT_WM_Command(EDITSTATE *es, INT code, INT id, HWND control)
+{
+ if (code || control)
+ return;
+
+ switch (id) {
+ case EM_UNDO:
+ SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
+ break;
+ case WM_CUT:
+ SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
+ break;
+ case WM_COPY:
+ SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
+ break;
+ case WM_PASTE:
+ SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
+ break;
+ case WM_CLEAR:
+ SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
+ break;
+ case EM_SETSEL:
+ EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE);
+ EDIT_EM_ScrollCaret(es);
+ break;
+ default:
+ ERR("unknown menu item, please report\n");
+ break;
+ }
+}
+#endif
+
/*********************************************************************
*
*/
static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
{
-#ifdef __REACTOS__
- HMENU menu = LoadMenuA(User32Instance, "EDITMENU");
-#else
HMENU menu = LoadMenuA(user32_module, "EDITMENU");
-#endif
HMENU popup = GetSubMenu(menu, 0);
UINT start = es->selection_start;
UINT end = es->selection_end;
y = rc.top + (rc.bottom - rc.top) / 2;
}
- selectedItem = TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, es->hwndSelf, NULL);
+ if (!(es->flags & EF_FOCUSED))
+ SetFocus(es->hwndSelf);
+#ifdef __REACTOS__
+ selectedItem = TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, es->hwndSelf, NULL);
+ // Added see Revision 43925 comments.
switch (selectedItem) {
case EM_UNDO:
SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
ERR("unknown menu item, please report\n");
break;
}
-
+#endif
DestroyMenu(menu);
}
nEUI = 2;
}
- SendMessageW(hLBox, WM_KEYDOWN, (WPARAM)key, 0);
+ SendMessageW(hLBox, WM_KEYDOWN, key, 0);
break;
case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
if (nEUI)
SendMessageW(hCombo, CB_SHOWDROPDOWN, bDropped ? FALSE : TRUE, 0);
else
- SendMessageW(hLBox, WM_KEYDOWN, (WPARAM)VK_F4, 0);
+ SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
break;
}
/* If the edit doesn't want the return send a message to the default object */
if(!(es->style & ES_MULTILINE) || !(es->style & ES_WANTRETURN))
{
- DWORD dw;
+ DWORD dw;
if (!EDIT_IsInsideDialog(es)) break;
if (control) break;
- dw = SendMessageW( es->hwndParent, DM_GETDEFID, 0, 0 );
+ dw = SendMessageW(es->hwndParent, DM_GETDEFID, 0, 0);
if (HIWORD(dw) == DC_HASDEFID)
{
HWND hwDefCtrl = GetDlgItem(es->hwndParent, LOWORD(dw));
if (hwDefCtrl)
{
- SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, (LPARAM)TRUE);
+ SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
}
}
SendMessageW(es->hwndParent, WM_NEXTDLGCTL, shift, 0);
break;
}
- return TRUE;
+ return TRUE;
}
EDIT_UpdateText(es, NULL, TRUE);
if (es->flags & EF_FOCUSED) {
DestroyCaret();
- CreateCaret(es->hwndSelf, 0, 2, es->line_height);
+ CreateCaret(es->hwndSelf, 0, 1, es->line_height);
EDIT_SetCaretPos(es, es->selection_end,
es->flags & EF_AFTER_WRAP);
ShowCaret(es->hwndSelf);
}
else
{
- static const WCHAR empty_stringW[] = {0};
TRACE("<NULL>\n");
EDIT_EM_ReplaceSel(es, FALSE, empty_stringW, FALSE, FALSE);
}
if (EDIT_CheckCombo(es, WM_SYSKEYDOWN, key))
return 0;
}
- return DefWindowProcW(es->hwndSelf, WM_SYSKEYDOWN, (WPARAM)key, (LPARAM)key_data);
+ return DefWindowProcW(es->hwndSelf, WM_SYSKEYDOWN, key, key_data);
}
case SB_THUMBPOSITION:
TRACE("SB_THUMBPOSITION %d\n", pos);
es->flags &= ~EF_HSCROLL_TRACK;
- if(GetWindowLongPtrW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
+ if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
dx = pos - es->x_offset;
else
{
* although it's also a regular control message.
*/
case EM_GETTHUMB: /* this one is used by NT notepad */
-#ifndef __REACTOS__
- case EM_GETTHUMB16:
-#endif
{
LRESULT ret;
- if(GetWindowLongPtrW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
+ if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
ret = GetScrollPos(es->hwndSelf, SB_HORZ);
else
{
TRACE("EM_GETTHUMB: returning %ld\n", ret);
return ret;
}
-#ifndef __REACTOS__
- case EM_LINESCROLL16:
+ case EM_LINESCROLL:
TRACE("EM_LINESCROLL16\n");
dx = pos;
break;
-#endif
default:
ERR("undocumented WM_HSCROLL action %d (0x%04x), please report\n",
* although it's also a regular control message.
*/
case EM_GETTHUMB: /* this one is used by NT notepad */
-#ifndef __REACTOS__
- case EM_GETTHUMB16:
-#endif
{
LRESULT ret;
- if(GetWindowLongPtrW( es->hwndSelf, GWL_STYLE ) & WS_VSCROLL)
+ if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_VSCROLL)
ret = GetScrollPos(es->hwndSelf, SB_VERT);
else
{
TRACE("EM_GETTHUMB: returning %ld\n", ret);
return ret;
}
-#ifndef __REACTOS__
- case EM_LINESCROLL16:
- TRACE("EM_LINESCROLL16 %d\n", pos);
+ case EM_LINESCROLL:
+ TRACE("EM_LINESCROLL %d\n", pos);
dy = pos;
break;
-#endif
default:
ERR("undocumented WM_VSCROLL action %d (0x%04x), please report\n",
*/
static LRESULT EDIT_EM_GetThumb(EDITSTATE *es)
{
-#ifdef __REACTOS__
return MAKELONG(EDIT_WM_VScroll(es, EM_GETTHUMB, 0),
- EDIT_WM_HScroll(es, EM_GETTHUMB, 0));
-#else
- return MAKELONG(EDIT_WM_VScroll(es, EM_GETTHUMB16, 0),
- EDIT_WM_HScroll(es, EM_GETTHUMB16, 0));
-#endif
+ EDIT_WM_HScroll(es, EM_GETTHUMB, 0));
}
+
/********************************************************************
*
* The Following code is to handle inline editing from IMEs
if (es->composition_len == 0 && es->selection_start != es->selection_end)
{
- static const WCHAR empty_stringW[] = {0};
EDIT_EM_ReplaceSel(es, TRUE, empty_stringW, TRUE, TRUE);
es->composition_start = es->selection_end;
}
alloc_size = ROUND_TO_GROW((es->buffer_size + 1) * sizeof(WCHAR));
if(!(es->hloc32W = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
- return FALSE;
+ goto cleanup;
es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
if (!(es->undo_text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (es->buffer_size + 1) * sizeof(WCHAR))))
- return FALSE;
+ goto cleanup;
es->undo_buffer_size = es->buffer_size;
if (es->style & ES_MULTILINE)
if (!(es->first_line_def = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
- return FALSE;
+ goto cleanup;
es->line_count = 1;
/*
if (lpcs->dwExStyle & WS_EX_CLIENTEDGE)
es->style &= ~WS_BORDER;
else if (es->style & WS_BORDER)
- SetWindowLongPtrW(hwnd, GWL_STYLE, es->style & ~WS_BORDER);
+ SetWindowLongW(hwnd, GWL_STYLE, es->style & ~WS_BORDER);
return TRUE;
+
+cleanup:
+ SetWindowLongPtrW(es->hwndSelf, 0, 0);
+ HeapFree(GetProcessHeap(), 0, es->first_line_def);
+ HeapFree(GetProcessHeap(), 0, es->undo_text);
+ if (es->hloc32W) LocalFree(es->hloc32W);
+ HeapFree(GetProcessHeap(), 0, es);
+ return FALSE;
}
/*********************************************************************
*
- * WM_DESTROY
+ * WM_NCDESTROY
*
*/
-static LRESULT EDIT_WM_Destroy(EDITSTATE *es)
+static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
{
LINEDEF *pc, *pp;
if (es->hloc32A) {
LocalFree(es->hloc32A);
}
-#ifndef __REACTOS__
- if (es->hloc16) {
- STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
- HANDLE16 oldDS = stack16->ds;
-
- stack16->ds = GetWindowLongPtrW( es->hwndSelf, GWLP_HINSTANCE );
- while (LocalUnlock16(es->hloc16)) ;
- LocalFree16(es->hloc16);
- stack16->ds = oldDS;
- }
-#endif
-
pc = es->first_line_def;
while (pc)
{
pc = pp;
}
- SetWindowLongPtrW( es->hwndSelf, 0, 0 );
+ SetWindowLongPtrW( es->hwndSelf, 0, 0 );
+ HeapFree(GetProcessHeap(), 0, es->undo_text);
HeapFree(GetProcessHeap(), 0, es);
return 0;
*
* The messages are in the order of the actual integer values
* (which can be found in include/windows.h)
- * Wherever possible the 16 bit versions are converted to
- * the 32 bit ones, so that we can 'fall through' to the
- * helper functions. These are mostly 32 bit (with a few
- * exceptions, clearly indicated by a '16' extension to their
- * names).
- *
*/
-LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
- WPARAM wParam, LPARAM lParam, BOOL unicode )
+LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode )
{
EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW( hwnd, 0 );
LRESULT result = 0;
+#ifdef __REACTOS__
+ PWND pWnd;
+
+ pWnd = ValidateHwnd(hwnd);
+ if (pWnd)
+ {
+ if (!pWnd->fnid)
+ {
+ NtUserSetWindowFNID(hwnd, FNID_EDIT);
+ }
+ }
+#endif
TRACE("hwnd=%p msg=%x (%s) wparam=%lx lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
if (!es && msg != WM_NCCREATE)
return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
- if (es && (msg != WM_DESTROY)) EDIT_LockBuffer(es);
+ if (es && (msg != WM_NCDESTROY)) EDIT_LockBuffer(es);
switch (msg) {
-#ifndef __REACTOS__
- case EM_GETSEL16:
- wParam = 0;
- lParam = 0;
- /* fall through */
-#endif
case EM_GETSEL:
result = EDIT_EM_GetSel(es, (PUINT)wParam, (PUINT)lParam);
break;
-#ifndef __REACTOS__
- case EM_SETSEL16:
- if ((short)LOWORD(lParam) == -1)
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
- else
- EDIT_EM_SetSel(es, LOWORD(lParam), HIWORD(lParam), FALSE);
- if (!wParam)
- EDIT_EM_ScrollCaret(es);
- result = 1;
- break;
-#endif
case EM_SETSEL:
EDIT_EM_SetSel(es, wParam, lParam, FALSE);
EDIT_EM_ScrollCaret(es);
result = 1;
break;
-#ifndef __REACTOS__
- case EM_GETRECT16:
- if (lParam)
- {
- RECT16 *r16 = MapSL(lParam);
- r16->left = es->format_rect.left;
- r16->top = es->format_rect.top;
- r16->right = es->format_rect.right;
- r16->bottom = es->format_rect.bottom;
- }
- break;
-#endif
case EM_GETRECT:
if (lParam)
CopyRect((LPRECT)lParam, &es->format_rect);
break;
-#ifndef __REACTOS__
- case EM_SETRECT16:
- if ((es->style & ES_MULTILINE) && lParam) {
- RECT rc;
- RECT16 *r16 = MapSL(lParam);
- rc.left = r16->left;
- rc.top = r16->top;
- rc.right = r16->right;
- rc.bottom = r16->bottom;
- EDIT_SetRectNP(es, &rc);
- EDIT_UpdateText(es, NULL, TRUE);
- }
- break;
-#endif
case EM_SETRECT:
if ((es->style & ES_MULTILINE) && lParam) {
EDIT_SetRectNP(es, (LPRECT)lParam);
}
break;
-#ifndef __REACTOS__
- case EM_SETRECTNP16:
- if ((es->style & ES_MULTILINE) && lParam) {
- RECT rc;
- RECT16 *r16 = MapSL(lParam);
- rc.left = r16->left;
- rc.top = r16->top;
- rc.right = r16->right;
- rc.bottom = r16->bottom;
- EDIT_SetRectNP(es, &rc);
- }
- break;
-#endif
case EM_SETRECTNP:
if ((es->style & ES_MULTILINE) && lParam)
EDIT_SetRectNP(es, (LPRECT)lParam);
break;
-#ifndef __REACTOS__
- case EM_SCROLL16:
-#endif
case EM_SCROLL:
result = EDIT_EM_Scroll(es, (INT)wParam);
break;
-#ifndef __REACTOS__
- case EM_LINESCROLL16:
- wParam = (WPARAM)(INT)(SHORT)HIWORD(lParam);
- lParam = (LPARAM)(INT)(SHORT)LOWORD(lParam);
- /* fall through */
-#endif
case EM_LINESCROLL:
result = (LRESULT)EDIT_EM_LineScroll(es, (INT)wParam, (INT)lParam);
break;
-#ifndef __REACTOS__
- case EM_SCROLLCARET16:
-#endif
case EM_SCROLLCARET:
EDIT_EM_ScrollCaret(es);
result = 1;
break;
-#ifndef __REACTOS__
- case EM_GETMODIFY16:
-#endif
case EM_GETMODIFY:
result = ((es->flags & EF_MODIFIED) != 0);
break;
-#ifndef __REACTOS__
- case EM_SETMODIFY16:
-#endif
case EM_SETMODIFY:
if (wParam)
es->flags |= EF_MODIFIED;
es->flags &= ~(EF_MODIFIED | EF_UPDATE); /* reset pending updates */
break;
-#ifndef __REACTOS__
- case EM_GETLINECOUNT16:
-#endif
case EM_GETLINECOUNT:
result = (es->style & ES_MULTILINE) ? es->line_count : 1;
break;
-#ifndef __REACTOS__
- case EM_LINEINDEX16:
- if ((INT16)wParam == -1)
- wParam = (WPARAM)-1;
- /* fall through */
-#endif
case EM_LINEINDEX:
result = (LRESULT)EDIT_EM_LineIndex(es, (INT)wParam);
break;
-#ifndef __REACTOS__
- case EM_SETHANDLE16:
- EDIT_EM_SetHandle16(es, (HLOCAL16)wParam);
- break;
-#endif
case EM_SETHANDLE:
EDIT_EM_SetHandle(es, (HLOCAL)wParam);
break;
-#ifndef __REACTOS__
- case EM_GETHANDLE16:
- result = (LRESULT)EDIT_EM_GetHandle16(es);
- break;
-#endif
case EM_GETHANDLE:
result = (LRESULT)EDIT_EM_GetHandle(es);
break;
-#ifndef __REACTOS__
- case EM_GETTHUMB16:
-#endif
case EM_GETTHUMB:
result = EDIT_EM_GetThumb(es);
break;
/* these messages missing from specs */
- case WM_USER+15:
case 0x00bf:
- case WM_USER+16:
case 0x00c0:
- case WM_USER+19:
case 0x00c3:
- case WM_USER+26:
case 0x00ca:
FIXME("undocumented message 0x%x, please report\n", msg);
result = DefWindowProcW(hwnd, msg, wParam, lParam);
break;
-#ifndef __REACTOS__
- case EM_LINELENGTH16:
-#endif
case EM_LINELENGTH:
result = (LRESULT)EDIT_EM_LineLength(es, (INT)wParam);
break;
-#ifndef __REACTOS__
- case EM_REPLACESEL16:
- lParam = (LPARAM)MapSL(lParam);
- unicode = FALSE; /* 16-bit message is always ascii */
- /* fall through */
-#endif
case EM_REPLACESEL:
{
LPWSTR textW;
{
LPSTR textA = (LPSTR)lParam;
INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
- if(!(textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) break;
- MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
+ if (!(textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) break;
+ MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
}
EDIT_EM_ReplaceSel(es, (BOOL)wParam, textW, TRUE, TRUE);
break;
}
-#ifndef __REACTOS__
- case EM_GETLINE16:
- lParam = (LPARAM)MapSL(lParam);
- unicode = FALSE; /* 16-bit message is always ascii */
- /* fall through */
-#endif
case EM_GETLINE:
result = (LRESULT)EDIT_EM_GetLine(es, (INT)wParam, (LPWSTR)lParam, unicode);
break;
-#ifndef __REACTOS__
- case EM_LIMITTEXT16:
-#endif
case EM_SETLIMITTEXT:
EDIT_EM_SetLimitText(es, wParam);
break;
-#ifndef __REACTOS__
- case EM_CANUNDO16:
-#endif
case EM_CANUNDO:
result = (LRESULT)EDIT_EM_CanUndo(es);
break;
-#ifndef __REACTOS__
- case EM_UNDO16:
-#endif
case EM_UNDO:
case WM_UNDO:
result = (LRESULT)EDIT_EM_Undo(es);
break;
-#ifndef __REACTOS__
- case EM_FMTLINES16:
-#endif
case EM_FMTLINES:
result = (LRESULT)EDIT_EM_FmtLines(es, (BOOL)wParam);
break;
-#ifndef __REACTOS__
- case EM_LINEFROMCHAR16:
-#endif
case EM_LINEFROMCHAR:
result = (LRESULT)EDIT_EM_LineFromChar(es, (INT)wParam);
break;
-#ifndef __REACTOS__
- case EM_SETTABSTOPS16:
- result = (LRESULT)EDIT_EM_SetTabStops16(es, (INT)wParam, MapSL(lParam));
- break;
-#endif
case EM_SETTABSTOPS:
result = (LRESULT)EDIT_EM_SetTabStops(es, (INT)wParam, (LPINT)lParam);
break;
-#ifndef __REACTOS__
- case EM_SETPASSWORDCHAR16:
- unicode = FALSE; /* 16-bit message is always ascii */
- /* fall through */
-#endif
case EM_SETPASSWORDCHAR:
{
WCHAR charW = 0;
break;
}
-#ifndef __REACTOS__
- case EM_EMPTYUNDOBUFFER16:
-#endif
case EM_EMPTYUNDOBUFFER:
EDIT_EM_EmptyUndoBuffer(es);
break;
-#ifndef __REACTOS__
- case EM_GETFIRSTVISIBLELINE16:
- result = es->y_offset;
- break;
-#endif
case EM_GETFIRSTVISIBLELINE:
result = (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;
break;
-#ifndef __REACTOS__
- case EM_SETREADONLY16:
-#endif
case EM_SETREADONLY:
{
DWORD old_style = es->style;
if (wParam) {
- SetWindowLongPtrW( hwnd, GWL_STYLE,
- GetWindowLongPtrW( hwnd, GWL_STYLE ) | ES_READONLY );
+ SetWindowLongW( hwnd, GWL_STYLE,
+ GetWindowLongW( hwnd, GWL_STYLE ) | ES_READONLY );
es->style |= ES_READONLY;
} else {
- SetWindowLongPtrW( hwnd, GWL_STYLE,
- GetWindowLongPtrW( hwnd, GWL_STYLE ) & ~ES_READONLY );
+ SetWindowLongW( hwnd, GWL_STYLE,
+ GetWindowLongW( hwnd, GWL_STYLE ) & ~ES_READONLY );
es->style &= ~ES_READONLY;
}
break;
}
-#ifndef __REACTOS__
- case EM_SETWORDBREAKPROC16:
- EDIT_EM_SetWordBreakProc16(es, (EDITWORDBREAKPROC16)lParam);
- break;
-#endif
case EM_SETWORDBREAKPROC:
EDIT_EM_SetWordBreakProc(es, (void *)lParam);
break;
-#ifndef __REACTOS__
- case EM_GETWORDBREAKPROC16:
- result = (LRESULT)es->word_break_proc16;
- break;
-#endif
case EM_GETWORDBREAKPROC:
result = (LRESULT)es->word_break_proc;
break;
-#ifndef __REACTOS__
- case EM_GETPASSWORDCHAR16:
- unicode = FALSE; /* 16-bit message is always ascii */
- /* fall through */
-#endif
case EM_GETPASSWORDCHAR:
{
if(unicode)
break;
}
- /* The following EM_xxx are new to win95 and don't exist for 16 bit */
-
case EM_SETMARGINS:
EDIT_EM_SetMargins(es, (INT)wParam, LOWORD(lParam), HIWORD(lParam), TRUE);
break;
result = EDIT_WM_NCCreate(hwnd, (LPCREATESTRUCTW)lParam, unicode);
break;
- case WM_DESTROY:
- result = EDIT_WM_Destroy(es);
- es = NULL;
+ case WM_NCDESTROY:
+ result = EDIT_WM_NCDestroy(es);
+// es = NULL; reactos
+#ifdef __REACTOS__
+ NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+#endif
break;
case WM_GETDLGCODE:
case WM_CLEAR:
EDIT_WM_Clear(es);
break;
-
- case WM_CONTEXTMENU:
+#if 0 // Removed see Revision 43925 comments.
+ case WM_COMMAND:
+ EDIT_WM_Command(es, HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
+ break;
+#endif
+ case WM_CONTEXTMENU:
EDIT_WM_ContextMenu(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
break;
break;
case WM_MBUTTONDOWN:
- result = EDIT_WM_MButtonDown(es);
+ result = EDIT_WM_MButtonDown(es);
break;
case WM_MOUSEMOVE:
}
break;
-
- /* IME messages to make the edit control IME aware */
+
+ /* IME messages to make the edit control IME aware */
case WM_IME_SETCONTEXT:
break;
case WM_IME_ENDCOMPOSITION:
if (es->composition_len > 0)
{
- static const WCHAR empty_stringW[] = {0};
EDIT_EM_ReplaceSel(es, TRUE, empty_stringW, TRUE, TRUE);
es->selection_end = es->selection_start;
es->composition_len= 0;
break;
}
- if (IsWindow(hwnd) && es) EDIT_UnlockBuffer(es, FALSE);
+ /* reactos: check GetWindowLong in case es has been destroyed during processing */
+ if (IsWindow(hwnd) && es && GetWindowLongPtrW(hwnd, 0))
+ EDIT_UnlockBuffer(es, FALSE);
TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
CS_DBLCLKS | CS_PARENTDC, /* style */
EditWndProcA, /* procA */
EditWndProcW, /* procW */
-#ifdef _WIN64
- sizeof(EDITSTATE *), /* extra */
-#else
+#ifndef _WIN64
sizeof(EDITSTATE *) + sizeof(WORD), /* extra */
+#else
+ sizeof(EDITSTATE *), /* extra */
#endif
IDC_IBEAM, /* cursor */
0 /* brush */