I have a button in the main window, and the question came to me: ¿Como hago para eliminar ese mismo boton en tiempo de ejecucción
. I thought to call the function: SendDlgItemMessage
:
#include <windows.h>
#define ID_BUTTON 119
...
LRESULT CALLBACK WindowProcedure( HWND hwnd,UINT msg,WPARA wParam,LPARAM lParam ){
switch(msg){
case WM_CREATE:
CreateWindow("button","Click Me for deleted mi.",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,200,200,40,20,hwnd,(HMENU)ID_BUTTON,NULL,0 );
break;
case WM_COMMAND:
switch( wParam ){
case ID_BUTTON:
SendDlgItemMessage( hwnd,ID_BUTTON,WM_DESTROY,0,0);
break;
}
break;
...
}
return 0;
}
Since the button is really a window, I decided to send it the message WM_DESTROY
so that it will close, but when I click it it doesn't close it and it doesn't disappear either. I have verified that if you call the function SendDlgItemMessage
with a simple MessageBox
.
I haven't been able to do it on the internet, I only get: ¿Como crear un boton con win32Apis?
, but what I want is to close it, not create it.