I am setting a text limit for one of my edit controls like this:
When I call:
This alwasy returns 0 but I'm setting the limit to 3? I also can type over 3 characters into the edit box. Why isn't this working? Sending that message to my edit box should only allow 3 characters to be typed into the edit box, but this is not the case. Thanks.
try using the MAKEWPARAM() macro from windows.h
Ok, I've tried that with different combinations for hi and lo words. I tried:
But this still doesn't work. Any more suggestions? Thanks.
First I verified that the following works correctly:
All I can really say about your code is that 'num1' seems a bit of a strange HWND to me. Maybe you can show us more code.
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
static HBRUSH hBrush;
static HWND hEdit;
static LRESULT lResult;
static char buffer;
switch (message) /* handle the messages */
hEdit = CreateWindowEx (
0, "EDIT", "", WS_CHILD | WS_VISIBLE,
10, 10, 50, 16,
hwnd, NULL, NULL, NULL);
SendMessage(hEdit, EM_LIMITTEXT, WPARAM(3), 0);
lResult = SendMessage(hEdit,EM_GETLIMITTEXT,0,0);
wsprintf(buffer, "%i", lResult);
MessageBox(hwnd, buffer, "Caption", MB_OK);