启用和禁用按钮 [英] Enabing and disabling button
本文介绍了启用和禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个按钮.我想根据某些情况启用和禁用该按钮.我如何通过代码启用和禁用按钮.请帮助我..
hi all,
i''ve a button. i want to enable and disable that button based on some conditions. how can i enable and disable the button through code.please help me..
推荐答案
使用 ^ ]函数或方法,具体取决于所使用的框架(原始/MFC/ATL)
EnableWindow(hWindow,FALSE);
或
CWnd.EnableWindow(FALSE);
或
CWindow.EnableWindow(FALSE);
将禁用该窗口
use the EnableWindow(...)[^] function, or method, depending on thr framework you''re using (raw/MFC/ATL)
EnableWindow(hWindow,FALSE);
or
CWnd.EnableWindow(FALSE);
or
CWindow.EnableWindow(FALSE);
will disable the window
添加到Barneyman的解决方案中,如果您使用的是Win32,则可以使用以下内容:
Adding to the solution of Barneyman, if you''re using Win32, you can use something like:
GetDlgItem (YOUR_CONTROL_ID_HERE)->EnableWindow(FALSE);
或其他替代方法:
or the other alternate:
CWnd* myControl = GetDlgItem (YOUR_CONTROL_ID_HERE);
if(myControl)
{
myControl->EnableWindow (FALSE);
}
尝试一下:
if(condition1)
{
buttonName.enabled = false;
}
try this:
if(condition1)
{
buttonName.enabled=false;
}
这篇关于启用和禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文