一般來講,通過函數SHFullScreen就可以實現,如通過如下調用SHFullScreen(hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON)即可實現,但有一個注意點,如果你的窗口裏有MENU Bar 的話,則需要在全屏幕的時候隱藏MENU Bar可以調用SHGetMenuBar()來獲取MENU的句柄,這裏不能直接將HMENU用CAST成HWND,然後再使用ShowWindow(hWndMenu, SW_HIDE)來隱藏Menu。這樣就是全屏的窗口了,返回非全屏模式,也是調用SHFullScreen()來實現,只是把裏面的標誌位置換成SHOW的就好。下面是例子代碼: BOOL rb; BOOL chgScreen; int rc; RECT rect; HWND hWnd; rb = SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0); if (rb == FALSE) // SystemParametersInfo failed. { rc = MessageBox(NULL, _T("Could not get work area."), _T("Error"), MB_OK); if (rc == 0) // Not enough memory to create MessageBox. return E_OUTOFMEMORY; return E_FAIL; // Replace with specific error handling. } hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (hWnd == NULL)// CreateWindow failed. { rc = MessageBox(NULL, _T("Could not create main window."), _T("Error"), MB_OK); if (rc == 0) // Not enough memory to create MessageBox. return E_OUTOFMEMORY; return E_FAIL; // Replace with specific error handling. } GetWindowRect(hWnd, &rect); chgScreen = SHFullScreen(hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON); if (chgScreen == FALSE); { // SHFullScreen failed. rc = MessageBox(NULL, _T("Could not modify the window."), _T("Error"), MB_OK); if (rc == 0) // Not enough memory to create MessageBox. return E_OUTOFMEMORY; return E_FAIL; // Replace with specific error handling. } MoveWindow( hWnd, rect.left, rect.top - MENU_HEIGHT, rect.right, rect.bottom + MENU_HEIGHT, TRUE);
BOOL CTestDlg::OnInitDialog() { ........ DWORD dwState = ( SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON ); SHFullScreen( m_hWnd, dwState ); CRect rc; SetRect( &rc, 0, 0, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ) ); MoveWindow( &rc, TRUE ); ......... } |
Windows Mobile Phone全屏開發
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.