Hello,
Using VB6, i am trying to get the module filename from the cursor positioned
on any windows, with the following code (modified from Article ID: Q112649
in MSDN LIBRARY for Visual Studio 6.0A)
Call GetCursorPos(pt 32) ' Get cursor position
ptx = pt32.x
pty = pt32.y
hWndOver = WindowFromPoint XY(ptx, pty) ' Get window cursor is over
If hWndOver <> hWndLast Then ' If changed update display
hWndLast = hWndOver ' Save change
Cls ' Clear the form
Print "hWndOver: &H"; hex(hWndOver)
' Get window instance:
hInstance = GetWindowLong(h WndOver, GWW_HINSTANCE)
Print "hinstance: &H"; hex(hInstance)
' Get module file name:
r = GetModuleFileNa me(hInstance, sModuleFileName , 100)
Print "Module: "; Left(sModuleFil eName, r)
End If
The hWndOver change depending the cursor position, but the hInstance is not
updated correctly , and consequently, the sModuleFileName is not correct.
The initial API was GetWindowWord, but MSDN say that it is replaced by
GetWindowLong (anyway it does not work also with GetWindowWord)
I am using VB6 and Windows XP. I tried VB5 and Windows 98SE with the same
problem.
Any idea ?? suggestion ??
Many thanks for your help
Yves
Using VB6, i am trying to get the module filename from the cursor positioned
on any windows, with the following code (modified from Article ID: Q112649
in MSDN LIBRARY for Visual Studio 6.0A)
Call GetCursorPos(pt 32) ' Get cursor position
ptx = pt32.x
pty = pt32.y
hWndOver = WindowFromPoint XY(ptx, pty) ' Get window cursor is over
If hWndOver <> hWndLast Then ' If changed update display
hWndLast = hWndOver ' Save change
Cls ' Clear the form
Print "hWndOver: &H"; hex(hWndOver)
' Get window instance:
hInstance = GetWindowLong(h WndOver, GWW_HINSTANCE)
Print "hinstance: &H"; hex(hInstance)
' Get module file name:
r = GetModuleFileNa me(hInstance, sModuleFileName , 100)
Print "Module: "; Left(sModuleFil eName, r)
End If
The hWndOver change depending the cursor position, but the hInstance is not
updated correctly , and consequently, the sModuleFileName is not correct.
The initial API was GetWindowWord, but MSDN say that it is replaced by
GetWindowLong (anyway it does not work also with GetWindowWord)
I am using VB6 and Windows XP. I tried VB5 and Windows 98SE with the same
problem.
Any idea ?? suggestion ??
Many thanks for your help
Yves
Comment