iif i have a button on the screen that paints a rectangle over it once it's clicked i noticed you can still click on the spot and the button will appear. Is there anyway of deleting buttons, so that it can't be clicked again.
Printable View
iif i have a button on the screen that paints a rectangle over it once it's clicked i noticed you can still click on the spot and the button will appear. Is there anyway of deleting buttons, so that it can't be clicked again.
Check out EnableWindow().
Kuphryn
how do i use it
EnableWindow(hwnd);
hwnd is the hwnd of the button... but that will only make the button disabled and not gone..
i think that maybe:
ShowWindow(hwnd, SW_HIDE);
should work better.. use SW_SHOW to show it again
it doesn't seem to work. Do i put it in WM_COMMAND:
I think also you can use
getdlgitem(hwnd)->EnableWindow(false)
I am not sure of it .. anyone correct me if i am not right
EnableWindow takes 2 parameters:
To get rid of the button altogether, use DestroyWindow.Code:EnableWindow( hwndButton, FALSE ); // disable your button
Code:DestroyWindow( hwndButton ); // this destroys your button
it doesn't seem to delete them. Am i suppsoed to be putting them in WM_COMMAND:
Put it wherever you want, as long as the window handle you're passing is valid.Quote:
it doesn't seem to delete them. Am i suppsoed to be putting them in WM_COMMAND
oh yeah sorry about that, EnableWindow does take two parameters..
EnableWindow() will make the control not respond to user input but still be visible (appear 'greyed').
ShowWindow will make a control/dialog appear or disappear (and not respond if hidden).
>>if i have a button on the screen that paints a rectangle over it once it's clicked
Instead of painting the rectangle (in the WM_COMMAND, BN_CLICKED handler for IDC_THIS_BUTTON)
I would hide the button
ShowWindow( GetDlgItem(hWnd, IDC_THIS_BUTTON), SW_HIDE);