Em_limittext

This is a discussion on Em_limittext within the Windows Programming forums, part of the Platform Specific Boards category; 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: ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    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.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    try using the MAKEWPARAM() macro from windows.h
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    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.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    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.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21