Index: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp	(revision 637)
+++ trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.ab	(revision 646)
@@ -1,25 +1,8 @@
 'Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
 
-#ifdef _WIN64
-Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
-Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
-Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
-Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
-#else
-Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLong (hWnd As HWND, nIndex As Long) As LONG_PTR
-Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
-Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLong (hWnd As HWND, nIndex As Long) As LONG_PTR
-Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
-#endif
-Declare Function _System_GetParent Lib "user32" Alias "GetParent" (hWnd As HWND) As HWND
-Declare Function _System_SetParent Lib "user32" Alias "SetParent" (hWnd As HWND, hwndParent As HWND) As HWND
 Declare Function _System_GetMenu Lib "user32" Alias "GetMenu" (hWnd As HWND) As HMENU
-Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As HMENU
-Declare Function _System_InvalidateRect Lib "user32" Alias "InvalidateRect" (hWnd As HWND, ByRef Rect As RECT, bErase As BOOL) As BOOL
-Declare Function _System_InvalidateRgn Lib "user32" Alias "InvalidateRgn" (hWnd As HWND, hRgn As HRGN, bErase As BOOL) As BOOL
+Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As BOOL
 Declare Function _System_ValidateRect Lib "user32" Alias "ValidateRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL
 Declare Function _System_ValidateRgn Lib "user32" Alias "ValidateRgn" (hWnd As HWND, hRgn As HRGN) As BOOL
-Declare Function _System_BeginPaint Lib "user32" Alias "BeginPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC
-Declare Function _System_EndPaint Lib "user32" Alias "EndPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC
 Declare Function _System_ClientToScreen Lib "user32" Alias "ClientToScreen" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
 Declare Function _System_ScreenToClient Lib "user32" Alias "ScreenToClient" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
@@ -28,8 +11,4 @@
 Declare Function _System_ShowCaret Lib "user32" Alias "ShowCaret" (hWnd As HWND) As BOOL
 Declare Function _System_DrawMenuBar Lib "user32" Alias "DrawMenuBar" (hwnd As HWND) As BOOL
-Declare Function _System_GetWindowRect Lib "user32" Alias "DrawMenuBar" (hWnd As HWND, ByRef Rect As RECT) As BOOL
-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_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
 Declare Function _System_SetScrollInfo Lib "user32" Alias "SetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO, bRedraw As Long) As BOOL
@@ -39,7 +18,10 @@
 Declare Function _System_GetWindowDC Lib "user32" Alias "GetWindowDC" (hwnd As HWND) As HDC
 Declare Function _System_ReleaseDC Lib "user32" Alias "ReleaseDC" (hwnd As HWND, hdc As HDC) As BOOL
-Declare Function _System_SendMessage Lib "user32" Alias _FuncName_SendMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
-Declare Function _System_PostMessage Lib "user32" Alias _FuncName_PostMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
-Declare Function _System_SendDlgItemMessage Lib "user32" Alias _FuncName_SendDlgItemMessage (hwnd As HWND, id As DWord, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+'Declare Function _System_SendMessage Lib "user32" Alias _FuncName_SendMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+'Declare Function _System_PostMessage Lib "user32" Alias _FuncName_PostMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+'Declare Function _System_SendDlgItemMessage Lib "user32" Alias _FuncName_SendDlgItemMessage (hwnd As HWND, id As DWord, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+Declare Function _System_SendMessage Lib "user32" Alias "SendMessageA" (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+Declare Function _System_PostMessage Lib "user32" Alias "PostMessageA" (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+Declare Function _System_SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (hwnd As HWND, id As DWord, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
 Declare Function _System_GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (hwnd As HWND, pdwProcessId As *DWord) As DWord
 
@@ -50,4 +32,10 @@
 Class WindowHandle
 	hwnd As HWND
+Private
+	Sub ThrowIfFailedNT(ret As BOOL, msg As String)
+		If ret = FALSE Then
+			ThrowWithLastErrorNT(msg)
+		End If
+	End Sub
 Public
 	Sub WindowHandle()
@@ -74,432 +62,55 @@
 	End Function
 */
-	Function BringToTop() As Boolean
-		Return BringWindowToTop(hwnd) As Boolean
-	End Function
-
-	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
-/*
-	Const Function ChildFromPoint(x As Long, y As Long) As WindowHandle
-		Return New WindowHandle(ChildWindowFromPoint(hwnd, x, y))
-	End Function
-
-	Const Function ChildFromPointEx(x As Long, y As Long, flags As DWord) As WindowHandle
-		Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags))
-	End Function
-*/
-	Const Function ClientToScreen(ByRef pt As POINTAPI) As Boolean
-		Return _System_ClientToScreen(hwnd, pt) As Boolean
-	End Function
-
-	Const Function ClientToScreen(ByRef rc As RECT) As Boolean
-		Dim ppt = VarPtr(rc) As *POINTAPI
-		Return (_System_ClientToScreen(hwnd, ppt[0]) <> FALSE And _System_ClientToScreen(hwnd, ppt[1]) <> FALSE) As Boolean
-	End Function
-
-	Function Close() As Boolean
-		Return CloseWindow(hwnd) As Boolean
-	End Function
-
-	Function CreateCaret(hbmp As HBITMAP, width As Long, height As Long) As Boolean
-		Return _System_CreateCaret(hwnd, hbmp, width, height) As Boolean
-	End Function
-
-	Function Destroy() As Boolean
-		Return DestroyWindow(hwnd) As Boolean
-	End Function
-
-	Function DrawMenuBar() As Boolean
-		Return _System_DrawMenuBar(hwnd) As Boolean
-	End Function
-/*
-	Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean
-		Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean
-	End Function
-*/
-	Function Enable(enable As Boolean) As Boolean
-		Return EnableWindow(hwnd, enable) As Boolean
-	End Function
-
-	Function EndPaint(ByRef ps As PAINTSTRUCT) As Boolean
-		Return _System_EndPaint(hwnd, ps) As Boolean
-	End Function
-
-	Const Function EnumChilds(enumFunc As WNDENUMPROC, lp As LPARAM) As Boolean
-		Return EnumChildWindows(hwnd, enumFunc, lp) As Boolean
-	End Function
-
-	Function Flash(invert As Boolean) As Boolean
-		Return FlashWindow(hwnd, invert) As Boolean
-	End Function
-
-	Const Function GetClassLongPtr(index As Long) As LONG_PTR
-		Return _System_GetClassLongPtr(hwnd, index)
-	End Function
-
-	Const Function GetClassName(className As PTSTR, maxCount As Long) As Long
-		Return _System_GetClassName(hwnd, className, maxCount)
-	End Function
-
-/*
-	Const Function GetContextHelpId() As DWord
-		Return GetWindowContextHelpId(hwnd)
-	End Function
-*/
-	Function GetDC() As HDC
-		Return _System_GetDC(hwnd)
-	End Function
-
-	Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC
-		Return _System_GetDCEx(hwnd, hrgnClip, flags)
-	End Function
-/*
-	Const Function GetDlgCtrlID() As Long
-		Return GetDlgCtrlID(hwnd)
-	End Function
-
-	Const Function GetDlgItem(idDlgItem As Long) As WindowHandle
-		Return GetDlgItem(hwnd, idDlgItem)
-	End Function
-
-	Const Function GetDlgItemText(idDlgItem As Long, ps As PTSTR, maxCount As Long) As Long
-		Return GetDlgItemText(hwnd, idDlgItem, ps, maxCount)
-	End Function
-*/
-	Const Function GetMenu() As HMENU
-		Return _System_GetMenu(hwnd)
-	End Function
-/*
-	Const Function GetParent() As WindowHandle
-		Return New WindowHandle(_System_GetParent(hwnd))
-	End Function
-*/
-	Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
-		Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
-	End Function
-/*
-	Const Function GetSystemMenu(revert As Boolean) As HMENU
-		Return GetSystemMenu(hwnd, revert)
-	End Function
-
-	Const Function GetUpdateRect(ByRef rc As RECT, erase As Boolean) As Boolean
-		Return GetUpdateRact(hwnd, rc, erase) As Boolean
-	End Function
-
-	Const Function GetUpdateRgn(hrgn As HRGN, erase As Boolean) As Boolean
-		Return GetUpdateRgn(hwnd, hrgn, erase) As Boolean
-	End Function
-
-	Const Function GetWindow(cmd As DWord) As WindowHandle
-		Return GetWindow(hwnd, cmd)
-	End Function
-*/
-	Function GetWindowDC() As HDC
-		Return _System_GetWindowDC(hwnd)
-	End Function
-
-	Const Function GetWindowLongPtr(index As Long) As LONG_PTR
-		Return _System_GetWindowLongPtr(hwnd, index)
-	End Function
-/*
-	Const Function GetWindowPlasement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
-		Return GetWindowPlasement(hwnd, wndpl) 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 GetWindowThreadProcessId(ByRef processId As DWord) As DWord
-		Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId))
-	End Function
-
-	Function HideCaret() As Boolean
-		Return _System_HideCaret(hwnd) As Boolean
-	End Function
-
-	Function InvalidateRect(ByRef rc As RECT, erace As Boolean) As Boolean
-		Return _System_InvalidateRect(hwnd, rc, erace) As Boolean
-	End Function
-
-	Function InvalidateRect(ByRef rc As RECT) As Boolean
-		Return _System_InvalidateRect(hwnd, rc, TRUE) As Boolean
-	End Function
-
-	Function InvalidateRgn(hrgn As HRGN, erace As Boolean) As Boolean
-		Return _System_InvalidateRgn(hwnd, hrgn, erace) As Boolean
-	End Function
-
-	Function InvalidateRgn(hrgn As HRGN) As Boolean
-		Return _System_InvalidateRgn(hwnd, hrgn, TRUE) As Boolean
-	End Function
-
-	Function Invalidate(erace As Boolean) As Boolean
-		Return _System_InvalidateRect(hwnd, ByVal 0, erace) As Boolean
-	End Function
-
-	Function Invalidate() As Boolean
-		Return _System_InvalidateRect(hwnd, ByVal 0, TRUE) As Boolean
-	End Function
-/*
-	Const Function IsChild(hwnd As HWND) As Boolean
-		Return IsChild(This.hwnd, hwnd) As Boolean
-	End Function
-
-	Const Function IsDialogMessage(ByRef msg As MSG) As Boolean
-		Return IsDialogMessage(hwnd, msg) As Boolean
-	End Function
-*/
-	Const Function IsIconic() As Boolean
-		Return _System_IsIconic(hwnd) As Boolean
-	End Function
-
-	Const Function IsWindow() As Boolean
-		Return _System_IsWindow(hwnd) As Boolean
-	End Function
-
-	Const Function IsEnabled() As Boolean
-		Return IsWindowEnabled(hwnd) As Boolean
-	End Function
-
-	Const Function IsUnicode() As Boolean
-		Return IsWindowUnicode(hwnd) As Boolean
-	End Function
-
-	Const Function IsVisible() As Boolean
-		Return IsWindowVisible(hwnd) As Boolean
-	End Function
-/*
-	Const Function IsZoomed() As Boolean
-		Return IsZoomed(hwnd) As Boolean
-	End Function
-
-	Function KillTimer(idEvent As ULONG_PTR) As Boolean
-		Return KillTimer(idEvent) As Boolean
-	End Function
-*/
-	Function LockUpdate() As Boolean
-		Return LockWindowUpdate(hwnd) As Boolean
-	End Function
-/*
-	Function MapPoints(hwndTo As HWND, pPoints As *POINTAPI, cPoints As DWord) As Long
-		Return MapWindowPoints(hwnd, hwndTo, pPoints, cPoints)
-	End Function
-
-	Function MapPoints(hwndTo As HWND, ByRef rc As RECT) As Long
-		Return MapWindowPoints(hwnd, hwndTo, VarPtr(rc) As *POINTAPI, 2)
-	End Function
-
-	Const Function MessageBox(text As PCTSTR, caption As PCTSTR, uType As DWord) As Long
-		Return MessageBox(hwnd, text, caption, uType)
-	End Function
-
-	Const Function MessageBox(text As PCTSTR, caption As PCTSTR) As Long
-		Return MessageBox(hwnd, text, caption, MB_OK)
-	End Function
-
-	Const Function MessageBox(text As PCTSTR) As Long
-		Return MessageBox(hwnd, text, 0, MB_OK)
-	End Function
-*/
-	Function Move(x As Long, y As Long, width As Long, height As Long, repaint = True As Boolean) As Boolean
-		Return MoveWindow(hwnd, x, y, width, height, repaint) As Boolean
-	End Function
-
-	Function Move(ByRef rc As RECT, repaint = True As Boolean) As Boolean
+	Sub BringToTop()
+		ThrowIfFailedNT(BringWindowToTop(hwnd), "WindowHandle.BringToTop")
+	End Sub
+
+'座標関係
+	Const Function ClientToScreen(ByRef pt As POINTAPI) As POINTAPI
+		ClientToScreen = pt
+		ThrowIfFailedNT(_System_ClientToScreen(hwnd, ClientToScreen), "WindowHandle.ClientToScreen")
+	End Function
+
+	Const Function ClientToScreen(ByRef rc As RECT) As RECT
+		ClientToScreen = rc
+		Dim ppt = VarPtr(ClientToScreen) As *POINTAPI
+		ThrowIfFailedNT(_System_ClientToScreen(hwnd, ppt[0]), "WindowHandle.ClientToScreen")
+		ThrowIfFailedNT(_System_ClientToScreen(hwnd, ppt[1]), "WindowHandle.ClientToScreen")
+	End Function
+
+	Const Function ScreenToClient(ByRef pt As POINTAPI) As POINTAPI
+		ScreenToClient = pt
+		ThrowIfFailedNT(_System_ScreenToClient(hwnd, ScreenToClient), "WindowHandle.ScreenToClient")
+	End Function
+
+	Const Function ScreenToClient(ByRef rc As RECT) As RECT
+		ScreenToClient = rc
+		Dim ppt = VarPtr(ScreenToClient) As *POINTAPI
+		ThrowIfFailedNT(_System_ScreenToClient(hwnd, ppt[0]), "WindowHandle.ClientToScreen")
+		ThrowIfFailedNT(_System_ScreenToClient(hwnd, ppt[1]), "WindowHandle.ClientToScreen")
+	End Function
+
+	Sub Move(x As Long, y As Long, width As Long, height As Long, repaint = True As Boolean)
+		ThrowIfFailedNT(MoveWindow(hwnd, x, y, width, height, repaint), "WindowHandle.Move")
+	End Sub
+
+	Sub Move(ByRef rc As RECT, repaint = True As Boolean)
 		With rc
-			Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, repaint) As Boolean
+			Move(.left, .top, .right - .left, .bottom - .top, repaint)
 		End With
-	End Function
-
-/*
-	Function OpenClipboard() As Boolean
-		Return OpenClipboard(hwnd) As Boolean
-	End Function
-
-	Function OpenIcon() As Boolean
-		Return OpenIcon(hwnd) As Boolean
-	End Function
-*/
-	Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
-		Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
-	End Function
-
-	Function PostMessage(msg As DWord) As Boolean
-		Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
-	End Function
-/*
-	Function RedrawWindow(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord) As Boolean
-		Return RedrawWindow(hwnd, rcUpdatre, hrgnUpdate, flags) As Boolean
-	End Function
-*/
-	Function ReleaseDC(hdc As HDC) As Boolean
-		Return _System_ReleaseDC(hwnd, hdc) As Boolean
-	End Function
-/*
-	Function RemoveProp(str As String) As HANDLE
-		Return RemoveProp(hwnd, ToTCStr(str))
-	End Function
-
-	Function RemoveProp(psz As PCTSTR) As HANDLE
-		Return RemoveProp(hwnd, psz)
-	End Function
-
-	Function RemoveProp(atom As ATOM) As HANDLE
-		Return RemoveProp(hwnd, atom As ULONG_PTR As PCTSTR)
-	End Function
-*/
-	Const Function ScreenToClient(ByRef pt As POINTAPI) As Boolean
-		Return _System_ScreenToClient(hwnd, pt) As Boolean
-	End Function
-
-	Const Function ScreenToClient(ByRef rc As RECT) As Boolean
-		Dim ppt = VarPtr(rc) As *POINTAPI
-		Return (_System_ScreenToClient(hwnd, ppt[0]) <> FALSE And _System_ScreenToClient(hwnd, ppt[1]) <> FALSE) As Boolean
-	End Function
-
-	Function Scroll(dx As Long, dy As Long, ByRef rcScroll As RECT, ByRef rcClip As RECT, hrgnUpdate As HRGN, ByRef rcUpdate As RECT, flags As DWord) As Boolean
-		Return ScrollWindowEx(hwnd, dx, dy, rcScroll, rcClip, hrgnUpdate, rcUpdate, flags) As Boolean
-	End Function
-
-	Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
-		Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp)
-	End Function
-
-	Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
-		Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
-	End Function
-
-	Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
-		Return _System_SendMessage(hwnd, msg, wp, lp)
-	End Function
-
-	Function SendMessage(msg As DWord) As LRESULT
-		Return _System_SendMessage(hwnd, msg, 0, 0)
-	End Function
-/*
-	Function SetActiveWindow() As WindowHandle
-		Return New WindowHandle(SetActiveWindow(hwnd))
-	End Function
-
-	Function SetDlgItemText(idDlgItem As Long, psz As PCTSTR) As Boolean
-		Return SetDlgItemText(hwnd, idDlgItem, psz) As Boolean
-	End Function
-
-	Function SetCapture() As WindowHandle
-		Return New WindowHandle(SetCapture(hwnd))
-	End Function
-*/
-	Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
-		Return _System_SetClassLongPtr(hwnd, index, newLong)
-	End Function
-/*
-	Function SetFocus() As WindowHandle
-		Return New WindowHandle(SetFocus(hwnd))
-	End Function
-*/
-	Function SetForeground() As Boolean
-		Return SetForegroundWindow(hwnd) As Boolean
-	End Function
-
-	Function SetMenu(hmenu As HMENU) As Boolean
-		Return _System_SetMenu(hwnd, hmenu) As Boolean
-	End Function
-
-	Function SetParent(hwndNewParent As HWND) As WindowHandle
-		Return New WindowHandle(_System_SetParent(hwnd, hwndNewParent))
-	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
-	End Function
-
-	Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
-		Return _System_SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
-	End Function
-/*
-	Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
-		Return SetTmer(hwnd, idEvent, elapse, timerFunc)
-	End Function
-
-	Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
-		Return This.SetTmer(hwnd, idEvent, elapse, 0)
-	End Function
-
-	Function SetContextHelpId(contextHelpId As DWord) As Boolean
-		Return SetContextHelpId(hwnd, contextHelpId) As Boolean
-	End Function
-*/
-	Function SetWindowLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
-		Return _System_SetWindowLongPtr(hwnd, index, newLong)
-	End Function
-/*
-	Function SetWindowPlacement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
-		Return SetWindowPlacement(hwnd, wndpl) As Boolean
-	End Function
-*/
-	Function SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord) As Boolean
-		Return SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags) As Boolean
-	End Function
-
-	Function SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord) As Boolean
+	End Sub
+
+	Sub SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord)
+		ThrowIfFailedNT(SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags), "WindowHandle.SetPos")
+	End Sub
+
+	Sub SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord)
 		With rc
-			Return SetWindowPos(hwnd, hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags) As Boolean
+			SetPos(hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags)
 		End With
-	End Function
-
-	Function SetRgn(hrgn As HRGN, redraw As Boolean) As Boolean
-		Return SetWindowRgn(hwnd, hrgn, redraw) As Boolean
-	End Function
-
-	Function SetRgn(hrgn As HRGN) As Boolean
-		Return SetWindowRgn(hwnd, hrgn, TRUE) As Boolean
-	End Function
-
-	Function ShowCaret() As Boolean
-		Return _System_ShowCaret(hwnd) As Boolean
-	End Function
-/*
-	Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
-		Return ShowScrollBar(hwnd, bar, show) As Boolean
-	End Function
-
-	Function ShowScrollBar(bar As DWord) As Boolean
-		Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
-	End Function
-*/
-	Function Show(cmdShow As DWord) As Boolean
-		Return ShowWindow(hwnd, cmdShow) As Boolean
-	End Function
-
-	Function ShowAsync(cmdShow As DWord) As Boolean
-		Return ShowWindowAsync(hwnd, cmdShow) As Boolean
-	End Function
-
-	Function Update() As Boolean
-		Return UpdateWindow(hwnd) As Boolean
-	End Function
-
-	Function ValidateRect(ByRef rc As RECT) As Boolean
-		Return _System_ValidateRect(hwnd, rc) As Boolean
-	End Function
-
-	Function ValidateRgn(hrgn As HRGN) As Boolean
-		Return _System_ValidateRgn(hwnd, hrgn) As Boolean
-	End Function
-
-	Function Validate() As Boolean
-		Return _System_ValidateRect(hwnd, ByVal 0) As Boolean
-	End Function
-
-	' Propaties
+	End Sub
 
 	Const Function ClientRect() As RECT
-		GetClientRect(hwnd, ClientRect)
+		ThrowIfFailedNT(GetClientRect(hwnd, ClientRect), "WindowHandle.ClientRect")
 	End Function
 #ifdef _UNDEF
@@ -516,5 +127,5 @@
 #endif
 	Const Function WindowRect() As RECT
-		_System_GetWindowRect(hwnd, WindowRect)
+		GetWindowRect(hwnd, WindowRect)
 	End Function
 
@@ -522,95 +133,31 @@
 		This.Move(rc)
 	End Sub
-#ifdef _UNDEF
-	Const Function ContextHelpID() As DWord
-		Return GetContextHelpId(hwnd)
-	End Function
-
-	Sub ContextHelpID(newID As DWord)
-		_System_SetContextHelpId(hwnd, newId)
-	End Sub
-
-	Const Function DlgCtrlID() As Long
-		Return GetDlgCtrlID(hwnd)
-	End Function
-
-	Sub DlgCtrlId(newId As Long)
-		_System_SetWindowLongPtr(hwnd, GWLP_ID, newId)
-	End Sub
-#endif
-	Function DlgItem(idDlgItem As Long) As WindowHandle
-		Dim w As WindowHandle(GetDlgItem(hwnd, idDlgItem))
-		Return w
-	End Function
-
-	Const Function ExStyle() As DWord
-		Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
-	End Function
-
-	Sub ExStyle(newExStyle As DWord)
-		_System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle)
-	End Sub
-
-	Const Function Style() As DWord
-		Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
-	End Function
-
-	Sub Style(newStyle As DWord)
-		_System_SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
-	End Sub
-
-	Const Function Enabled() As Boolean
-		Return IsWindowEnabled(hwnd) As Boolean
-	End Function
-
-	Sub Enabled(enable As Boolean)
-		EnableWindow(hwnd, enable)
-	End Sub
-
-	Const Function Font() As HFONT
-		Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
-	End Function
-
-	Sub Font(hfntNew As HFONT)
-		_System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
-	End Sub
-
-	Const Function Maximized() As Boolean
-		Return IsZoomed(hwnd) As Boolean
-	End Function
-
-	Sub Maximized(maximized As Boolean)
-		If maximized <> False Then
-			ShowWindow(hwnd, SW_SHOWMAXIMIZED)
-		Else
-			ShowWindow(hwnd, SW_RESTORE)
-		End If
-	End Sub
-
-	Const Function Minimized() As Boolean
-		Return _System_IsIconic(hwnd) As Boolean
-	End Function
-
-	Sub Minimized(minimized As Boolean)
-		If minimized <> False Then
-			CloseWindow(hwnd)
-		Else
-			OpenIcon(hwnd)
-		End If
-	End Sub
-
-	Const Function Instance() As HINSTANCE
-		Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
-	End Function
-
-	' IsWindow, IsUnicodeはメソッドと同じ。
-
-	Const Function Parent() As WindowHandle
-		Return New WindowHandle(_System_GetParent(hwnd))
-	End Function
-
-	Sub Parent(hwndNewParent As HWND)
-		_System_SetParent(hwnd, hwndNewParent)
-	End Sub
+
+	Const Function WindowPlacement() As WINDOWPLACEMENT
+		WindowPlacement.length = Len(WindowPlacement)
+		ThrowIfFailedNT(GetWindowPlacement(hwnd, WindowPlacement), "WindowHandle.WindowPlacement (get)")
+	End Function
+
+	Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
+		ThrowIfFailedNT(SetWindowPlacement(hwnd, wndpl), "WindowHandle.WindowPlacement (set)")
+	End Sub
+
+'キャレット
+	Sub CreateCaret(hbmp As HBITMAP, width As Long, height As Long)
+		ThrowIfFailedNT(_System_CreateCaret(hwnd, hbmp, width, height), "WindowHandle.CreateCaret")
+	End Sub
+
+	Sub HideCaret()
+		ThrowIfFailedNT(_System_HideCaret(hwnd), "WindowHandle.HideCaret")
+	End Sub
+
+	Sub ShowCaret()
+		ThrowIfFailedNT(_System_ShowCaret(hwnd), "WindowHandle.ShowCaret")
+	End Sub
+'全般
+	Sub Destroy()
+		DestroyWindow(hwnd)
+	End Sub
+
 
 	Const Function ProcessId() As DWord
@@ -621,12 +168,4 @@
 		Return GetWindowThreadProcessId(ByVal 0)
 	End Function
-
-	Const Function Menu() As HMENU
-		Return _System_GetMenu(hwnd)
-	End Function
-
-	Sub Menu(hmenuNew As HMENU)
-		_System_SetMenu(hwnd, hmenuNew)
-	End Sub
 
 	Const Function Prop(str As String) As HANDLE
@@ -674,13 +213,73 @@
 		Return GetWindowTextLength(hwnd)
 	End Function
-#ifdef _UNDEF
-	Const Function UserData() As LONG_PTR
-		Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
-	End Function
-
-	Sub UserData(newValue As LONG_PTR)
-		_System_SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
-	End Sub
-#endif
+
+	Function Flash(invert As Boolean) As Boolean
+		Return FlashWindow(hwnd, invert) As Boolean
+	End Function
+/*
+	Const Function GetWindow(cmd As DWord) As WindowHandle
+		Return GetWindow(hwnd, cmd)
+	End Function
+	Const Function IsChild(hwnd As HWND) As Boolean
+		Return IsChild(This.hwnd, hwnd) As Boolean
+	End Function
+
+	Const Function IsDialogMessage(ByRef msg As MSG) As Boolean
+		Return IsDialogMessage(hwnd, msg) As Boolean
+	End Function
+*/
+	Const Function IsValid() As Boolean
+		Return IsWindow(hwnd) As Boolean
+	End Function
+
+	Const Function IsUnicode() As Boolean
+		Return IsWindowUnicode(hwnd) As Boolean
+	End Function
+/*
+	Function KillTimer(idEvent As ULONG_PTR) As Boolean
+		Return KillTimer(idEvent) As Boolean
+	End Function
+
+	Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
+		Return SetTmer(hwnd, idEvent, elapse, timerFunc)
+	End Function
+
+	Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
+		Return This.SetTmer(hwnd, idEvent, elapse, 0)
+	End Function
+
+	Function SetActiveWindow() As WindowHandle
+		Return New WindowHandle(SetActiveWindow(hwnd))
+	End Function
+
+	Function SetCapture() As WindowHandle
+		Return New WindowHandle(SetCapture(hwnd))
+	End Function
+ 
+	Function SetFocus() As WindowHandle
+		Return New WindowHandle(SetFocus(hwnd))
+	End Function
+*/
+	Function SetForeground() As Boolean
+		Return SetForegroundWindow(hwnd) As Boolean
+	End Function
+
+	Const Function ContextHelpID() As DWord
+		Return GetWindowContextHelpId(hwnd)
+	End Function
+
+	Sub ContextHelpID(newId As DWord)
+		ThrowIfFailedNT(SetWindowContextHelpId(hwnd, newId), "WindowHandle.ContextHelpID")
+	End Sub
+'表示関係
+	'呼出前に可視状態だったらTrue、そうでなければFalseが返る。
+	Function Show(cmdShow As DWord) As Boolean
+		Return ShowWindow(hwnd, cmdShow) As Boolean
+	End Function
+
+	Function ShowAsync(cmdShow As DWord) As Boolean
+		Return ShowWindowAsync(hwnd, cmdShow) As Boolean
+	End Function
+
 	Const Function Visible() As Boolean
 		Return IsWindowVisible(hwnd) As Boolean
@@ -694,20 +293,247 @@
 		EndIf
 	End Sub
+
+	Const Function Maximized() As Boolean
+		Return IsZoomed(hwnd) As Boolean
+	End Function
+
+	Sub Maximized(maximized As Boolean)
+		If maximized <> False Then
+			Show(SW_SHOWMAXIMIZED)
+		Else
+			Show(SW_RESTORE)
+		End If
+	End Sub
+
+	Const Function Minimized() As Boolean
+		Return IsIconic(hwnd) As Boolean
+	End Function
+
+	Sub Minimized(minimized As Boolean)
+		If minimized <> False Then
+			CloseWindow(hwnd)
+		Else
+			OpenIcon(hwnd)
+		End If
+	End Sub
+
+	Const Function Enable() As Boolean
+		Return IsWindowEnabled(hwnd) As Boolean
+	End Function
+
+	Sub Enable(enable As Boolean)
+		EnableWindow(hwnd, enable)
+	End Sub
+
+'メニュー
+/*
+	Sub DrawMenuBar()
+		ThrowIfFailedNT(_System_DrawMenuBar(hwnd), "WindowHandle.DrawMenuBar")
+	End Sub
+	Const Function GetMenu() As HMENU
+		Return _System_GetMenu(hwnd)
+	End Function
+
+	Sub SetMenu(hmenu As HMENU)
+		ThrowIfFailedNT(_System_SetMenu(hwnd, hmenu), "WindowHandle.SetMenu")
+	End Sub
+*/
+	Const Function GetWindowThreadProcessId(ByRef processId As DWord) As DWord
+		Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId))
+	End Function
+
+'スクロールバー
+/*
+	Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean
+		Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean
+	End Function
+
+	Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
+		Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
+	End Function
+
+	Function Scroll(dx As Long, dy As Long, ByRef rcScroll As RECT, ByRef rcClip As RECT, hrgnUpdate As HRGN, ByRef rcUpdate As RECT, flags As DWord) As Long
+		Return ScrollWindowEx(hwnd, dx, dy, rcScroll, rcClip, hrgnUpdate, rcUpdate, flags)
+	End Function
+
+	Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw = True As Boolean) As Long
+		Return _System_SetScrollInfo(hwnd, fnBar, si, redraw)
+	End Function
+
+	Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
+		Return ShowScrollBar(hwnd, bar, show) As Boolean
+	End Function
+
+	Function ShowScrollBar(bar As DWord) As Boolean
+		Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
+	End Function
+*/
+'子ウィンドウ
+	Const Sub EnumChilds(enumFunc As WNDENUMPROC, lp As LPARAM)
+		EnumChildWindows(hwnd, enumFunc, lp)
+	End Sub
+/*
+	Const Function ChildFromPoint(x As Long, y As Long) As WindowHandle
+		Return New WindowHandle(ChildWindowFromPoint(hwnd, x, y))
+	End Function
+
+	Const Function ChildFromPointEx(x As Long, y As Long, flags As DWord) As WindowHandle
+		Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags))
+	End Function
+*/
+'描画
+	Function GetDC() As HDC
+		Return _System_GetDC(hwnd)
+	End Function
+
+	Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC
+		Return _System_GetDCEx(hwnd, hrgnClip, flags)
+	End Function
+
+	Function GetWindowDC() As HDC
+		Return _System_GetWindowDC(hwnd)
+	End Function
+
+	Sub Invalidate(ByRef rc As RECT, erace As Boolean)
+		ThrowIfFailedNT(InvalidateRect(hwnd, rc, erace), "WindowHandle.Invalidate")
+	End Sub
+
+	Sub Invalidate(ByRef rc As RECT)
+		ThrowIfFailedNT(InvalidateRect(hwnd, rc, TRUE), "WindowHandle.Invalidate")
+	End Sub
+
+	Sub Invalidate(hrgn As HRGN, erace As Boolean)
+		'InvalidateRgnは常に非0を返すというMSDNライブラリの記述を信じる
+		InvalidateRgn(hwnd, hrgn, erace)
+	End Sub
+
+	Sub Invalidate(hrgn As HRGN)
+		InvalidateRgn(hwnd, hrgn, TRUE)
+	End Sub
+
+	Sub Invalidate(erace As Boolean)
+		ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, erace), "WindowHandle.Invalidate")
+	End Sub
+
+	Sub Invalidate()
+		ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, TRUE), "WindowHandle.Invalidate")
+	End Sub
+
+	Sub Validate(ByRef rc As RECT)
+		ThrowIfFailedNT(ValidateRect(hwnd, rc), "WindowHandle.Validate")
+	End Sub
+
+	Sub Validate(hrgn As HRGN)
+		ThrowIfFailedNT(ValidateRgn(hwnd, hrgn), "WindowHandle.Validate")
+	End Sub
+
+	Sub Validate()
+		ThrowIfFailedNT(ValidateRect(hwnd, ByVal 0), "WindowHandle.Validate")
+	End Sub
+
+	Sub Update()
+		ThrowIfFailedNT(UpdateWindow(hwnd), "WindowHandle.Update")
+	End Sub
+
+	Sub Redraw(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord)
+		ThrowIfFailedNT(RedrawWindow(hwnd, rcUpdate, hrgnUpdate, flags), "WindowHandle.Update")
+	End Sub
+
+	Sub ReleaseDC(hdc As HDC)
+		ThrowIfFailedNT(_System_ReleaseDC(hwnd, hdc), "WindowHandle.ReleaseDC")
+	End Sub
+
+	Sub SetRgn(hrgn As HRGN, redraw = True As Boolean)
+		ThrowIfFailedNT(SetWindowRgn(hwnd, hrgn, redraw), "WindowHandle.SetRgn")
+	End Sub
+'メッセージ
+	Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+		Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp)
+	End Function
+
+	Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
+		Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
+	End Function
+
+	Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
+		Return _System_SendMessage(hwnd, msg, wp, lp)
+	End Function
+
+	Function SendMessage(msg As DWord) As LRESULT
+		Return _System_SendMessage(hwnd, msg, 0, 0)
+	End Function
+
+	Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
+		Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
+	End Function
+
+	Function PostMessage(msg As DWord) As Boolean
+		Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
+	End Function
+
+'その他
+	Const Function Id() As Long
+		Return GetDlgCtrlID(hwnd)
+	End Function
+
+	Sub Id(newId As Long)
+		SetWindowLongPtr(hwnd, GWLP_ID, newId)
+	End Sub
+/*
+	Function DlgItem(idDlgItem As Long) As WindowHandle
+		DlgItem = New WindowHandle(GetDlgItem(hwnd, idDlgItem))
+	End Function
+*/
+	Const Function ExStyle() As DWord
+		Return GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
+	End Function
+
+	Sub ExStyle(newExStyle As DWord)
+		SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle As LONG_PTR)
+	End Sub
+
+	Const Function Style() As DWord
+		Return GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
+	End Function
+
+	Sub Style(newStyle As DWord)
+		SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
+	End Sub
+
+	Const Function Font() As HFONT
+		Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
+	End Function
+
+	Sub Font(hfntNew As HFONT)
+		_System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
+	End Sub
+
+	Const Function Instance() As HINSTANCE
+		Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
+	End Function
+
+	Const Function Parent() As WindowHandle
+		Return New WindowHandle(GetParent(hwnd))
+	End Function
+
+	Sub Parent(hwndNewParent As HWND)
+		SetParent(hwnd, hwndNewParent)
+	End Sub
+
+	Const Function UserData() As LONG_PTR
+		Return GetWindowLongPtr(hwnd, GWLP_USERDATA)
+	End Function
+
+	Sub UserData(newValue As LONG_PTR)
+		SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
+	End Sub
+
 #ifdef _UNDEF
-	Const Function WindowPlacement() As WINDOWPLACEMENT
-		WindowPlacement.length = Len(WindowPlacement)
-		GetWindowPlacement(hwnd, WindowPlacement)
-	End Function
-
-	Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
-		SetWindowPlacement(wndpl)
-	End Sub
-
 	Const Function WndProc() As WNDPROC
-		Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
+		Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
 	End Function
 
 	Sub WndProc(newWndProc As WNDPROC)
-		_System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
+		SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
 	End Sub
 #endif
