石鑫华视觉 发表于 2015-5-17 10:38:55

API---如何获得窗口句柄(HWND)(陈树学)

hwnd 是窗口句柄,系统分配的一个ID号,对操作系统来说就是这个窗口的唯一标识,通过它就可以操作WIN窗口了,LABVIEW VI的前面板无疑是一个WINDOWS窗口,那如何获得这个窗口句柄那.
有两种方法:
1.利用API FindWindow函数,通过窗口标题,来查找前面板的窗口句柄.


2.利用LABVIEW未公开的私有属性节点



获得了HWND,可以说获得了控制前面板的钥匙,举几个例子:1.读取窗口标题和设置窗口标题Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long





2.如何使窗口的最大最小化按纽失效Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZE = &H1000000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZE = &H20000000
Public Const WS_MINIMIZEBOX = &H20000
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

页: [1]
查看完整版本: API---如何获得窗口句柄(HWND)(陈树学)

LabVIEW HALCON图像处理入门教程(第二版)
石鑫华机器视觉与LabVIEW Vision图像处理PDF+视频教程11种全套
《LabVIEW Vision函数实例详解》教程-NI Vision所有函数使用方法介绍,基于NI VISION2020,兼容VDM21/22/23/24