怎样获得当前窗口的句柄?(50分)

  • 主题发起人 主题发起人 ayb
  • 开始时间 开始时间
A

ayb

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各路大虾怎样才能获得当前窗口的句柄,谢了.我是一VC菜鸟.
 
self.handle
 
GetActiveWindow()
 
是vc哦:
好像是getwindow(),你再去查查帮助。
 
GetActiveWindow
The GetActiveWindow function retrieves the window handle to the active window attached to 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 attached to the calling thread's message queue. Otherwise, the return value is NULL.
Remarks
To get the handle to the foreground window, you can use GetForegroundWindow.
Windows 98/Me and Windows NT 4.0 SP3 and later: To get the window handle to the active window in the message queue for another thread, use GetGUIThreadInfo.
 
HWND GetActiveWindow(VOID);
没错
 
GetDlgItem(id号)
 
如果事mfc的话可以这样 this->m_hWnd
 
不是自己程序的窗口就得 FindWindow()了
 
CWnd *pWndPrev
// Determine if a window with the class name exists...
if (pWndPrev = CWnd::FindWindow(_T("MyNewClass"),NULL))
return FALSE;
就可以找到
 
毫无疑问。GetActiveWindow()
 
毫无疑问是
::GetActiveWindow()
加上全局限定符,呵呵
如果是mfc
cwnd中有一个成员变量m_hWnd保存着句柄
 
后退
顶部