//---------------------------------------------------------------------------
//屏蔽CE系统桌面,每个窗体在初始化的时候调用
//EnableDesktop(FALSE);
//仅一个主窗体在退出时恢复屏蔽EnableDesktop(TRUE);
//注:其他辅助窗体均不能恢复屏蔽!!仅主窗体恢复一次即可
void EnableDesktop(BOOL bEnable)
{
HWND hTaskBarWnd=NULL,hMenuBarWnd=NULL,hSipBtnWnd=NULL;
hTaskBarWnd = ::FindWindow(_T("HHTaskBar"), NULL);
hMenuBarWnd = ::FindWindow(_T("menu_worker"), NULL);
hSipBtnWnd = ::FindWindow(_T("MS_SIPBUTTON"), NULL);
if(NULL==hTaskBarWnd || NULL==hMenuBarWnd ) return;
if(TRUE == bEnable)
{
::EnableWindow(hTaskBarWnd, TRUE);
::ShowWindow(hTaskBarWnd, SW_SHOW);
::EnableWindow(hMenuBarWnd, TRUE);
::ShowWindow(hMenuBarWnd, SW_SHOW);
::EnableWindow(hSipBtnWnd, TRUE);
::ShowWindow(hSipBtnWnd, SW_SHOW);
}
else
{
::EnableWindow(hTaskBarWnd, FALSE);
::ShowWindow(hTaskBarWnd, SW_HIDE);
::EnableWindow(hMenuBarWnd, FALSE);
::ShowWindow(hMenuBarWnd, SW_HIDE);
::EnableWindow(hSipBtnWnd, FALSE);
::ShowWindow(hSipBtnWnd, SW_HIDE);
}
}
//---------------------------------------------------------------------------
//设置系统键盘CAPSLOCK按下和恢复
//bState=TRUE : 模拟按下(大写)
//bState=FALSE : 模拟恢复(小写)
void SetCapsLock( BOOL bState )
{
EnableDesktop(FALSE);
SHORT b;
b = GetKeyState(VK_CAPITAL);
/*
if( (TRUE==bState && (LOWORD(b)==1)) ||
(FALSE==bState && (LOWORD(b)==0)) )
{
*/ //AfxMessageBox(TEXT("down"));
keybd_event( VK_CAPITAL,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0 );
keybd_event( VK_CAPITAL,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
//}
}
//---------------------------------------------------------------------------