如何访问桌面窗口


静态函数CWnd:: GetDesktopWindow 返回桌面窗口的指针。下例说明了MFC函数CFrameWnd::BeginModalStae是如何使用该函数进入内部窗口列表的。

void CFrameWnd::BeginModalState ()
{
 …
 //first count all windows that need to be disabled
 UINT nCount=0
 HWND hWnd= :: GetWindow (:: GetDesktopWindow(), GW_CHILD)
 while (hWnd!=NULL)
 {
 if (:: IsWindowEnabled (hwnd)
&& CWnd::FromHandlePermanent (hWnd)!=NULL
&& AfxIsDescendant (pParent->m_hWnd, hWnd)
&& :: SendMessage (hWnd, WM_DISABLEMODAL, 0, 0)==0)
 {
++nCount
 }
 hWnd=:: GetWindow (hWnd, GW_HWNDNEXT)
 }
 …



[返回“一学网www.onestudy.net”首页]