Windows system functions with callback
BlitzMax Forums/BlitzMax Beginners Area/Windows system functions with callback
| ||
| Hi, is it possible to use windows system functions which need a callback routine as a parameter? In this case i would like to use EnumWindows, out of bm. I know this could be done with a c code but is it possible with native bm code? I would have used the search function of this board, if it would work ;-) |
| ||
Try this...
Extern "win32"
Function EnumWindows(Callbackptr:Byte Ptr,lParam)
Function GetWindowText(hWnd,lpString:Byte Ptr,nMaxCount) = "GetWindowTextA@12"
End Extern
Global CharBuffer:Byte[255]
'The callback function
Function EnumWindowsProc(hwnd,lParam)
GetWindowText(hwnd,CharBuffer,255)
Print "("+hwnd+") / "+String.FromCString(CharBuffer)
'Return True if you want to fetch the next window, return False to tell EnumWindows to stop.
Return True
End Function
EnumWindows(EnumWindowsProc,0)
|
| ||
| Thanx a lot. I tried it with the EnumWindowsProc as a method in a type, which doesn't work. But as a function it seems to work. |