在VB6中获取当前窗口/窗体的hWnd?

C. *_*oss 6 vb6 hwnd

何我在VB6中获得当前窗口/窗体的hWnd?

C-P*_*uru 14

如果你在表格上: Me.hWnd.如果您不知道当前表单是哪个表单: Screen.ActiveForm.hWnd


Hea*_*r M 9

使用Windows API,GetForegroundWindow()无论它来自哪个应用程序,都将获得最顶层窗口GetActiveWindow()的句柄,并获取应用程序活动窗口的句柄.Declare您需要的陈述:

Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Declare Function GetActiveWindow Lib "user32.dll" () As Long 
Run Code Online (Sandbox Code Playgroud)

调用任一函数将返回如上所述的窗口句柄.