请问如何获得没有标题栏的窗口的句柄,并显示?

terpitude2002 2007-04-14 09:22:05
多谢。
...全文
634 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
greentest 2007-04-16
  • 打赏
  • 举报
回复
枚举进程复杂了点,直接用windowfrompoint函数,鼠标指到哪儿,显示哪儿的句柄,想怎么做就怎么做
terpitude2002 2007-04-16
  • 打赏
  • 举报
回复
大家能不能再说的详细一些,谢谢。
diclover 2007-04-16
  • 打赏
  • 举报
回复
object.hWnd
迈克揉索芙特 2007-04-16
  • 打赏
  • 举报
回复
顶老大的

给你个参考代码,n年前写的,忘记干什么用的了,有龌龊只处自己改吧。
Option Explicit
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessageS Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_GETTEXT = &HD

Private hWnd As Long
Private ClassName As String, WindowName As String
Private ReVal As Boolean, IncFind As Boolean
Public Enuming As Boolean

Private Function EnumChildWindow(ByVal hWndChild As Long, ByVal lParam As Long) As Long
Dim lpClassName As String, lpWindowName As String
Dim i As Integer

Enuming = True
lpClassName = Space(64)
GetClassName hWndChild, lpClassName, 63
lpClassName = Left$(lpClassName, InStr(lpClassName, Chr$(0)) - 1)

lpWindowName = Space(256)
SendMessageS hWndChild, WM_GETTEXT, 255, lpWindowName
lpWindowName = Left$(lpWindowName, InStr(lpWindowName, Chr$(0)) - 1)

lpClassName = UCase(Trim(lpClassName))
lpWindowName = UCase(Trim(lpWindowName))

' Debug.Print lpClassName

ReVal = False

If ClassName <> vbNullString And WindowName <> vbNullString Then
If Not IncFind Then
If ClassName = lpClassName And WindowName = lpWindowName Then hWnd = hWndChild: ReVal = True: Exit Function
Else
If InStr(1, lpClassName, ClassName, vbTextCompare) > 0 And _
InStr(1, lpWindowName, WindowName, vbTextCompare) > 0 Then hWnd = hWndChild: ReVal = True: Exit Function
End If

ElseIf ClassName <> vbNullString And WindowName = vbNullString Then
If Not IncFind Then
If ClassName = lpClassName Then hWnd = hWndChild: ReVal = True: Exit Function
Else
If InStr(1, lpClassName, ClassName, vbTextCompare) > 0 Then hWnd = hWndChild: ReVal = True: Exit Function
End If

ElseIf ClassName = vbNullString And WindowName <> vbNullString Then
If Not IncFind Then
If WindowName = lpWindowName Then hWnd = hWndChild: ReVal = True: Exit Function
Else
If InStr(1, lpWindowName, WindowName, vbTextCompare) > 0 Then hWnd = hWndChild: ReVal = True: Exit Function
End If

End If

EnumChildWindow = 1
End Function

Public Function GetChildWindow(hWndParent As Long, Optional ByVal lpClassName As String, Optional ByVal lpWindowName As String, Optional Include As Boolean) As Long
lpClassName = UCase(Trim(lpClassName))
lpWindowName = UCase(Trim(lpWindowName))
ClassName = lpClassName
WindowName = lpWindowName
IncFind = Include
EnumChildWindows hWndParent, AddressOf EnumChildWindow, 0
If ReVal Then GetChildWindow = hWnd
Enuming = False
End Function
xiaolei1982 2007-04-14
  • 打赏
  • 举报
回复
当前窗体的句柄me.hWnd
CathySun118 2007-04-14
  • 打赏
  • 举报
回复
vb中很简单:Form1.hWnd
rainstormmaster 2007-04-14
  • 打赏
  • 举报
回复
可以考虑用EnumWindows枚举窗口列表中的所有父窗口
rainstormmaster 2007-04-14
  • 打赏
  • 举报
回复
只所以不推荐FindWindow的原因是,估计你也是用vb写程序,这样的话,你的程序+"使用VB编写的没有标题栏的窗体"对应程序,最少在你正常测试时会存在2个vb程序,而findwindow只查找一次.

PS:可以考虑使用类似spy之类的工具
rainstormmaster 2007-04-14
  • 打赏
  • 举报
回复
//是在其他应用程序中想获得使用VB编写的没有标题栏的窗体。

用EnumWindows结合getclassname进行判断

或者考虑枚举进程,根据进程对应文件路径进行判定
kmlxk0 2007-04-14
  • 打赏
  • 举报
回复
handleDC=FindWindow("ThunderRT6FormDC","") '包含控件的
handle=FindWindow("ThunderRT6Main","") '不知道做什么用的
terpitude2002 2007-04-14
  • 打赏
  • 举报
回复
是在其他应用程序中想获得使用VB编写的没有标题栏的窗体。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧