Edit Boxes, I need specifics..

This is a discussion on Edit Boxes, I need specifics.. within the Windows Programming forums, part of the Platform Specific Boards category; I have about 10 edit boxes in a dialog box. I can have people enter strings into them and retrieve ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Edit Boxes, I need specifics..

    I have about 10 edit boxes in a dialog box. I can have people enter strings into them and retrieve them no problem. I need to limit them to only one character though. Right now I can OBTAIN the first character if the enter a bunch but I don't want to display the other keys they hit just the first. This is for a key configuration setup in a game I am writing. Also, I assume I need to use sub-classing and give the edit controls their own wndproc so I can catch keyup messages for each key they press? Because I need to know if they hit TAB and want that as one of their buttons. I also need to write TAB in the box in that case. Just wondering the best approach to this. Thanks in advance.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You could try sending the edit a EM_SETLIMITTEXT message to set the maximum amount of chars

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Ah, ok that would probably do the trick! There are a lot of these those as I stated but oh well. Also, Fordy, do you have know of any good sites with win32 sub-classing tutorials? I tried google but came up empty handed.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by MrWizard
    Also, Fordy, do you have know of any good sites with win32 sub-classing tutorials? I tried google but came up empty handed.
    Not really.......there's stuff on this board......lookup the function SetWindowLong on the search..

    Also, this was on my SDK docs and should give a little idea

    Code:
    WNDPROC wpOrigEditProc; 
     
    LRESULT APIENTRY EditBoxProc(
        HWND hwndDlg, 
        UINT uMsg, 
        WPARAM wParam, 
        LPARAM lParam) 
    { 
        HWND hwndEdit; 
     
        switch(uMsg) 
        { 
            case WM_INITDIALOG: 
                // Retrieve the handle to the edit control. 
                hwndEdit = GetDlgItem(hwndDlg, ID_EDIT); 
     
                // Subclass the edit control. 
                wpOrigEditProc = (WNDPROC) SetWindowLong(hwndEdit, 
                    GWL_WNDPROC, (LONG) EditSubclassProc); 
                // 
                // Continue the initialization procedure. 
                // 
                return TRUE; 
     
            case WM_DESTROY: 
                // Remove the subclass from the edit control. 
                SetWindowLong(hwndEdit, GWL_WNDPROC, 
                    (LONG) wpOrigEditProc); 
                // 
                // Continue the cleanup procedure. 
                // 
                break; 
        } 
        return FALSE; 
            UNREFERENCED_PARAMETER(lParam); 
    } 
     
    // Subclass procedure 
    LRESULT APIENTRY EditSubclassProc(
        HWND hwnd, 
        UINT uMsg, 
        WPARAM wParam, 
        LPARAM lParam) 
    { 
        if (uMsg == WM_GETDLGCODE) 
            return DLGC_WANTALLKEYS; 
     
        return CallWindowProc(wpOrigEditProc, hwnd, uMsg, 
            wParam, lParam); 
    }

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Fordy
    Code:
    if (uMsg == WM_GETDLGCODE) 
            return DLGC_WANTALLKEYS; 
     
        return CallWindowProc(wpOrigEditProc, hwnd, uMsg, 
            wParam, lParam); 
    }
    Yes, This is perfect! Thank you very much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 07:46 AM
  2. Edit box(es), and specialized onmouseover
    By Lurker in forum Windows Programming
    Replies: 7
    Last Post: 05-25-2003, 04:13 PM
  3. Edit Boxes
    By ColdFire in forum Windows Programming
    Replies: 2
    Last Post: 02-13-2002, 01:54 PM
  4. please help visual c++ edit control boxes
    By alcoholic in forum C++ Programming
    Replies: 3
    Last Post: 02-05-2002, 01:39 PM
  5. Password Edit Boxes
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2001, 02:40 PM

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