Code: Select all
function createwin(windowName as LPCTSTR, x as integer, y as integer, winWidth as integer, winHeight as integer, styles as DWORD = WS_OVERLAPPEDWINDOW+WS_CLIPSIBLINGS+WS_VISIBLE, extStyles as DWORD = 0, parent as HWND = null, menu as HMENU = null) as HWND
var hLib = dylibload("user32.dll")
if hLib = null then return null
dim pCreateWindowEx as function (byval as DWORD, byval as LPCTSTR, byval as LPCTSTR, byval as DWORD, byval as integer, byval as integer, byval as integer, byval as integer, byval as HWND, byval as HMENU, byval as HINSTANCE, byval as LPVOID) as HWND
pCreateWindowEx = dylibsymbol(hLib, "CreateWindowExA")
if pCreateWindowEx = null then dylibfree(hLib): return null
var res = pCreateWindowEx(extStyles, chr(0), windowName, styles, x, y, winWidth, winHeight, parent, menu, null, null)
dylibfree(hLib)
return res
end function
function killwin(hWin as HWND) as boolean
var hLib = dylibload("user32.dll")
if hLib = null then return false
dim pDestroyWindow as function (byval as HWND) as boolean
pDestroyWindow = dylibsymbol(hLib, "DestroyWindow")
if pDestroyWindow = null then dylibfree(hLib): return false
var res = pDestroyWindow(hWin)
dylibfree(hLib)
return res
end function
dim as HWND windowHandle = createwin("Tester Window", 50, 35, 175, 100)
if windowHandle = 0 then print "Somethin' went wrong :'("
sleep
print killwin(windowHandle)
sleep
system