出于好奇,自己用VC弄了一个简单的工具,有的时候还真挺有用的。
这个连灰色的菜单也可以激活的。
核心代码:
bool bstart=false; void CEnabledDlg::OnEnable() { if (bstart) { KillTimer(1); SetDlgItemText(IDC_ENABLE,"激活[开启]"); } else { SetTimer(1, 500, NULL); SetDlgItemText(IDC_ENABLE,"激活[关闭]"); } bstart=!bstart; } BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) { if (::IsWindowEnabled(hwnd)==false) ::EnableWindow(hwnd,true); return true; } BOOL CEnabledDlg::DestroyWindow() { KillTimer(1); return CDialog::DestroyWindow(); } void EnMenu(HMENU hMenu) { int i,subs; subs = ::GetMenuItemCount(hMenu); for (i=0; i<subs ; i++) { ::EnableMenuItem(hMenu, i, MF_ENABLED | MF_BYPOSITION); HMENU hMenu2 = ::GetSubMenu(hMenu, i); int subs2 = ::GetMenuItemCount(hMenu2); if (subs2>0) { EnMenu(hMenu2); } } } void CEnabledDlg::OnTimer(UINT nIDEvent) { HWND hwnd = ::GetForegroundWindow(); ::EnumChildWindows(hwnd,EnumChildProc,0); HMENU hMenu; hMenu =::GetMenu(hwnd); EnMenu(hMenu); CDialog::OnTimer(nIDEvent); } </subs> |
附件:Enabled
受教了!呵呵!