Edit box not working

This is a discussion on Edit box not working within the Windows Programming forums, part of the Platform Specific Boards category; Here is my code for creating an edit box: Code: CreateWindow("Edit", "Test", WS_CHILD|WS_VISIBLE, 100, 300, 100, 20, hwnd, 0, 0, ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    Edit box not working

    Here is my code for creating an edit box:

    Code:
    CreateWindow("Edit", "Test", WS_CHILD|WS_VISIBLE, 100, 300, 100, 20, hwnd, 0, 0, NULL);
    hwnd is a valid parent window.

    It apears and apears to work fine but I am not able to type or delete stuff inside the textbox. I already figured out that read only is not the problem, anyone got other ideas?

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What window has current focus? Try using SetFocus.
    "...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

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Oh yes the textbox has focus. The carrot is even blinking and I can highlet text in the textbox.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    That should be all there is to it. Maybe you can post more code? Why don't you open up a new project and just add that call in there and see if it works (it should). Then try to see what could be different. What you have should be fine, but there maybe some interference in the code you haven't listed.
    "...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

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Most likely something wrong with your window procedure. Are you calling DefWindowProc?

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Yes I am, this code was my whole problem:

    Code:
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    I had almost the same thing before but a bit different. Not sure where I got the other one but I most always use this one wich works.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    It's actually better if you do your message pump like this:
    Code:
    BOOL bRet;
    
    while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
    { 
        if (bRet == -1)
        {
            // handle the error and possibly exit
        }
        else
        {
            TranslateMessage(&msg); 
            DispatchMessage(&msg); 
        }
    }
    This way your code can handle a GetMessage() error.

  8. #8
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    I also had anouther way that is more for games wich I also like alot. Don't have time to look it up but I will use the one above, could use error handling.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 07:15 PM
  2. setting fixed floats in edit box
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 08-13-2004, 10:13 AM
  3. Limit of Edit Box
    By osal in forum Windows Programming
    Replies: 0
    Last Post: 07-15-2004, 12:58 PM
  4. Limiting Characters in Edit Box :: MFC
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 06-02-2002, 11:21 AM
  5. How do i make a "new line" with in an edit box?
    By Clyde in forum Windows Programming
    Replies: 3
    Last Post: 05-18-2002, 02:35 PM

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