なんとなく投稿
#include "user32.as"
#const wndx 500
#const wndy 200
#const titley 25
// ボタンの色の定義 hsv の hを指定
#const btcl 191
#const txcl	btcl+btcl/2
// 終了ボタン位置の定数
#const MARGIN 3
#const cleft wndx-titley+MARGIN
#const ctop MARGIN
#const cright wndx-MARGIN*2
#const cbottom titley-MARGIN*2
#const fontsize cbottom
bgscr 0,wndx,wndy
c = 255,120 // ボタンの暗明用の変数
*@
	is_InCloseButton = (mousex >= cleft) and (mousey >= ctop) and (mousex < cright) and (mousey < cbottom)
	is_notmove = (flg_moveing==0)
	
	// キー入力処理
	stick key,256
	if(key&256){
		mx = ginfo_mx
		my = ginfo_my
		if (is_InCloseButton) {
			flg_end = is_notmove
		}else:if(is_notmove and (flg_end==0) and (mousey <= titley)){
			flg_moveing = 1
			targetx = ginfo_wx1 - mx
			targety = ginfo_wy1 - my
		}
	}else{
		if(is_InCloseButton and flg_end):end	
		flg_moveing = 0
		flg_end = 0
	}
	if(flg_moveing){
		MoveWindow hwnd , targetx+mx,targety+my , wndx,wndy , 1
		// width ,,targetx+mx,targety+my だった場合 ポジションが -1 以下の場合に動作しない?		
	}
	
	// タイトルバー描画
	redraw 0
	font msGothic,fontsize,1
	color 200,200,255:boxf 0,0,wndx,titley
	pos 0,0:color:mes "クリックしてドラッグ!!"
	
	// 終了ボタン描画
	
	s = c(flg_end^(is_InCloseButton and is_notmove))
	v = c(flg_end)
	hsvcolor btcl,s,v:boxf cleft,ctop,cright,cbottom
	hsvcolor txcl,s,v:pos cleft-1,ctop-1:mes "×"
	
	redraw
	await 30
goto*@b
こんな方法もあります
使わないと思いますが。