Post
by trevordevore » Tue May 15, 2018 2:32 pm
I was wrapping the Windows API call GetActiveWindow() today and wanted to return the value to LCS. GetActiveWindow() returns a HWND which is a pointer. I couldn't find a way to return the integer value (the windowId property of a stack) by working with a Pointer. I then found IntPtr which works for my purposes. Can someone from headquarters confirm that this is the correct approach?
Code: Select all
foreign handler User32GetActiveWindow() returns optional IntPtr binds to "user32>GetActiveWindow"
public handler GetActiveWindow() returns Integer
variable hWnd as optional Integer
unsafe
put User32GetActiveWindow() into hWnd
end unsafe
if hWnd is not nothing then
return hWnd
else
return 0
end if
end handler
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder