如果得知我的对话框是否获得了焦点?
如何得知我的对话框是否被别的窗口挡在了后面?多谢了~

解决方案 »

  1.   

    GetForegroundWindow()和对话框句柄比较。
      

  2.   

    HWND GetFocus(VOID)
    用来获取获得焦点的窗口的句柄
      

  3.   

    如果要知道窗口是否被遮挡,逐个调用GetNextWindow 获取其他窗口的位置并且根据他们的位置判断与对话框的位置是否有重叠部分。
      

  4.   

    你可以用::GetActiveWindow()先得到当前的active window,然后判断是不是和你的对话框HWND相等,如果相等就是获得了焦点,否则没有获得了焦点
      

  5.   

    应该用GetFocus(),方法如下:
    GetFocus
    The GetFocus function retrieves the handle to the window that has the keyboard focus, if the window is attached to the calling thread's message queue. HWND GetFocus(VOID);
    Parameters
    This function has no parameters. Return Values
    The return value is the handle to the window with the keyboard focus. If the calling thread's message queue does not have an associated window with the keyboard focus, the return value is NULL. Res
    GetFocus returns the window with the keyboard focus for the current thread's message queue. If GetFocus returns NULL, another thread's queue may be attached to a window that has the keyboard focus. Use the GetForegroundWindow function to retrieve the handle to the window with which the user is currently working. You can associate your thread's message queue with the windows owned by another thread by using the AttachThreadInput function. Windows 98/Me and Windows NT 4.0 SP3 and later: To get the window with the keyboard focus on the foreground queue or the queue of another thread, use the GetGUIThreadInfo function.Example Code
    For an example, see Creating a Combo-box Toolbar. Requirements 
      Windows NT/2000/XP: Included in Windows NT 3.1 and later.
      Windows 95/98/Me: Included in Windows 95 and later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.