Source / code snippets | | | | Julian Schmidt | many functions around Mouse and Window.
Def SetCursorPos(2)!"User32","SetCursorPos"
Windowstyle 10
Window Title "Beispiel for GetwindowRect, GetCursorPos, ScreenToClient, WindowfromPoint and your 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 to demonstration one Hoverbuttons with 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)
User Messages 16
WhileNot (%umessage=16) or iskey(27)
Waitinput 30
Sendmessage(picbt&,$F7 | 247,0,If(HandleHover()=picbt&,pic1&,pic2&))'Hover-Button with HandleHover(), alternatively The usage of IsMouseHover()
Settext text&,IF(IsMouseInDg(%hwnd, 0, 0, width(%hwnd)/2, height(%hwnd))=1,"Maus on linker Page ",IF(IsMouseInDg(%hwnd, width(%hwnd)/2, 0, width(%hwnd), height(%hwnd))=1,"Maus on right Page ","Maus outside the Client_Bereichs of hWnd"))
Settext pos&, "Position of %hwnd (global): "+Str $(WindowRect(%hwnd,"X1"))+"x"+Str $(WindowRect(%hwnd,"Y1"))
Settext Dlg&, "Maus over the lever '"+Str $(HandleHover())+"' with the cover '"+Mid$(Gettext$(HandleHover()),1,45)+"...'"
Settext %hwnd, "CursorPosGlobal: "+Str $(CursorPos("X1"))+"x"+Str $(CursorPos("Y1"))+" - CursorPosLokal on 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&, mode%
'mode = 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"); mode%
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 mode$
mode$=Lower$(mode$)
Declare x%, mpos#
Dim mpos#,8
External("user32","GetCursorPos",mpos#)
Case @&(2)<>0 : External("USER32","ScreenToClient",@&(2),mpos#)
Case mode$="x1" : x%=long(mpos#,0)
Case mode$="y1" : x%=long(mpos#,4)
Case mode$="x2" : x%=IF(@&(2)<>0,WindowRect(@&(2),"Breite"),%maxx)-long(mpos#,0)
Case mode$="y2" : x%=IF(@&(2)<>02,WindowRect(@&(2),"Höhe"),%maxy)-long(mpos#,4)
Dispose mpos#
Return x%
ENDPROC
Proc WindowRect
Parameters hdl&,mode$
mode$=Lower$(mode$)
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 mode$="breite" : x%=Long(b #,8)-Long(b #,0)
Case mode$="höhe" : x%=Long(b #,12)-Long(b #,4)
Case mode$="x1" : x%=Long(b #,0)
Case mode$="y1" : x%=Long(b #,4)
Case mode$="x2" : x%=Long(b #,8)
Case mode$="y2" : x%=Long(b #,12)
Dispose b#
Return x%
ENDPROC
Proc Workarea
Parameters mode$
mode$=lower$(mode$)
Declare Rect#,x%
Dim Rect#,16
External("User32","SystemParametersInfoA",48,0,Rect#,0)
case mode$="x1" : x%=Long(Rect#,0)
case mode$="y1" : x%=Long(Rect#,4)
case mode$="x2" : x%=Long(Rect#,8)
case mode$="y2" : x%=Long(Rect#,12)
Dispose Rect#
Return x%
ENDPROC
Nachtrag of iF:
Martin Kempf (21.01.2016)
thanks, super thing, functions. Info yet: I work with 2 Bildschirmen: The Proc HandleHover produced a crash, if The mouse from the a to that others screen jumping.
|
| | | | |
| | | i'd of it dissuade Own functions with API-Funktionsnamen To occupy -
so there GetCursorPos ( [...] ) already and if one z.B. XPSE uses then can simply APIs write without To deklarieren and who likes already dahingehende Kollisionen. |
| | | | |
| | E.T. | | | | Grüße aus Sachsen... Mario WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte... | 02/07/12 ▲ |
| |
| | | These control isn't necessary there one with ~ explizit on API-functions verweisen can, so goes so To discern:
and XPSE can so thoroughly make possible API-gleichnamige Own functions To deklarieren.
my council related hold sooner hereon a Own setPixel-function the better distinction because of sooner z.B. mySetPixel To name |
| | | | |
| | Julian Schmidt | | | | | |
| | | Martin Kempf (21.01.2016)
thanks, super thing, functions. Info yet: I work with 2 Bildschirmen: The Proc HandleHover produced a crash, if The mouse from the a to that others screen jumping.
|
| | | | |
|
Zum QuelltextTopic-Options | 14.371 Views |
Themeninformationenthis Topic has 3 subscriber: |