void CLpllpDlg::FullScreenDialog(HWND hDlg) { int x0,y0,cx, cy; x0 = -(GetSystemMetrics(SM_CXBORDER)+1); y0 = -(GetSystemMetrics(SM_CYBORDER)+1); HDC dc = ::GetDC(NULL); //HDC dc = ::GetWindowDC( HWND_DESKTOP ); cx = GetDeviceCaps(dc,HORZRES) + GetSystemMetrics(SM_CXBORDER); cy = GetDeviceCaps(dc,VERTRES) + GetSystemMetrics(SM_CYBORDER); ::ReleaseDC(0,dc); //去除标题和边框 SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)&(~(WS_CAPTION|WS_BORDER))); //置对话框为最顶端并扩充到整个屏幕 ::SetWindowPos(m_hWnd, HWND_TOPMOST, x0, y0, cx+1, cy+1, SWP_NOZORDER); //隐藏任务栏 HWND hTaskBar; hTaskBar = ::FindWindow(TEXT("HHTaskBar"), NULL); //搜寻任务栏句柄 ::ShowWindow(hTaskBar, SW_HIDE); //隐藏 // ShowWindow(hTaskBar, SW_SHOWNORMAL); //显示任务栏 }
在Mobile5.0上,上面的方式是无效的,需调用如下:
SetForegroundWindow(); //此函数不调用,则SHFullScreen将无效 // To switch to full screen mode, first hide all of the shell parts. dwState = (SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); SHFullScreen(hWnd, dwState); RECT rc; SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); ::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); this->m_bFullScreen = false; //不执行此句将有不同的效果