How do you destroy an editbox?
Printable View
How do you destroy an editbox?
PostQuitMessage(0);
That'll work but is, perhaps, overkill. ;)
DestroyWindow.
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()).
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();
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.Quote:
Originally Posted by Cool-August
That would cause a leak. If you assign a newly created control to your handle, the old control still exists.Quote:
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.
I use this:
When I activate 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));
Nothing happens.Code:DestroyWindow(hEdit);
What is the value of hEdit?
You've not assigned anything to hEdit.
You just declared it:
Then you created the edit control, but you did not assign the return value to hEdit.Code:HWND 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));
And how do I do that?
Somehow, I knew you were going to ask me that.
Code:hEdit = CreateWindowEx( ...etc... );
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.