用API?
用p_pMainWnd?
还是什么函数?

解决方案 »

  1.   

    HWND GetSafeHwnd( ) const;Return ValueReturns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer////////////////////////////////////////////////////////////////////static CWnd* PASCAL GetActiveWindow( );Return ValueThe active window or NULL if no window was active at the time of the call. The pointer may be temporary and should not be stored for later use.ResRetrieves a pointer to the active window. The active window is either the window that has the current input focus or the window explicitly made active by the SetActiveWindow member function.
      

  2.   

    GetActiveWindowThe GetActiveWindow function retrieves the window handle to the active window associated with the calling thread's message queue. HWND GetActiveWindow(VOID)
     
    Parameters
    This function has no parameters. Return Values
    The return value is the handle to the active window associated with the calling thread's message queue. Otherwise, the return value is NULL. 
      

  3.   

    HWND hWnd = GetSafeHwnd();
      

  4.   

    HWND hWnd = GetSafeHwnd();
      

  5.   

    HWND GetSafeHwnd( )HWND GetWindowHWND( );
      

  6.   

    HWND hWnd = GetSafeHwnd();
      

  7.   

    GetActiveWindowThe GetActiveWindow function retrieves the window handle to the active window associated with the calling thread's message queue. HWND GetActiveWindow(VOID)
     
    Parameters
    This function has no parameters. Return Values
    The return value is the handle to the active window associated with the calling thread's message queue. Otherwise, the return value is NULL. 
      

  8.   

    POINT pt;
    HWND hwnd;
    ::GetCursorPos(&pt);
    hwnd = ::WindowFromPoint(pt);
      

  9.   

    如果你是用MFC的话,每个窗口类都有一个变量HWND m_hWnd,取窗口句柄的函数很多,如GetWindow,FindWindow,EnumWindow等,不局限于本窗口。