How do you destroy an editbox?

This is a discussion on How do you destroy an editbox? within the Windows Programming forums, part of the Platform Specific Boards category; How do you destroy an editbox?...

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

    Question How do you destroy an editbox?

    How do you destroy an editbox?

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    PostQuitMessage(0);

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    That'll work but is, perhaps, overkill.

    DestroyWindow.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Apoligies for confusing answer. I was confused between an EditBox (a window that can use CreateWindow() and DestroyWindow()), and a Menu (which uses CreateMenu() and SetMenu() and DestroyMenu()).
    Last edited by Lithorien; 05-12-2005 at 06:16 PM. Reason: Misunderstood OP.

  5. #5
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    Meow!

    Nuked the litter box again. In most cases usually when one wants to destroy a editbox they also want to terminate the proggie? yes? unless it is one of those extra long proggies. or app.

    Nuclear is an option? Thought it was obligatorie.

    edit:

    NukeWindow();
    Last edited by kryptkat; 05-12-2005 at 04:54 PM.

  6. #6
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I guess I said it wrong or somthing but, I want to destroy the Editbox, but not the window.
    Last edited by Queatrix; 05-12-2005 at 05:12 PM.

  7. #7
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Quote Originally Posted by Cool-August
    I guess I said it wrong or somthing but, I want to destroy the Editbox, but not the window.
    The editbox is a window. DestroyWindow would destroy it.

    Then, when you need to destroy your edit box, set hEdit (or whatever you use) to NULL, and call your 'window creation' function again. In practice, all this will do is refresh your window minus the edit box.
    That would cause a leak. If you assign a newly created control to your handle, the old control still exists.
    Last edited by Dante Shamest; 05-12-2005 at 05:25 PM.

  8. #8
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I use this:

    Code:
     
    HFONT hfDefault;
    HWND hEdit;
    CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
    WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 
    2, 2, 391, 170, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    When I activate this:

    Code:
    DestroyWindow(hEdit);
    Nothing happens.

  9. #9
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    What is the value of hEdit?

    You've not assigned anything to hEdit.

    You just declared it:

    Code:
    HWND hEdit;
    Then you created the edit control, but you did not assign the return value to hEdit.

    Code:
    CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
    WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 
    2, 2, 391, 170, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));

  10. #10
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    And how do I do that?

  11. #11
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Somehow, I knew you were going to ask me that.

    Code:
    hEdit = CreateWindowEx( ...etc... );

  12. #12
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    Make sure the HWND is static or global if it is declared in the callback (or it will loose scope).

    Or use GetDlgItem() ect to get the edits HWND again when needed.
    "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. Replies: 2
    Last Post: 08-25-2005, 03:09 PM
  2. Create two buttons that interact with an editbox
    By Arkanos in forum Windows Programming
    Replies: 8
    Last Post: 07-13-2005, 12:56 AM
  3. Create two buttons that interact with an editbox
    By Arkanos in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2005, 01:17 AM
  4. editbox problem
    By tyouk in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2004, 09:14 PM
  5. Editbox problems
    By Devil Panther in forum Windows Programming
    Replies: 9
    Last Post: 07-27-2003, 04:12 PM

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