-
Em_limittext
I am setting a text limit for one of my edit controls like this:
Code:
SendMessage(num1,EM_LIMITTEXT,(WPARAM)3,0);
When I call:
Code:
SendMessage(num1,EM_GETLIMITTEXT,0,0);
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:
Code:
MAKEWPARAM(3,3);
//and
MAKEWPARAM(0,3);
//and
MAKEWPARAM(3,0);
But this still doesn't work. Any more suggestions? Thanks.
-
First I verified that the following works correctly:
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HBRUSH hBrush;
static HWND hEdit;
static LRESULT lResult;
static char buffer[16];
switch (message) /* handle the messages */
{
case WM_CREATE:
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);
break;
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.