- Timestamp:
- Aug 24, 2007, 11:14:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/ActiveBasic/Windows/WindowHandle.sbp
r302 r303 1 ' Windows/WindowHandle.sbp 2 3 #ifndef __WINDOWS_WINDOWHANDLE_SBP__ 4 #define __WINDOWS_WINDOWHANDLE_SBP__ 1 'Classes/ActiveBasic/Windows/WindowHandle.sbp 5 2 6 3 #ifdef _WIN64 … … 16 13 #endif 17 14 Declare Function _System_GetParent Lib "user32" Alias "GetParent" (hWnd As HWND) As HWND 18 Declare Function _System_SetParent Lib "user32" Alias "SetParent" (hWnd As HWND ) As HWND15 Declare Function _System_SetParent Lib "user32" Alias "SetParent" (hWnd As HWND, hwndParent As HWND) As HWND 19 16 Declare Function _System_GetMenu Lib "user32" Alias "GetMenu" (hWnd As HWND) As HMENU 20 Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND ) As HMENU17 Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As HMENU 21 18 Declare Function _System_InvalidateRect Lib "user32" Alias "InvalidateRect" (hWnd As HWND, ByRef Rect As RECT, bErase As BOOL) As BOOL 22 19 Declare Function _System_InvalidateRgn Lib "user32" Alias "InvalidateRgn" (hWnd As HWND, hRgn As HRGN, bErase As BOOL) As BOOL … … 33 30 Declare Function _System_GetWindowRect Lib "user32" Alias "DrawMenuBar" (hWnd As HWND, ByRef Rect As RECT) As BOOL 34 31 Declare Function _System_IsWindow Lib "user32" Alias "IsWindow" (hWnd As HWND) As BOOL 35 Declare Function _System_Is iconic Lib "user32" Alias "Isiconic" (hWnd As HWND) As BOOL32 Declare Function _System_IsIconic Lib "user32" Alias "IsIconic" (hWnd As HWND) As BOOL 36 33 Declare Function _System_GetClientRect Lib "user32" Alias "GetClientRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL 37 34 Declare Function _System_GetProp Lib "user32" Alias _FuncName_GetProp (hWnd As HWND, pString As PCTSTR) As HANDLE … … 41 38 Declare Function _System_SetScrollInfo Lib "user32" Alias "SetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO, bRedraw As Long) As BOOL 42 39 Declare Function _System_GetSystemMenu Lib "user32" Alias "GetSystemMenu" (hWnd As HWND, bRevert As BOOL) As HMENU 43 Declare Function _System_GetDC Lib "gdi32" Alias "GetDC" (hwnd As HWND) As HDC 44 Declare Function _System_ReleaseDC Lib "gdi32" Alias "ReleaseDC" (hwnd As HWND, hdc As HDC) As BOOL 40 Declare Function _System_GetDC Lib "user32" Alias "GetDC" (hwnd As HWND) As HDC 41 Declare Function _System_GetDCEx Lib "user32" Alias "GetDCEx" (hwnd As HWND, hrgnClip As HRGN, flags As DWord) As HDC 42 Declare Function _System_GetWindowDC Lib "user32" Alias "GetWindowDC" (hwnd As HWND) As HDC 43 Declare Function _System_ReleaseDC Lib "user32" Alias "ReleaseDC" (hwnd As HWND, hdc As HDC) As BOOL 44 Declare Function _System_SendMessage Lib "user32" Alias _FuncName_SendMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 45 Declare Function _System_PostMessage Lib "user32" Alias _FuncName_PostMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 46 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 47 Declare Function _System_GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (hwnd As HWND, pdwProcessId As *DWord) As DWord 48 49 Namespace ActiveBasic 50 Namespace Windows 45 51 46 52 Class WindowHandle … … 55 61 End Sub 56 62 57 Sub WindowHandle(wnd As WindowHandle)58 hwnd = wnd.hwnd59 End Sub60 61 Sub Operator =(hwndNew As HWND)62 hwnd = hwndNew63 End Sub64 65 63 Const Function HWnd() As HWND 66 64 Return hwnd … … 78 76 Return _System_BeginPaint(hwnd, ps) 79 77 End Function 80 78 /* 81 79 Const Function ChildFromPoint(x As Long, y As Long) As WindowHandle 82 80 Return New WindowHandle(ChildWindowFromPoint(hwnd, x, y)) … … 86 84 Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags)) 87 85 End Function 88 86 */ 89 87 Const Function ClientToScreen(ByRef pt As POINTAPI) As Boolean 90 88 Return _System_ClientToScreen(hwnd, pt) As Boolean … … 101 99 102 100 Function CreateCaret(hbmp As HBITMAP, width As Long, height As Long) As Boolean 103 Return _System_CreateCaret(hwnd, hbmp, width, he giht) As Boolean101 Return _System_CreateCaret(hwnd, hbmp, width, height) As Boolean 104 102 End Function 105 103 … … 111 109 Return _System_DrawMenuBar(hwnd) As Boolean 112 110 End Function 113 111 /* 114 112 Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean 115 113 Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean 116 114 End Function 117 115 */ 118 116 Function Enable(enable As Boolean) As Boolean 119 117 Return EnableWindow(hwnd, enable) As Boolean … … 137 135 138 136 Const Function GetClassName(className As PTSTR, maxCount As Long) As Long 139 Return _System_GetClassName( className, maxCount)137 Return _System_GetClassName(hwnd, className, maxCount) 140 138 End Function 141 139 … … 143 141 Return _System_GetClientRect(hwnd, rc) As Boolean 144 142 End Function 145 143 /* 146 144 Const Function GetContextHelpId() As DWord 147 145 Return GetWindowContextHelpId(hwnd) 148 146 End Function 149 147 */ 150 148 Function GetDC() As HDC 151 149 Return _System_GetDC(hwnd) … … 153 151 154 152 Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC 155 Return GetDCEx(hwnd, hrgnClip, flags)156 End Function 157 153 Return _System_GetDCEx(hwnd, hrgnClip, flags) 154 End Function 155 /* 158 156 Const Function GetDlgCtrlID() As Long 159 157 Return GetDlgCtrlID(hwnd) … … 167 165 Return GetDlgItemText(hwnd, idDlgItem, ps, maxCount) 168 166 End Function 169 167 */ 170 168 Const Function GetMenu() As HMENU 171 169 Return _System_GetMenu(hwnd) 172 170 End Function 173 171 /* 174 172 Const Function GetParent() As WindowHandle 175 173 Return New WindowHandle(_System_GetParent(hwnd)) 176 174 End Function 177 175 */ 178 176 Const Function GetProp(str As String) As HANDLE 179 177 Return _System_GetProp(hwnd, ToTCStr(str)) … … 191 189 Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean 192 190 End Function 193 191 /* 194 192 Const Function GetSystemMenu(revert As Boolean) As HMENU 195 193 Return GetSystemMenu(hwnd, revert) … … 207 205 Return GetWindow(hwnd, cmd) 208 206 End Function 209 207 */ 210 208 Function GetWindowDC() As HDC 211 Return GetWindowDC(hwnd)209 Return _System_GetWindowDC(hwnd) 212 210 End Function 213 211 … … 215 213 Return _System_GetWindowLongPtr(hwnd, index) 216 214 End Function 217 215 /* 218 216 Const Function GetWindowPlasement(ByRef wndpl As WINDOWPLACEMENT) As Boolean 219 217 Return GetWindowPlasement(hwnd, wndpl) As Boolean 220 218 End Function 221 219 */ 222 220 Const Function GetWindowRect(ByRef rc As RECT) As Boolean 223 Return _System_GetWindowRect( rc) As Boolean221 Return _System_GetWindowRect(hwnd, rc) As Boolean 224 222 End Function 225 223 226 224 Const Function GetText(ps As PTSTR, maxCount As Long) As Boolean 227 Return GetWindowText( ps, maxCount) As Boolean225 Return GetWindowText(hwnd, ps, maxCount) As Boolean 228 226 End Function 229 227 … … 233 231 234 232 Const Function GetWindowThreadId() As DWord 235 Return GetWindowProcessThreadId(hwnd, 0)236 End Function 237 238 Const Function GetWindow ProcessThreadId(ByRef processId As DWord) As DWord239 Return GetWindowProcessThreadId(hwnd, VarPtr(processId))233 Return _System_GetWindowThreadProcessId(hwnd, 0) 234 End Function 235 236 Const Function GetWindowThreadProcessId(ByRef processId As DWord) As DWord 237 Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId)) 240 238 End Function 241 239 … … 267 265 Return _System_InvalidateRect(hwnd, ByVal 0, TRUE) As Boolean 268 266 End Function 269 267 /* 270 268 Const Function IsChild(hwnd As HWND) As Boolean 271 269 Return IsChild(This.hwnd, hwnd) As Boolean … … 275 273 Return IsDialogMessage(hwnd, msg) As Boolean 276 274 End Function 277 275 */ 278 276 Const Function IsIconic() As Boolean 279 277 Return _System_IsIconic(hwnd) As Boolean … … 295 293 Return IsWindowVisible(hwnd) As Boolean 296 294 End Function 297 295 /* 298 296 Const Function IsZoomed() As Boolean 299 297 Return IsZoomed(hwnd) As Boolean … … 303 301 Return KillTimer(idEvent) As Boolean 304 302 End Function 305 303 */ 306 304 Function LockUpdate() As Boolean 307 305 Return LockWindowUpdate(hwnd) As Boolean 308 306 End Function 309 307 /* 310 308 Function MapPoints(hwndTo As HWND, pPoints As *POINTAPI, cPoints As DWord) As Long 311 309 Return MapWindowPoints(hwnd, hwndTo, pPoints, cPoints) … … 327 325 Return MessageBox(hwnd, text, 0, MB_OK) 328 326 End Function 329 327 */ 330 328 Function Move(x As Long, y As Long, width As Long, height As Long, repaint As Boolean) As Boolean 331 329 Return MoveWindow(hwnd, x, y, width, height, repaint) As Boolean … … 336 334 End Function 337 335 338 Function Move(ByRef rc As RECT, rep eaint As Boolean) As Boolean336 Function Move(ByRef rc As RECT, repaint As Boolean) As Boolean 339 337 With rc 340 338 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, repaint) As Boolean … … 347 345 End With 348 346 End Function 349 347 /* 350 348 Function OpenClipboard() As Boolean 351 349 Return OpenClipboard(hwnd) As Boolean … … 355 353 Return OpenIcon(hwnd) As Boolean 356 354 End Function 357 355 */ 358 356 Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean 359 Return PostMessage(hwnd, msg, wp, lp) As Boolean357 Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean 360 358 End Function 361 359 362 360 Function PostMessage(msg As DWord) As Boolean 363 Return PostMessage(hwnd, msg, 0, 0) As Boolean364 End Function 365 361 Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean 362 End Function 363 /* 366 364 Function RedrawWindow(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord) As Boolean 367 365 Return RedrawWindow(hwnd, rcUpdatre, hrgnUpdate, flags) As Boolean 368 366 End Function 369 367 */ 370 368 Function ReleaseDC(hdc As HDC) As Boolean 371 369 Return _System_ReleaseDC(hwnd, hdc) As Boolean 372 370 End Function 373 371 /* 374 372 Function RemoveProp(str As String) As HANDLE 375 373 Return RemoveProp(hwnd, ToTCStr(str)) … … 383 381 Return RemoveProp(hwnd, atom As ULONG_PTR As PCTSTR) 384 382 End Function 385 383 */ 386 384 Const Function ScreenToClient(ByRef pt As POINTAPI) As Boolean 387 385 Return _System_ScreenToClient(hwnd, pt) As Boolean … … 398 396 399 397 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 400 Return SendDlgItemMessage(hwnd, idDlgItem, wp, lp)398 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp) 401 399 End Function 402 400 403 401 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT 404 Return SendDlgItemMessage(hwnd, idDlgItem, 0, 0)402 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0) 405 403 End Function 406 404 407 405 Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 408 Return SendMessage(hwnd, msg, wp, lp)406 Return _System_SendMessage(hwnd, msg, wp, lp) 409 407 End Function 410 408 411 409 Function SendMessage(msg As DWord) As LRESULT 412 Return SendMessage(hwnd, msg, 0, 0)413 End Function 414 410 Return _System_SendMessage(hwnd, msg, 0, 0) 411 End Function 412 /* 415 413 Function SetActiveWindow() As WindowHandle 416 414 Return New WindowHandle(SetActiveWindow(hwnd)) … … 424 422 Return New WindowHandle(SetCapture(hwnd)) 425 423 End Function 426 424 */ 427 425 Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR 428 426 Return _System_SetClassLongPtr(hwnd, index, newLong) 429 427 End Function 430 428 /* 431 429 Function SetFocus() As WindowHandle 432 430 Return New WindowHandle(SetFocus(hwnd)) 433 431 End Function 434 432 */ 435 433 Function SetForeground() As Boolean 436 434 Return SetForegroundWindow(hwnd) As Boolean … … 454 452 455 453 Function SetProp(atom As ATOM, hData As HANDLE) As Boolean 456 Return SetProp((atom As ULONG_PTR) As PCTSTR, hData) As Boolean454 Return This.SetProp((atom As ULONG_PTR) As PCTSTR, hData) As Boolean 457 455 End Function 458 456 … … 464 462 Return _System_SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean 465 463 End Function 466 464 /* 467 465 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR 468 466 Return SetTmer(hwnd, idEvent, elapse, timerFunc) … … 470 468 471 469 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR 472 Return SetTmer(hwnd, idEvent, elapse, 0)470 Return This.SetTmer(hwnd, idEvent, elapse, 0) 473 471 End Function 474 472 … … 476 474 Return SetContextHelpId(hwnd, contextHelpId) As Boolean 477 475 End Function 478 476 */ 479 477 Function SetWindowLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR 480 478 Return _System_SetWindowLongPtr(hwnd, index, newLong) 481 479 End Function 482 480 /* 483 481 Function SetWindowPlacement(ByRef wndpl As WINDOWPLACEMENT) As Boolean 484 482 Return SetWindowPlacement(hwnd, wndpl) As Boolean 485 483 End Function 486 484 */ 487 485 Function SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord) As Boolean 488 486 Return SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags) As Boolean … … 514 512 Return _System_ShowCaret(hwnd) As Boolean 515 513 End Function 516 514 /* 517 515 Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean 518 516 Return ShowScrollBar(hwnd, bar, show) As Boolean … … 522 520 Return ShowScrollBar(hwnd, bar, TRUE) As Boolean 523 521 End Function 524 522 */ 525 523 Function Show(cmdShow As DWord) As Boolean 526 524 Return ShowWindow(hwnd, cmdShow) As Boolean … … 556 554 Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord 557 555 End Function 558 556 #ifdef _UNDEF 559 557 Const Function GetWndProc() As WNDPROC 560 Return _System_GetWindowLongPtr(hwnd, GWLP_ HINSTANCE) As WNDPROC561 End Function 562 558 Return _System_GetWindowLongPtr(hwnd, GWLP_WNDPROC) As WNDPROC 559 End Function 560 #endif 563 561 Const Function GetInstance() As HINSTANCE 564 562 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE … … 576 574 Return _System_SetWindowLongPtr(hwnd, GWL_STYLE, style) As DWord 577 575 End Function 578 576 #ifdef _UNDEF 579 577 Function SetWndProc(wndProc As WNDPROC) As WNDPROC 580 Return _System_SetWindowLongPt R(hwnd, GWLP_WNDPROC, wndProc As WNDPROC) As WNDPROC581 End Function 582 578 Return _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, wndProc As WNDPROC) As WNDPROC 579 End Function 580 #endif 583 581 Function SetUserData(value As LONG_PTR) As LONG_PTR 584 Return _System_SetWindowLongPtr( value As LONG_PTR)582 Return _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, value As LONG_PTR) 585 583 End Function 586 584 … … 592 590 Return rc 593 591 End Function 594 592 #ifdef _UNDEF 595 593 Sub ClientRect(ByRef rc As RECT) 596 594 Dim hasMenu As BOOL 597 If IsChild() = False And IsMenu() <> FalseThen595 If IsChild() = False And GetMenu() <> 0 Then 598 596 hasMenu = TRUE 599 597 Else … … 601 599 End If 602 600 AdjustWindowRectEx(rc, GetStyle(), hasMenu, GetExStyle()) 603 MoveWindow(rc) ' WindowRect = rc604 End Sub 605 601 This.Move(rc) ' WindowRect = rc 602 End Sub 603 #endif 606 604 Const Function WindowRect() As RECT 607 605 Dim rc As RECT … … 611 609 612 610 Sub WindowRect(ByRef rc As RECT) 613 MoveWindow(rc)614 End Sub 615 611 This.Move(rc) 612 End Sub 613 #ifdef _UNDEF 616 614 Const Function ContextHelpID() As DWord 617 615 Return GetContextHelpId(hwnd) … … 634 632 Return w 635 633 End Function 636 634 #endif 637 635 Const Function ExStyle() As DWord 638 636 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord … … 640 638 641 639 Sub ExStyle(newExStyle As DWord) 642 _System_SetWindowLongPtr(hwnd, GWL P_EXSTYLE, newExStyle)640 _System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle) 643 641 End Sub 644 642 … … 648 646 649 647 Sub Style(newStyle As DWord) 650 _System_SetWindowLongPtr(hwnd, GWL P_STYLE, newStyle)648 _System_SetWindowLongPtr(hwnd, GWL_STYLE, newStyle) 651 649 End Sub 652 650 … … 660 658 661 659 Const Function Font() As HFONT 662 Return SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT660 Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT 663 661 End Function 664 662 665 663 Sub Font(hfntNew As HFONT) 666 SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)664 _System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE) 667 665 End Sub 668 666 … … 680 678 681 679 Const Function Minimized() As Boolean 682 Return IsIconic(hwnd) As Boolean680 Return _System_IsIconic(hwnd) As Boolean 683 681 End Function 684 682 … … 705 703 End Sub 706 704 707 Const Function ProcessI D() As DWord708 GetWindow ProcessThreadId(ProcessID)709 End Function 710 711 Const Function ThreadI D() As DWord712 Return GetWindow ProcessThreadId(ByVal 0)705 Const Function ProcessId() As DWord 706 GetWindowThreadProcessId(ProcessId) 707 End Function 708 709 Const Function ThreadId() As DWord 710 Return GetWindowThreadProcessId(ByVal 0) 713 711 End Function 714 712 … … 759 757 Return GetWindowTextLength(hwnd) 760 758 End Function 761 759 #ifdef _UNDEF 762 760 Const Function UserData() As LONG_PTR 763 761 Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA) … … 767 765 _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue) 768 766 End Sub 769 767 #endif 770 768 Const Function Visible() As Boolean 771 Return Is Visible(hwnd) As Boolean769 Return IsWindowVisible(hwnd) As Boolean 772 770 End Function 773 771 … … 779 777 EndIf 780 778 End Sub 781 779 #ifdef _UNDEF 782 780 Const Function WindowPlacement() As WINDOWPLACEMENT 783 781 WindowPlacement.length = Len(WindowPlacement) … … 796 794 _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR) 797 795 End Sub 798 796 #endif 799 797 Protected 800 798 Sub SetHWnd(hwndNew As HWND) … … 803 801 End Class 804 802 805 #endif '__WINDOWS_WINDOWHANDLE_SBP__ 803 End Namespace 'Widnows 804 End Namespace 'ActiveBasic
Note:
See TracChangeset
for help on using the changeset viewer.