我加入下面的代码,结果没有反应,按钮还是灰的?
::SendMessage(::GetDlgItem(GlobalsDlg,IDC_BUTTON1),WM_ENABLE,1,0);
使用EnableWindow
The WM_ENABLE message is sent when an application changes the enabled state of a window. It is sent to the window whose enabled state is changing. This message is sent before the EnableWindow function returns, but after the enabled state (WS_DISABLED style bit) of the window has changed.
发送是没有用的,只有接收处理这个消息
使用EnableWindow
EnableWindow(hWndDlg,TRUE);
EnableWindow(hWndDlg,TRUE); Enable the button
EnableWindow(hWndDlg,FALSE); Disable the button
Please refer to MSDN for detailed information.
CXXDlg * pdlg;//这是个全局变量,给线程函数用的
.....
//在OnInitDialog()中
pdlg=this;
.....
//在线程函数中,ID_XXX就是按钮的ID
pdlg->GetDlgItem(ID_XXX)->EnableWindow(true);
或者你在线程中向应用发一个自定义消息,应用中写对应的消息响应函数,函数的内容就是Enable那个按钮
EnableWindow