怎样使用EnableWindow()禁用窗口并将其显示为灰色
要使用EnableWindow()函数禁用窗口并将其显示为灰色,需要依照以下步骤进行操作:
下面是一个示例代码,演示了怎样使用EnableWindow()函数禁用窗口并将其显示为灰色:
#include
int main()
{
HWND hWnd = FindWindow(NULL, L"窗口标题"); // 根据窗口标题查找窗口句柄
if (hWnd != NULL)
{
EnableWindow(hWnd, FALSE); // 禁用窗口
// 设置窗口样式
LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE);
style |= WS_DISABLED;
SetWindowLongPtr(hWnd, GWL_STYLE, style);
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
return 0;
}
请根据实际情况替换示例代码中的窗口标题,并确保已获得到了要禁用的窗口的句柄。
TOP