MFC隐藏显示任务栏,菜单栏及输入法面板 收藏
转自:http://blog.csdn.net/zst126/archive/2009/06/12/4259625.aspx
1、隐藏
// 隐藏命令栏
HWND hWnd = SHFindMenuBar(m_hWnd);
::CommandBar_Show(hWnd, FALSE);
// 隐藏任务栏
SHFullScreen(m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON|SHFS_HIDESTARTICON);
//把窗体设为前台
SetForegroundWindow();
//隐藏后把窗体设置为全屏
CRect rcScreen;
rcScreen.SetRect( 0, 0, GetSystemMetrics( SM_CXSCREEN ),
GetSystemMetrics( SM_CYSCREEN ));
MoveWindow(&rcScreen, TRUE);
//隐藏输入法面板
BOOL fRes = FALSE;
SIPINFO si;
memset( &si, 0, sizeof( si ) );
si.cbSize = sizeof( si );
if( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0 ) )
{
si.fdwFlags &= ~SIPF_ON;
fRes = SHSipInfo( SPI_SETSIPINFO, 0, &si, 0 );
}
或者
SIPINFO si;
memset(&si, 0, sizeof(SIPINFO));
si.cbSize = sizeof(SIPINFO);
SHSipInfo(SPI_GETSIPINFO, 0, &si, 0);
if (si.fdwFlags & SIPF_ON)
{
si.cbSize = sizeof(SIPINFO);
si.fdwFlags = SIPF_OFF;
SHSipInfo(SPI_SETSIPINFO, 0, &si, 0);
}
2、显示
// 显示任务栏和输入法图标和Start图标
SHFullScreen(m_hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
//只显示任务栏
HWND hWndTaskBar = ::FindWindow(TEXT("HHTaskBar"), NULL);
if (hWndTaskBar != NULL)
{
::ShowWindow(hWndTaskBar, SW_SHOW);
}
//显示命令栏(此时只显示了输入法图标,因为窗体的高度已经变化,可以通过重新设置窗体大小把该命令栏显示在窗口中)
HWND hWnd = SHFindMenuBar(m_hWnd);
::CommandBar_Show(hWnd, TRUE);
//打开输入法面板
BOOL fRes = FALSE;
SIPINFO si;
memset( &si, 0, sizeof( si ) );
si.cbSize = sizeof( si );
if( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0 ) )
{
si.rcSipRect.top -= 20;
si.rcSipRect.bottom -= 20;
si.rcSipRect.left = 20;
si.rcSipRect.right = 200;
si.fdwFlags &= ~SIPF_LOCKED;
si.fdwFlags &= ~SIPF_DOCKED;
si.fdwFlags |= SIPF_ON;
fRes = SHSipInfo( SPI_SETSIPINFO, 0, &si, 0 );
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zst126/archive/2009/06/12/4259625.aspx