IsMouseIn, IsMouseInDlg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Def SetCursorPos(2)!"User32","SetCursorPos"
Windowstyle 10
WindowTitle "Beispiel für GetwindowRect, GetCursorPos, ScreenToClient, WindowfromPoint und ihre Anwendung"
CLS
WindowZ(%hwnd,-1)
Var pic1&=Create("hNewPic", 100, 100, RGB(0,0,255))
Var pic2&=Create("hNewPic", 100, 100, RGB(255,0,0))
Var picbt&=Create("PicButton",%hwnd,0,(width(%hwnd)-100)/2,(height(%hwnd)-100)/2,100,100)
Settext picbt&,"Bildbutton zur Demonstration eines Hoverbuttons mit HandleHover"
Var text&=Create("Text",%hwnd,"",0,0,width(%hwnd),16)
Var pos&=Create("Text",%hwnd,"",0,height(%hwnd)-16,width(%hwnd),16)
Var Dlg&=Create("Text",%hwnd,"",0,16,width(%hwnd),16)
Line width(%hwnd)/2,0 - width(%hwnd)/2,height(%hwnd)
Usermessages 16
WhileNot (%umessage=16) or iskey(27)
Waitinput 30
Sendmessage(picbt&,$F7 | 247,0,If(HandleHover()=picbt&,pic1&,pic2&))'Hover-Button mit HandleHover(), Alternativ die Verwendung von IsMouseHover()
Settext text&,IF(IsMouseInDg(%hwnd, 0, 0, width(%hwnd)/2, height(%hwnd))=1,"Maus auf linker Seite",IF(IsMouseInDg(%hwnd, width(%hwnd)/2, 0, width(%hwnd), height(%hwnd))=1,"Maus auf rechter Seite","Maus außerhalb des Client_Bereichs von hWnd"))
Settext pos&, "Position von %hwnd (global): "+Str$(WindowRect(%hwnd,"X1"))+"x"+Str$(WindowRect(%hwnd,"Y1"))
Settext Dlg&, "Maus über den Handle '"+Str$(HandleHover())+"' mit dem Titel '"+Mid$(Gettext$(HandleHover()),1,45)+"...'"
Settext %hwnd, "CursorPosGlobal: "+Str$(CursorPos("X1"))+"x"+Str$(CursorPos("Y1"))+" - CursorPosLokal auf hWnd: "+Str$(CursorPos("X1",%hwnd))+"x"+Str$(CursorPos("Y1",%hwnd))
EndWhile
deleteobject pic1&
deleteobject pic2&
end
Proc IsMouseHover
Parameters hdl&
Return Between(CursorPos("X1"), WindowRect(hdl&,"X1"), WindowRect(hdl&,"X2"), CursorPos("Y1"), WindowRect(hdl&,"Y1"), WindowRect(hdl&,"Y2"))
EndProc
Proc IsMouseIn
Parameters x1%,y1%,x2%,y2%
Return Between(CursorPos("X1"), x1%, x2%, CursorPos("Y1"), y1%, y2%)
EndProc
Proc IsMouseInDg
Parameters hdl&,x1%,y1%,x2%,y2%
Return Between(CursorPos("X1",hdl&), x1%, x2%, CursorPos("Y1",hdl&), y1%, y2%)
EndProc
Proc WindowSize
Parameters hdl&,x%,y%
SetWindowPos hdl& = WindowRect(hdl&,"X1"),WindowRect(hdl&,"Y1") - x%,y%
EndProc
Proc WindowZ
Parameters hdl&, modus%
'Modus = 0 : TOP| 1 : BOTTOM | -1 : TOP-MOST | -2 : BOTTOM-MOST
SetWindowPos hdl& = WindowRect(hdl&,"X1"),WindowRect(hdl&,"Y1") - WindowRect(hdl&,"Breite"),WindowRect(hdl&,"Höhe"); modus%
EndProc
Proc HandleHover
Declare mpos#
Dim mpos#,8
External("user32","GetCursorPos",mpos#)
Var hdl&=External("USER32","WindowFromPoint",long(mpos#,0),long(mpos#,4))
Dispose mpos#
Return hdl&
EndProc
Proc HandleHoverPos
Parameters x&,y&
Return External("USER32","WindowFromPoint",x&,y&)
EndProc
Proc CursorPos
Parameters Modus$
Modus$=Lower$(Modus$)
Declare x%, mpos#
Dim mpos#,8
External("user32","GetCursorPos",mpos#)
Case @&(2)<>0 : External("USER32","ScreenToClient",@&(2),mpos#)
Case Modus$="x1" : x%=long(mpos#,0)
Case Modus$="y1" : x%=long(mpos#,4)
Case Modus$="x2" : x%=IF(@&(2)<>0,WindowRect(@&(2),"Breite"),%maxx)-long(mpos#,0)
Case Modus$="y2" : x%=IF(@&(2)<>02,WindowRect(@&(2),"Höhe"),%maxy)-long(mpos#,4)
Dispose mpos#
Return x%
EndProc
Proc WindowRect
Parameters hdl&,Modus$
Modus$=Lower$(Modus$)
Declare x%, b#
Dim b#,16
External("USER32", "GetWindowRect",hdl&,b#)
Case @&(3)<>0 : External("USER32","ScreenToClient",@&(3),b#) : External("USER32","ScreenToClient",@&(3),b#+8)
Case Modus$="breite" : x%=Long(b#,8)-Long(b#,0)
Case Modus$="höhe" : x%=Long(b#,12)-Long(b#,4)
Case Modus$="x1" : x%=Long(b#,0)
Case Modus$="y1" : x%=Long(b#,4)
Case Modus$="x2" : x%=Long(b#,8)
Case Modus$="y2" : x%=Long(b#,12)
Dispose b#
Return x%
EndProc
Proc Workarea
Parameters Modus$
modus$=lower$(modus$)
Declare Rect#,x%
Dim Rect#,16
External("User32","SystemParametersInfoA",48,0,Rect#,0)
case modus$="x1" : x%=Long(Rect#,0)
case modus$="y1" : x%=Long(Rect#,4)
case modus$="x2" : x%=Long(Rect#,8)
case modus$="y2" : x%=Long(Rect#,12)
Dispose Rect#
Return x%
EndProc