Question about Edit Boxes

This is a discussion on Question about Edit Boxes within the Windows Programming forums, part of the Platform Specific Boards category; Hey, does anyone know how to clear edits in win32? This is what i have but its not working, its ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    387

    Question about Edit Boxes

    Hey, does anyone know how to clear edits in win32?
    This is what i have but its not working, its compiling fine but when i click 'Clear' nothing happens.

    PHP Code:
    HWND NAME;
    HWND MESSAGE;
    HWND CLEAR;

    switch(&
    msg)
    {
         case 
    WM_CREATE:

         
    NAME    CreateWindowEx(0TEXT("EDIT"), "Username"WS_CHILD WS_VISIBLE2514035020hwnd, (HMENU)IDC_NAMEhInstanceNULL);

         
    MESSAGE CreateWindowEx(0TEXT("EDIT"), "Message"WS_CHILD WS_VISIBLE ES_MULTILINE25170350100hwnd, (HMENU)IDC_MESSAGEhInstanceNULL);

         
    CLEAR   CreateWindowEx(0TEXT("BUTTON"), "Clear"WS_CHILD WS_VISIBLE BS_FLAT19828017520hwnd, (HMENU)IDC_CLEARhInstanceNULL);

         break;

         case 
    WM_COMMAND:
           {
                 switch(
    LOWORD(wParam))
                      {
                                case 
    IDC_CLEAR:
                                    
                                    
    SetWindowText(NAMETEXT(" "));
                                    
    SetWindowText(MESSAGETEXT(" "));
                                    
                                    break;
                      }
           }
            break;


  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You need to check the lParam of WM_COMMAND to ensure the msg/id is from a valid control.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    nope, that didnt work
    when i click the clear button, nothing happens

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    worked fine for me. Check reply to pm you sent as explicit code is given there.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    i did, but it didnt work

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Perhaps you could zip up and attach your code so that we could take a closer look and maybe get a better idea of what the problem is? If you want to, of course.

    Other than that I can only suggest you also try looking for the BN_CLICKED msg coming into your WM_COMMAND handler and so cover all possibilities there.

    ie in your WM_COMMAND handler:
    Code:
    if (lParam)
      {
      //must be a control, so check for btn click msg
      if (HIWORD(wParam)==BN_CLICKED)
        {
         //button must have been clicked, so check for id
         if (LOWORD(wParam)==IDC_CLEAR)
           {
           //'clear' btn clicked
           SetWindowText(NAME, TEXT(""));
           SetWindowText(MESSAGE, TEXT(""));
           }
        }
      }

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    And ensure the HWND's are static's if inside the callback.
    "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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edit box question
    By learning110 in forum Windows Programming
    Replies: 6
    Last Post: 03-28-2003, 07:16 PM
  2. Edit Boxes
    By ColdFire in forum Windows Programming
    Replies: 2
    Last Post: 02-13-2002, 01:54 PM
  3. please help visual c++ edit control boxes
    By alcoholic in forum C++ Programming
    Replies: 3
    Last Post: 02-05-2002, 01:39 PM
  4. edit boxes
    By face_master in forum Windows Programming
    Replies: 2
    Last Post: 01-25-2002, 04:47 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