Combined my code with the code from andrew11 and it works.
You may have problems with using set display mode. The font might change and you will proberly have to load all your media again after it is used.
Edit: this code shows how you will need to reload/create media after the window is resized
sync on
load dll "user32.dll",1
hwnd = call dll(1,"GetActiveWindow")
make memblock 1,16
`set text size 20
disable escapekey
font as string
font = text font$()
old_x as integer : old_y as integer
old_x = screen width() : old_y = screen height()
make_media()
while escapekey() = 0
cls
box 50,50,100,100
sprite 1,200,200,1
retval=call dll(1,"GetWindowRect",hwnd,get memblock ptr(1))
posx = memblock word(1,0): posy = memblock word(1,4)
x2 = memblock word(1,8): y2 = memblock word(1,12)
If posy > 3000 Then posy = posy - 65536
If posx > 3000 Then posx = posx - 65536
sizex = x2 - posx: sizey = y2 - posy
text 1,0,"Window position: (" + STR$(posx) + "," + STR$(posy) + ")"
text 1,15,"Window size: (" + STR$(sizex) + "," + STR$(sizey) + ")"
text 0,30,"fps: "+str$(screen fps())
`27 is size of top title bar + bottom border | 8 is size of l+r border
if sizex <> old_x+8 or sizey <> old_y+27
set display mode sizex-8,sizey-27,screen depth()
old_x = screen width() : old_y = screen height()
set text font font
make_media()
endif
sync
Endwhile
delete dll 1
delete memblock 1
function make_media()
create bitmap 1,100,100
box 0,0,50,50
box 50,50,100,100
get image 1,0,0,100,100,1
delete bitmap 1
endfunction
See attached code.