The first demo changes the caption in a plain window or dialog window. The second method must be used in windows of type "graphics" and "text". In these window types, the HWND returns the handle of the embedded grahicbox or texteditor, so you must use GetParent to get the handle of the window.
Window or Dialog Window
nomainwin
newtitle$="New Caption"
UpperLeftX=10:UpperLeftY=10
open "Window" for window as #1
#1 "trapclose [quit]"
call SetWindowText hwnd(#1),newtitle$
wait
[quit] close #1:end
Sub SetWindowText hWnd, txt$
CallDLL #user32, "SetWindowTextA",_
hWnd As uLong, txt$ As Ptr, result As boolean
End Sub
Graphics or Text Window
nomainwin
newtitle$="New Caption"
UpperLeftX=10:UpperLeftY=10
open "Graphics" for graphics as #2
#2 "trapclose [quit]"
hParent = GetParent(hwnd(#2))
call SetWindowText hParent,newtitle$
wait
[quit] close #2:end
Sub SetWindowText hWnd, txt$
CallDLL #user32, "SetWindowTextA",_
hWnd As uLong, txt$ As Ptr, result As boolean
End Sub
Function GetParent(hWnd)
CallDLL #user32, "GetParent",_
hWnd As uLong, GetParent As uLong
End Function