Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Application.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Application.ab	(revision 547)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Application.ab	(revision 547)
@@ -0,0 +1,69 @@
+'Classes/ActiveBasic/Windows/UI/Application.ab
+
+Namespace ActiveBasic
+Namespace Windows
+Namespace UI
+
+/*!
+@date 2008/07/13
+@brief アプリケーション全体に関わるようなこと……、主にメッセージループを管理するクラス。
+@todo	メッセージフィルタとマルチスレッド対応
+@author Egtra
+*/
+Class Application
+Public
+	/*!
+	@brief メッセージループを回す
+	@date 2008/07/13
+	@param[in] form メインウィンドウ
+	@author Egtra
+	*/
+	Static Sub Run(form As Form)
+		f.Show(SW_SHOW)
+		If IsNothing(form) = False Then
+			form.AddMessageEvent(WM_DESTROY, AddressOf(Application.OnMainFormClosed))
+		End If
+
+		Dim m As MSG
+		Do
+			Dim ret = GetMessage(m, 0, 0, 0)
+			If ret = 0 Or ret = -1 Then
+				Exit Do
+			End If
+			TranslateMessage(m)
+			DispatchMessage(m)
+		Loop
+'		OnThraedExit(EventArgs.Empty)
+	End Sub
+
+	/*!
+	@brief メインウィンドウなしでメッセージループを回す
+	@date 2008/07/13
+	@author Egtra
+	*/
+	Static Sub Run()
+		Run(Nothing)
+	End Sub
+
+	/*!
+	@brief メッセージループを終わらせる。
+	@date 2008/07/13
+	@author Egtra
+	*/
+	Static Sub ExitThread()
+		PostQuitMessage(0)
+	End Sub
+
+'#include "ApplicationEvent.sbp"
+
+Private
+	Static Sub OnMainFormClosed(sender As Object, e As EventArgs)
+		ExitThread()
+	End Sub
+
+	main As Form
+End Class
+
+End Namespace 'UI
+End Namespace 'Widnows
+End Namespace 'ActiveBasic
Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab	(revision 545)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab	(revision 547)
@@ -12,5 +12,7 @@
 
 Class Control
+	Inherits WindowHandle
 Public
+
 	Sub Control()
 	End Sub
@@ -25,5 +27,5 @@
 	Static Function FromHWnd(hwnd As HWND) As Control
 		FromHWnd = Nothing
-		If IsWindow(hwnd) Then
+		If _System_IsWindow(hwnd) Then
 			FromHWnd = FromHWndCore(hwnd)
 		End If
@@ -32,5 +34,5 @@
 Private
 	Static Function FromHWndCore(hwnd As HWND) As Control
-		If GetClassLongPtr(hwnd, GCW_ATOM) = atom Then
+		If _System_GetClassLongPtr(hwnd, GCW_ATOM) = atom Then
 			Dim gchValue = GetProp(hwnd, PropertyInstance As ULONG_PTR As PCTSTR) As ULONG_PTR
 			If gchValue <> 0 Then
@@ -44,27 +46,25 @@
 '--------------------------------
 ' ウィンドウ作成
-/*
-	Function Create(
-		parent As HWND,
-		rect As RECT,
-		name As String,
-		style As DWord,
-		exStyle = 0 As DWord,
-		menu = 0 As HMENU) As HWND
-*/
+'	Function Create(
+'		parent As HWND,
+'		rect As RECT,
+'		name As String,
+'		style As DWord,
+'		exStyle = 0 As DWord,
+'		menu = 0 As HMENU) As HWND
 
 Public
-	Function Create() As Boolean
+	Sub Create()
 		Dim cs As CREATESTRUCT
 		cs.hInstance = hInstance
 		cs.lpszClass = (atom As ULONG_PTR) As LPCTSTR
 		GetCreateStruct(cs)
-		Create = createImpl(cs)
-	End Function
+		createImpl(cs)
+	End Sub
 
 Protected
 	Abstract Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
 
-	Function createImpl(ByRef cs As CREATESTRUCT) As Boolean
+	Sub createImpl(ByRef cs As CREATESTRUCT)
 		Imports System.Runtime.InteropServices
 
@@ -77,7 +77,9 @@
 			Dim hwnd = CreateWindowEx(.dwExStyle, .lpszClass, .lpszName, .style,
 				.x, .y, .cx, .cy, .hwndParent, .hMenu, .hInstance, .lpCreateParams)
-			createImpl = hwnd <> 0
+			If hwnd = 0 Then
+				ActiveBasic.Windows.ThrowByWindowsError(GetLastError())
+			End If
 		End With
-	End Function
+	End Sub
 
 '--------------------------------
@@ -125,17 +127,16 @@
 	*/
 	Sub StartWndProc()
-		Dim t = This '#177対策
-		AddMessageEvent(WM_ERASEBKGND, AddressOf(t.OnEraseBackground))
-		Dim md = New MessageEventHandler(AddressOf(t.OnMouseDownBase))
+		AddMessageEvent(WM_ERASEBKGND, AddressOf(OnEraseBackground))
+		Dim md = New MessageEventHandler(AddressOf(OnMouseDownBase))
 		AddMessageEvent(WM_LBUTTONDOWN, md)
 		AddMessageEvent(WM_RBUTTONDOWN, md)
 		AddMessageEvent(WM_MBUTTONDOWN, md)
 		AddMessageEvent(WM_XBUTTONDOWN, md)
-		Dim mu = New MessageEventHandler(AddressOf(t.OnMouseUpBase))
+		Dim mu = New MessageEventHandler(AddressOf(OnMouseUpBase))
 		AddMessageEvent(WM_LBUTTONUP, mu)
 		AddMessageEvent(WM_RBUTTONUP, mu)
 		AddMessageEvent(WM_MBUTTONUP, mu)
 		AddMessageEvent(WM_XBUTTONUP, mu)
-		Dim mb = New MessageEventHandler(AddressOf(t.OnMouseDblClkBase))
+		Dim mb = New MessageEventHandler(AddressOf(OnMouseDblClkBase))
 		AddMessageEvent(WM_LBUTTONDBLCLK, mu)
 		AddMessageEvent(WM_RBUTTONDBLCLK, mu)
@@ -143,14 +144,14 @@
 		AddMessageEvent(WM_XBUTTONDBLCLK, mu)
 
-		AddMessageEvent(WM_MOUSELEAVE, AddressOf(t.OnMouseLeaveBase))
-		AddMessageEvent(WM_PAINT, AddressOf(t.OnPaintBase))
-		AddMessageEvent(WM_KEYDOWN, AddressOf(t.OnKeyDownBase))
-'		AddMessageEvent(WM_CHAR, AddressOf(t.OnChar))	
-		AddMessageEvent(WM_CREATE, AddressOf(t.OnCreateBase))
+		AddMessageEvent(WM_MOUSEMOVE, AddressOf(OnMouseMoveBase))
+		AddMessageEvent(WM_MOUSELEAVE, AddressOf(OnMouseLeaveBase))
+		AddMessageEvent(WM_PAINT, AddressOf(OnPaintBase))
+		AddMessageEvent(WM_KEYDOWN, AddressOf(OnKeyDownBase))
+'		AddMessageEvent(WM_CHAR, AddressOf(OnChar))	
+		AddMessageEvent(WM_CREATE, AddressOf(OnCreateBase))
 	End Sub
 
 	Sub OnEraseBackground(sender As Object, e As MessageEventArgs)
-		Dim rc As RECT
-		Dim r = GetClientRect(hwnd, rc)
+		Dim rc = ClientRect
 		FillRect(e.WParam As HDC, rc, (COLOR_3DFACE + 1) As HBRUSH)
 		e.LResult = TRUE
@@ -197,9 +198,9 @@
 	Sub OnPaintBase(sender As Object, e As MessageEventArgs)
 		Dim ps As PAINTSTRUCT
-		BeginPaint(hwnd, ps)
+		BeginPaint(ps)
 		Try
 			OnPaintDC(New PaintDCEventArgs(ps.hdc, ps.rcPaint))
 		Finally
-			EndPaint(hwnd, ps)
+			EndPaint(ps)
 		End Try
 	End Sub
@@ -272,5 +273,4 @@
 ' インスタンスメンバ変数
 Private
-	hwnd As HWND
 	/*!
 	@brief マウスカーソルがクライアント領域に入っているかどうかのフラグ
@@ -291,5 +291,5 @@
 		Imports System.Runtime.InteropServices
 
-		Dim rThis = Control.FromHWndCore(hwnd)
+		Dim rThis = FromHWndCore(hwnd)
 		If IsNothing(rThis) Then
 			Dim gchValue = TlsGetValue(tlsIndex) As LONG_PTR
@@ -306,12 +306,11 @@
 			End If
 			rThis.hwnd = hwnd
-			SetProp(hwnd, PropertyInstance As ULONG_PTR As PCSTR, gchValue As HANDLE)
+			rThis.Prop[PropertyInstance] = gchValue As HANDLE
 		End If
 		WndProcFirst = rThis.WndProc(msg, wp, lp)
 		If msg = WM_NCDESTROY Then
-			Dim gchValue = GetProp(hwnd, PropertyInstance As ULONG_PTR As PCTSTR) As ULONG_PTR
+			Dim gchValue = rThis.Prop(PropertyInstance) As ULONG_PTR
 			If gchValue <> 0 Then
-				Dim gch = GCHandle.FromIntPtr(gchValue)
-				gch.Free()
+				GCHandle.FromIntPtr(gchValue).Free()
 			End If
 		End If
@@ -320,5 +319,5 @@
 
 	*InstanceIsNotFound
-		OutputDebugString("ActiveBasic.Windows.UI.Control.WndProcFirst: The attached instance is not found.")
+		OutputDebugString(Ex"ActiveBasic.Windows.UI.Control.WndProcFirst: The attached instance is not found.\r\n")
 		WndProcFirst = DefWindowProc(hwnd, msg, wp, lp)
 	End Function
@@ -408,87 +407,5 @@
 End Class
 
-Class Form '仮
-	Inherits Control
-Protected
-	Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
-		With cs
-			.lpCreateParams = 0
-			'.hInstance
-			.hMenu = 0
-			.hwndParent = 0
-			.cy = CW_USEDEFAULT
-			.cx = CW_USEDEFAULT
-			.y = CW_USEDEFAULT
-			.x = CW_USEDEFAULT
-			.style = WS_OVERLAPPEDWINDOW
-			.lpszName = ""
-			'.lpszClass
-			.dwExStyle = 0
-		End With
-	End Sub
-Public 
-
-	Override Function WndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
-		WndProc = 0
-		Select Case msg
-			Case Else
-				WndProc = Super.WndProc(msg, wp, lp)
-		End Select
-	End Function
-End Class
-
 End Namespace 'UI
 End Namespace 'Widnows
 End Namespace 'ActiveBasic
-
-'----------
-'テスト実行用
-
-Imports ActiveBasic.Windows.UI
-
-'OleInitialize()
-Control.Initialize(GetModuleHandle(0))
-
-Class MyForm
-	Inherits Form
-Public
-	Sub MyForm()
-		Dim f = This
-		f.AddMessageEvent(WM_DESTROY, AddressOf (f.Destory))
-		f.AddPaintDC(AddressOf (f.Paint))
-	End Sub
-
-	Sub Destory(sender As Object, e As EventArgs)
-		OutputDebugString(Ex"Destory\r\n")
-		PostQuitMessage(0)
-	End Sub
-
-	Sub Paint(sender As Object, e As PaintDCEventArgs)
-		TextOut(e.Handle, 10, 10, "Hello world!", 12)
-	End Sub
-End Class
-
-Dim f = New MyForm
-f.Create()
-ShowWindow(f.Handle, SW_SHOW)
-
-Dim m As MSG
-Do
-	Dim ret = GetMessage(m, 0, 0, 0)
-	If ret = 0 Then
-		Exit Do
-	ElseIf ret = -1 Then
-		ExitProcess(-1)
-	End If
-
-	TranslateMessage(m)
-	DispatchMessage(m)
-Loop
-
-f = Nothing
-System.GC.Collect()
-
-Control.Uninitialize()
-'OleUninitialize()
-
-End
Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/EventArgs.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/EventArgs.ab	(revision 545)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/EventArgs.ab	(revision 547)
@@ -8,6 +8,11 @@
 Namespace UI
 
-TypeDef EventArgs = System.EventArgs
-TypeDef EventHandler = System.EventHandler
+'TypeDef EventArgs = System.EventArgs
+'TypeDef EventHandler = System.EventHandler
+Class EventArgs
+Public
+	Static Empty = Nothing As EventArgs
+End Class
+Delegate Sub EventHandler(sender As Object, e As EventArgs)
 
 Class MessageEventArgs
@@ -118,4 +123,5 @@
 		This.clicks = clicks
 		This.pt = New System.Drawing.Point(x, y)
+		OutputDebugString(ToTCStr(Hex$(y) + " " + Hex$(pt.Y) + " " +  Ex" mea\r\n"))
 		This.delta = delta
 	End Sub
@@ -445,7 +451,7 @@
 	'Menu: pcs->hMenu
 
-	Const Function Parent() As Control
-		'Parent = Control.FromHandle(pcs->hwndParent)
-	End Function
+'	Const Function Parent() As Control
+'		Parent = Control.FromHandle(pcs->hwndParent)
+'	End Function
 
 	Const Function Height() As Long
Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab	(revision 547)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab	(revision 547)
@@ -0,0 +1,91 @@
+'Classes/ActiveBasic/Windows/UI/Form.ab
+
+#require <Classes/ActiveBasic/Windows/UI/Control.ab>
+
+Namespace ActiveBasic
+Namespace Windows
+Namespace UI
+
+/*!
+@date 2008/07/13
+@brief	トップレベルウィンドウを表すクラス。
+@author Egtra
+*/
+Class Form
+	Inherits Control
+Protected
+	Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
+		With cs
+			.lpCreateParams = 0
+			'.hInstance
+			.hMenu = 0
+			.hwndParent = 0
+			.cy = CW_USEDEFAULT
+			.cx = CW_USEDEFAULT
+			.y = CW_USEDEFAULT
+			.x = CW_USEDEFAULT
+			.style = WS_OVERLAPPEDWINDOW
+			.lpszName = ""
+			'.lpszClass
+			.dwExStyle = 0
+		End With
+	End Sub
+#include "FormEvent.sbp"
+End Class
+
+End Namespace 'UI
+End Namespace 'Widnows
+End Namespace 'ActiveBasic
+
+'----------
+'テスト実行用
+
+#require <Classes/ActiveBasic/Windows/UI/Application.ab>
+
+Imports ActiveBasic.Windows.UI
+
+'OleInitialize()
+Control.Initialize(GetModuleHandle(0))
+
+Class MyForm
+	Inherits Form
+Public
+	Sub MyForm()
+		Dim f = This
+		AddMessageEvent(WM_DESTROY, AddressOf (f.Destory))
+		AddPaintDC(AddressOf (f.Paint))
+		AddMouseClick(AddressOf (f.Mouse))
+		s = ""
+	End Sub
+
+	Sub Destory(sender As Object, e As EventArgs)
+		OutputDebugString(Ex"Destory\r\n")
+		PostQuitMessage(0)
+	End Sub
+
+	Sub Paint(sender As Object, e As PaintDCEventArgs)
+		TextOut(e.Handle, 10, 10, ToTCStr(s), s.Length)
+	End Sub
+
+	Sub Mouse(sender As Object, e As MouseEventArgs)
+		Dim sb = New System.Text.StringBuilder
+		sb.Append("X = ").Append(e.X).Append(", Y = ").Append(e.Y)
+		s = sb.ToString
+		OutputDebugString(ToTCStr(s + " " + Hex$(ObjPtr(e)) + Ex"\r\n"))
+		Invalidate()
+	End Sub
+
+	s As String
+End Class
+
+Dim f = New MyForm
+f.Create()
+Application.Run(f)
+f = Nothing
+System.GC.Collect()
+
+Control.Uninitialize()
+'OleUninitialize()
+
+End
+
Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/FormEventList.txt
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/FormEventList.txt	(revision 547)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/FormEventList.txt	(revision 547)
@@ -0,0 +1,8 @@
+'f	Activate	WM_ACTIVATE
+'s	HScroll	WM_HSCROLL
+'f	Notify	WM_NOTIFY
+'f	QueryClose	WM_CLOSE
+'f	Timer	WM_TIMER
+'Activate	Event	ウィンドウがアクティブになったときに呼ばれます。
+'Deactivate	Event	ウィンドウがアクティブでなくなったときに呼ばれます。
+QueryClose	FormClosingEvent	ウィンドウが閉じられようとしているときに呼ばれます。
Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp	(revision 545)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp	(revision 547)
@@ -31,7 +31,4 @@
 Declare Function _System_IsWindow Lib "user32" Alias "IsWindow" (hWnd As HWND) As BOOL
 Declare Function _System_IsIconic Lib "user32" Alias "IsIconic" (hWnd As HWND) As BOOL
-Declare Function _System_GetClientRect Lib "user32" Alias "GetClientRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL
-Declare Function _System_GetProp Lib "user32" Alias _FuncName_GetProp (hWnd As HWND, pString As PCTSTR) As HANDLE
-Declare Function _System_SetProp Lib "user32" Alias _FuncName_SetProp (hWnd As HWND, pString As PCTSTR, hData As HANDLE) As BOOL
 Declare Function _System_GetClassName Lib "user32" Alias _FuncName_GetClassName (hWnd As HWND, lpClassName As PTSTR, nMaxCount As Long) As Long
 Declare Function _System_GetScrollInfo Lib "user32" Alias "GetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO) As BOOL
@@ -69,5 +66,12 @@
 		Return hwnd
 	End Function
-
+/*
+	Static Function FromHWnd(hwnd As HWND) As WindowHandle
+		FromHWnd = Control.FromHWnd(hwnd)
+		If IsNothing(FromHWnd) Then
+			FromHWnd = New WindowHandle(hwnd)
+		End If
+	End Function
+*/
 	Function BringToTop() As Boolean
 		Return BringWindowToTop(hwnd) As Boolean
@@ -76,4 +80,8 @@
 	Function BeginPaint(ByRef ps As PAINTSTRUCT) As HDC
 		Return _System_BeginPaint(hwnd, ps)
+	End Function
+
+	Function BeginPaint() As PAINTSTRUCT
+		_System_BeginPaint(hwnd, BeginPaint)
 	End Function
 /*
@@ -139,7 +147,4 @@
 	End Function
 
-	Const Function GetClientRect(ByRef rc As RECT) As Boolean
-		Return _System_GetClientRect(hwnd, rc) As Boolean
-	End Function
 /*
 	Const Function GetContextHelpId() As DWord
@@ -175,16 +180,4 @@
 	End Function
 */
-	Const Function GetProp(str As String) As HANDLE
-		Return _System_GetProp(hwnd, ToTCStr(str))
-	End Function
-
-	Const Function GetProp(psz As PCTSTR) As HANDLE
-		Return _System_GetProp(hwnd, psz)
-	End Function
-
-	Const Function GetProp(atom As ATOM) As HANDLE
-		Return _System_GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
-	End Function
-
 	Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
 		Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
@@ -219,18 +212,6 @@
 	End Function
 */
-	Const Function GetWindowRect(ByRef rc As RECT) As Boolean
-		Return _System_GetWindowRect(hwnd, rc) As Boolean
-	End Function
-
 	Const Function GetText(ps As PTSTR, maxCount As Long) As Boolean
 		Return GetWindowText(hwnd, ps, maxCount) As Boolean
-	End Function
-
-	Const Function GetTextLength() As Long
-		Return GetWindowTextLength(hwnd)
-	End Function
-
-	Const Function GetWindowThreadId() As DWord
-		Return _System_GetWindowThreadProcessId(hwnd, 0)
 	End Function
 
@@ -444,16 +425,4 @@
 	End Function
 
-	Function SetProp(str As String, hData As HANDLE) As Boolean
-		Return _System_SetProp(hwnd, ToTCStr(str), hData) As Boolean
-	End Function
-
-	Function SetProp(psz As PCTSTR, hData As HANDLE) As Boolean
-		Return _System_SetProp(hwnd, psz, hData) As Boolean
-	End Function
-
-	Function SetProp(atom As ATOM, hData As HANDLE) As Boolean
-		Return This.SetProp((atom As ULONG_PTR) As PCTSTR, hData) As Boolean
-	End Function
-
 	Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw As Boolean) As Boolean
 		Return _System_SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
@@ -502,12 +471,4 @@
 	End Function
 
-	Function SetText(psz As PCTSTR) As Boolean
-		Return SetWindowText(hwnd, psz) As Boolean
-	End Function
-
-	Function SetText(str As String) As Boolean
-		Return SetWindowText(hwnd, ToTCStr(str)) As Boolean
-	End Function
-
 	Function ShowCaret() As Boolean
 		Return _System_ShowCaret(hwnd) As Boolean
@@ -546,46 +507,8 @@
 	End Function
 
-	' Get/SetWindowLongPtr Wrappers
-
-	Const Function GetExStyle() As DWord
-		Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
-	End Function
-
-	Const Function GetStyle() As DWord
-		Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
-	End Function
-#ifdef _UNDEF
-	Const Function GetWndProc() As WNDPROC
-		Return _System_GetWindowLongPtr(hwnd, GWLP_WNDPROC) As WNDPROC
-	End Function
-#endif
-	Const Function GetInstance() As HINSTANCE
-		Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
-	End Function
-
-	Const Function GetUserData() As LONG_PTR
-		Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
-	End Function
-
-	Function SetExStyle(style As DWord) As DWord
-		Return _System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, style) As DWord
-	End Function
-
-	Function SetStyle(style As DWord) As DWord
-		Return _System_SetWindowLongPtr(hwnd, GWL_STYLE, style) As DWord
-	End Function
-#ifdef _UNDEF
-	Function SetWndProc(wndProc As WNDPROC) As WNDPROC
-		Return _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, wndProc As WNDPROC) As WNDPROC
-	End Function
-#endif
-	Function SetUserData(value As LONG_PTR) As LONG_PTR
-		Return _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, value As LONG_PTR)
-	End Function
-
 	' Propaties
 
 	Const Function ClientRect() As RECT
-		_System_GetClientRect(hwnd, ClientRect)
+		GetClientRect(hwnd, ClientRect)
 	End Function
 #ifdef _UNDEF
@@ -717,28 +640,33 @@
 
 	Const Function Prop(str As String) As HANDLE
-		Return GetProp(str)
+		Return GetProp(hwnd, ToTCStr(str))
 	End Function
 
 	Const Function Prop(psz As PCTSTR) As HANDLE
-		Return GetProp(psz)
+		Return GetProp(hwnd, psz)
 	End Function
 
 	Const Function Prop(atom As ATOM) As HANDLE
-		Return GetProp(atom)
-	End Function
+		Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
+	End Function
+
+	Sub Prop(str As String, hData As HANDLE)
+		SetProp(hwnd, ToTCStr(str), hData)
+	End Sub
 
 	Sub Prop(str As PCTSTR, h As HANDLE)
-		SetProp(str, h)
+		SetProp(hwnd, str, h)
 	End Sub
 
 	Sub Prop(atom As ATOM, h As HANDLE)
-		SetProp(atom, h)
+		SetProp(hwnd, atom As ULONG_PTR As PCTSTR, h)
 	End Sub
 
 	Const Function Text() As String
 		Dim size = GetWindowTextLength(hwnd) + 1
-		Dim p = GC_malloc_atomic(SizeOf (TCHAR) * size) As PTSTR
-		Dim length = GetWindowText(hwnd, p, size)
-		Text = New String(p, length As Long)
+		Dim sb = New System.Text.StringBuilder(size)
+		sb.Length = size
+		Dim length = GetWindowText(hwnd, StrPtr(sb), size)
+		Text = sb.ToString
 	End Function
 
