Changeset 192 for Include/windows/WindowHandle.sbp
- Timestamp:
- Mar 28, 2007, 10:29:58 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/windows/WindowHandle.sbp
r178 r192 1 #ifndef __WINDOWS HANDLE_SBP__2 #define __WINDOWS HANDLE_SBP__1 #ifndef __WINDOWS_WINDOWHANDLE_SBP__ 2 #define __WINDOWS_WINDOWHANDLE_SBP__ 3 3 4 4 #ifdef _WIN64 5 Declare Function _System_GetWindowLongPtr Lib "user32" Alias "GetWindowLongPtrA"(hWnd As HWND, nIndex As Long) As LONG_PTR6 Declare Function _System_SetWindowLongPtr Lib "user32" Alias "SetWindowLongPtrA"(hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR5 Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR 6 Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR 7 7 #else 8 Declare Function _System_GetWindowLongPtr Lib "user32" Alias "GetWindowLongA"(hWnd As HWND, nIndex As Long) As LONG_PTR9 Declare Function _System_SetWindowLongPtr Lib "user32" Alias "SetWindowLongA"(hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR8 Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLong (hWnd As HWND, nIndex As Long) As LONG_PTR 9 Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR 10 10 #endif 11 11 Declare Function _System_GetParent Lib "user32" Alias "GetParent" (hWnd As HWND) As HWND … … 18 18 Declare Function _System_ValidateRgn Lib "user32" Alias "ValidateRgn" (hWnd As HWND, hRgn As HRGN) As BOOL 19 19 Declare Function _System_BeginPaint Lib "user32" Alias "BeginPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC 20 Declare Function _System_EndPaint Lib "user32" Alias "EndPaint" (hWnd As HWND, ByRef lpPaintAs PAINTSTRUCT) As HDC21 Declare Function _System_ClientToScreen Lib "user32" Alias "ClientToScreen" (hWnd As HWND, ByRef lpPoint As POINTAPI) As BOOL22 Declare Function _System_ScreenToClient Lib "user32" Alias "ScreenToClient" (hWnd As HWND, ByRef lpPoint As POINTAPI) As BOOL20 Declare Function _System_EndPaint Lib "user32" Alias "EndPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC 21 Declare Function _System_ClientToScreen Lib "user32" Alias "ClientToScreen" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL 22 Declare Function _System_ScreenToClient Lib "user32" Alias "ScreenToClient" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL 23 23 Declare Function _System_CreateCaret Lib "user32" Alias "CreateCaret" (hWnd As HWND, hBitmap As HBITMAP, nWidth As Long, nHeight As Long) As BOOL 24 24 Declare Function _System_HideCaret Lib "user32" Alias "HideCaret" (hWnd As HWND) As BOOL … … 28 28 Declare Function _System_IsWindow Lib "user32" Alias "IsWindow" (hWnd As HWND) As BOOL 29 29 Declare Function _System_Isiconic Lib "user32" Alias "Isiconic" (hWnd As HWND) As BOOL 30 Declare Function _System_GetClientRect Lib "user32" Alias "GetClientRect" (hWnd As HWND, ByRef lpRect As RECT) As BOOL30 Declare Function _System_GetClientRect Lib "user32" Alias "GetClientRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL 31 31 32 32 Class WindowHandle … … 41 41 End Sub 42 42 43 Sub WindowHandle( ByRefwnd As WindowHandle)43 Sub WindowHandle(wnd As WindowHandle) 44 44 hwnd = wnd.hwnd 45 45 End Sub … … 117 117 End Function 118 118 119 Const Function GetClassName(className As P STR, maxCount As Long) As Long119 Const Function GetClassName(className As PTSTR, maxCount As Long) As Long 120 120 Return GetClassName(className, maxCount) 121 121 End Function … … 145 145 End Function 146 146 147 Const Function GetDlgItemText(idDlgItem As Long, ps As P STR, maxCount As Long) As Long147 Const Function GetDlgItemText(idDlgItem As Long, ps As PTSTR, maxCount As Long) As Long 148 148 Return GetDlgItemText(hwnd, idDlgItem, ps, maxCount) 149 149 End Function … … 158 158 End Function 159 159 160 Const Function GetProp(psz As PCSTR) As HANDLE 160 Const Function GetProp(str As String) As HANDLE 161 Return GetProp(hwnd, ToTCStr(str)) 162 End Function 163 164 Const Function GetProp(psz As PCTSTR) As HANDLE 161 165 Return GetProp(hwnd, psz) 162 166 End Function 163 167 164 168 Const Function GetProp(atom As ATOM) As HANDLE 165 Return GetProp(hwnd, atom As ULONG_PTR As PC STR)169 Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR) 166 170 End Function 167 171 … … 202 206 End Function 203 207 204 Const Function GetText(ps As P STR, maxCount As Long) As Boolean208 Const Function GetText(ps As PTSTR, maxCount As Long) As Boolean 205 209 Return GetWindowText(ps, maxCount) As Boolean 206 210 End Function … … 215 219 216 220 Const Function GetWindowProcessThreadId(ByRef processId As DWord) As DWord 217 Return GetWindowProcessThreadId(hwnd, processId)221 Return GetWindowProcessThreadId(hwnd, VarPtr(processId)) 218 222 End Function 219 223 … … 294 298 End Function 295 299 296 Const Function MessageBox(text As PC STR, caption As PCSTR, uType As DWord) As Long300 Const Function MessageBox(text As PCTSTR, caption As PCTSTR, uType As DWord) As Long 297 301 Return MessageBox(hwnd, text, caption, uType) 298 302 End Function 299 303 300 Const Function MessageBox(text As PC STR, caption As PCSTR) As Long304 Const Function MessageBox(text As PCTSTR, caption As PCTSTR) As Long 301 305 Return MessageBox(hwnd, text, caption, MB_OK) 302 306 End Function 303 307 304 Const Function MessageBox(text As PC STR) As Long308 Const Function MessageBox(text As PCTSTR) As Long 305 309 Return MessageBox(hwnd, text, 0, MB_OK) 306 310 End Function … … 350 354 End Function 351 355 352 Function RemoveProp(psz As PCSTR) As HANDLE 356 Function RemoveProp(str As String) As HANDLE 357 Return RemoveProp(hwnd, ToTCStr(str)) 358 End Function 359 360 Function RemoveProp(psz As PCTSTR) As HANDLE 353 361 Return RemoveProp(hwnd, psz) 354 362 End Function 355 363 356 364 Function RemoveProp(atom As ATOM) As HANDLE 357 Return RemoveProp(hwnd, atom As ULONG_PTR As PC STR)365 Return RemoveProp(hwnd, atom As ULONG_PTR As PCTSTR) 358 366 End Function 359 367 … … 386 394 End Function 387 395 388 Function SetDlgItemText(idDlgItem As Long, psz As PC STR) As Boolean396 Function SetDlgItemText(idDlgItem As Long, psz As PCTSTR) As Boolean 389 397 Return SetDlgItemText(hwnd, idDlgItem, psz) As Boolean 390 398 End Function … … 414 422 End Function 415 423 416 Function SetProp(psz As PCSTR, hData As HANDLE) As Boolean 424 Function SetProp(str As String, hData As HANDLE) As Boolean 425 Return SetProp(hwnd, ToTCStr(str), hData) As Boolean 426 End Function 427 428 Function SetProp(psz As PCTSTR, hData As HANDLE) As Boolean 417 429 Return SetProp(hwnd, psz, hData) As Boolean 418 430 End Function 419 431 420 432 Function SetProp(atom As ATOM, hData As HANDLE) As Boolean 421 Return SetProp(atom As ULONG_PTR As PC STR, hData) As Boolean433 Return SetProp(atom As ULONG_PTR As PCTSTR, hData) As Boolean 422 434 End Function 423 435 … … 468 480 End Function 469 481 470 Function SetText(psz As PC STR) As Boolean482 Function SetText(psz As PCTSTR) As Boolean 471 483 Return SetWindowText(hwnd, psz) As Boolean 484 End Function 485 486 Function SetText(str As String) As Boolean 487 Return SetWindowText(hwnd, ToTCStr(str)) As Boolean 472 488 End Function 473 489 … … 682 698 End Sub 683 699 700 Const Function Prop(str As String) As HANDLE 701 Return GetProp(str) 702 End Function 703 704 Const Function Prop(psz As PCTSTR) As HANDLE 705 Return GetProp(psz) 706 End Function 707 708 Const Function Prop(atom As ATOM) As HANDLE 709 Return GetProp(atom) 710 End Function 711 712 Sub Prop(str As PCTSTR, h As HANDLE) 713 SetProp(str, h) 714 End Sub 715 716 Sub Prop(psz As PCTSTR, h As HANDLE) 717 SetProp(psz, h) 718 End Sub 719 720 Sub Prop(atom As ATOM, h As HANDLE) 721 SetProp(atom, h) 722 End Sub 723 684 724 Const Function Text() As String 685 With Text 686 .ReSize(GetWindowTextLength(hwnd)) 687 .ReSize(GetWindowText(hwnd, .Chars, .Length + 1)) 688 End With 689 End Function 690 691 Sub Text(newText As PCSTR) 725 Dim size = GetWindowTextLength(hwnd) + 1 726 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 727 Dim length = GetWindowText(hwnd, p, size) 728 Return New String(p, length As SIZE_T) 729 End Function 730 731 Sub Text(newText As String) 732 SetWindowText(hwnd, ToTCStr(newText)) 733 End Sub 734 735 Sub Text(newText As PCTSTR) 692 736 SetWindowText(hwnd, newText) 693 737 End Sub … … 740 784 End Class 741 785 742 #endif '__WINDOWS HANDLE_SBP__786 #endif '__WINDOWS_WINDOWHANDLE_SBP__
Note:
See TracChangeset
for help on using the changeset viewer.