函式功能
參數:無。
速查:
Windows NT:3.1以上版本;Windows:95以上版本:;頭檔案:Winuser.h;庫檔案:user32.lib。
聲明
vb
Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
vb_net
Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer
S
【說明】
獲得代表整個螢幕的一個視窗(桌面視窗)句柄
C#
[
DllImport("user32", EntryPoint="GetDesktopWindow")]
public static extern IntPtrGetDesktopWindow ();
返回值是IntPtr 是桌面句柄
MFC實例 - 全螢幕顯示
void CFullScreenDlg::FullScreenView(void) {
RECT rectDesktop;
WINDOWPLACEMENT wpNew;
if (!IsFullScreen())
{
// We'll need these to restore the original state.
GetWindowPlacement (&m_wpPrev);
//Adjust RECT to new size of window
::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );
// Remember this for OnGetMinMaxInfo()
m_rcFullScreenRect = rectDesktop;
wpNew = m_wpPrev;
wpNew.showCmd = SW_SHOWNORMAL;
wpNew.rcNormalPosition = rectDesktop;
m_bFullScreen=true;
}
else
{
// 退出全螢幕幕時恢復到原來的視窗狀態
m_bFullScreen=false;null
wpNew = m_wpPrev;
}
SetWindowPlacement ( &wpNew );
}
void CFullScreenDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
// TODO: Add your message handler code here and/or call default
if (IsFullScreen())
{
lpMMI->ptMaxSize.y = m_rcFullScreenRect.Height();
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxSize.x = m_rcFullScreenRect.Width();
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
}
}
bool CFullScreenDlg::IsFullScreen(
void)
{
// 記錄視窗當前是否處於全螢幕狀態
return m_bFullScreen;
}