마우스커서가 현재 위치하고 있는 윈도우 핸들을 알고 싶을때 아래 코드를 참고하자.
PointToHandle와 같이 함수형태로 만들어 놓으면 호출시 핸들값을 리턴한다.
GetCursorPos는 현재 마우스커서의 위치를 POINTAPI 구조체에 담아주고, WindowFromPoint 를 통해 x좌표, y좌표를 넘겨주면 해당 좌표에 핸들을 리턴한다.
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" _
(ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Function PointToHandle() As Long
Dim pt As POINTAPI
GetCursorPos pt
PointToHandle = WindowFromPoint(pt.x, pt.y)
End Function
'VB6 > Function' 카테고리의 다른 글
Desktop 이름 구하기 (0) | 2013.04.01 |
---|---|
대기시간 함수 (0) | 2013.03.27 |