I'm trying to pick only the pasted part of a text inside a subclassed editbox while intercepting the WM_PASTE case, in the following way :
case WM_PASTE:
{
int length = SendMessageW(MainEdit, WM_GETTEXTLENGTH, 0, 0);
CallWindowProc(DefaultEditProc, hwnd, uMsg, wParam, lParam);
int length2 = SendMessageW(MainEdit, WM_GETTEXTLENGTH, 0, 0);
LPSTR buffer = (LPSTR)GlobalAlloc(GPTR, length2 + 1);
GetWindowTextA(MainEdit, buffer, sizeof(buffer));
MessageBoxA(hwnd, buffer, "nnt", MB_OK);
GlobalFree(buffer);
}
break;
The code above shows in the messagebox only 3 characters out of supposed 16 (or whatever number, for all that matter)
Tried also using a normal buffer :
wchar_t buffer[] = new wchar_t[length2 + 1];
memset(buffer, 0, sizeof(buffer));
GetWindowTextA(MainEdit, buffer, sizeof(buffer));
delete[] buffer;
If I were to use a normal array buffer the code runs just fine, but since my project involves undefined-lenght pasting processes I can't just place a fixed value.