For whom it may concern, I wrote a function, that opens the gfx.init-window AND returns its HWND. Use that, if you need to work with the HWND of a gfx-window.
It will be part of the next update of my Ultraschall-API.
The parameters are the exact same way as gfx.init.
Requires(of course) the JS-plugin installed and works on Mac and Windows (linux untested yet).
Code:
ultraschall={}
function ultraschall.GFX_Init(...)
local parms={...}
local temp=parms[1]
-- check, if the given windowtitle is a valid one,
-- if that's not the case, use "" as name
if temp==nil or type(temp)~="string" then temp="" end
if type(parms[1])~="string" then parms[1]=""
end
-- check for a window-name not being used yet, which is
-- windowtitleX, where X is a number
local freeslot=0
for i=0, 65555 do
if reaper.JS_Window_Find(parms[1]..i, true)==nil then freeslot=i break end
end
-- use that found, unused windowtitle as temporary windowtitle
parms[1]=parms[1]..freeslot
-- open window
local retval=gfx.init(table.unpack(parms))
-- find the window with the temporary windowtitle and get its HWND
local HWND=reaper.JS_Window_Find(parms[1], true)
-- rename it to the original title
if HWND~=nil then reaper.JS_Window_SetTitle(HWND, temp) end
ultraschall.GFX_WindowHWND=HWND
return retval, HWND
end