Thread: Edit Box Input

  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29

    Edit Box Input

    Hi guys, I know how to draw and position edit boxes in my programs, but I can't seem to get the to accept input can someone help me out and also I don't know how to take the input in and store it in the program (for obvious reasons)

    Thanks in advance for the help

  2. #2

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Always check out MSDN:

    http://msdn2.microsoft.com/en-us/library/ms672060.aspx

    The default behavior of an editbox, I believe, when you press Enter, is to press the first button on the same window. If you want it to do something different, consider subclassing it.

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    The default behavior of an editbox, I believe, when you press Enter, is to press the first button on the same window.
    That's not the case. Nurfina, use SetWindowLong() to subclass it.

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Queatrix View Post
    That's not the case. Nurfina, use SetWindowLong() to subclass it.
    http://support.microsoft.com/kb/102589

    If a dialog box or one of its controls currently has the input focus, then pressing the ENTER key causes Windows to send a WM_COMMAND message with the idItem (wParam) parameter set to the ID of the default command button. If the dialog box does not have a default command button, then the idItem parameter is set to IDOK by default.
    Bold addition mine. The above is what I was referring to.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    Cool thanks guys . . . having some issues just now with my edit box it's not showing, but thanks for the help on how to get input from it

  7. #7
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    Hi again guys, sorry to be a pain, but still having some issues, my edit boxes wont actually let me type into them, it doesn't accept key presses, can anyone help me out, and also I would like to know how to change the background colour and text colour if it's not too much trouble

    Thanks in advance

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Are you using a resource file to create your dialog box and editcontrol?

    Show us some code?

  9. #9
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    No I am doing it all through the CreateWindowEx function my code :

    Code:
    void Setup_Edit (Window* window, Edit & edit, char const * caption, int x, int y, int width, int height, int ID, DWORD exStyle)
    {
    	edit._style = WS_CHILD | WS_VISIBLE;
    	edit._caption = caption;
    	edit._exStyle = exStyle;
    	edit._x = x;														// horizontal position of Button
    	edit._y = y;														// vertical position od Button
    	edit._width = width;												// Button width
    	edit._height = height;												// Button height
    	edit._hWndParent = window->hWnd;									// handle to parent or owner Button
    	edit._data = 0;														// pointer to Button-creation data
    	edit._ID = ID;
    
    	Create_Edit(window, edit);
    }
    
    HWND Create_Edit (Window* window, Edit & edit)
    {
    	edit.hwnd = ::CreateWindowEx (
    		edit._exStyle,
    		"EDIT",
    		edit._caption,
    		edit._style,
    		edit._x,
    		edit._y,
    		edit._width,
    		edit._height,
    		edit._hWndParent,
    		(HMENU) edit._ID,
    		window->init.application->hInstance,
    		edit._data);
    
    	if (edit.hwnd == 0)
    		TerminateApplication(window);
    
    	return edit.hwnd;
    }
    
    . . .
    
    Setup_Edit(m_window, menu->login.UserName, "User Name", ((m_window->init.width / 2) + 3), 200, 150, 50, IDC_LUSERNAME, 0);
    Looks like that

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I don't see anything obviously wrong, although your method of creating a simple edit box seems rather complicated.....

  11. #11
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  2. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  3. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 07:15 PM
  4. setting fixed floats in edit box
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 08-13-2004, 09:13 AM
  5. Limiting Characters in Edit Box :: MFC
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 06-02-2002, 10:21 AM