| |
|
|
| Button:
Andreas Miethe (21.09.11)
This will usually over The Message WM_NCHITTEST geregelt. here time one small example for a skalier / verschiebbaren Button. ought to itself well for a Window adjust let. CompileMarkSeparation $H Windows.ph
$H Messages.ph
$H Structs.ph
STRUCT TRect = ~Rect
STRUCT TPoint = ~Point
Proc HitTest
Parameters hCtl&,lParam&
Declare Point#
Declare Rect#
Dim Point#,TPoint
Dim Rect#,TRect
Point#.x& = LoWord(lParam&)
Point#.y& = HiWord(lParam&)
~ScreenToClient(hCtl&,Point#)
~GetWindowRect(hCtl&,Rect#)
~MapWindowPoints(~GetDesktopWindow(),%Hwnd,Rect#,2)
If (Point#.y& < 4) AND (Point#.x& < 4)
Dispose Point#,Rect#
Return ~HTTOPLEFT
ElseIf (Point#.y& < 4) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Return ~HTTOPRIGHT
ElseIf (Point#.y& >= (Rect#.bottom& - Rect#.top&-4)) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Return ~HTBOTTOMRIGHT
ElseIf (Point#.x& < 4) AND (Point#.y& >= (Rect#.bottom& - Rect#.top& - 4))
Dispose Point#,Rect#
Return ~HTBOTTOMLEFT
ElseIf Point#.y& < 4
Dispose Point#,Rect#
Return ~HTTOP
ElseIf Point#.x& < 4
Dispose Point#,Rect#
Return ~HTLEFT
ElseIf Point#.x& >= (Rect#.right& - Rect#.left& - 4)
Dispose Point#,Rect#
Return ~HTRIGHT
ElseIf Point#.y& >= (Rect#.bottom& - Rect#.top& - 4)
Dispose Point#,Rect#
Return ~HTBOTTOM
Else
Dispose Point#,Rect#
Return ~HTCAPTION
EndIf
EndProc
SubClassProc
If SubClassMessage(&sWnd,~WM_NCHITTEST)
Set("WinProc", 0)
Return HitTest(&swnd,&slParam)
Endif
EndProc
cls
Var Ende& = 0
Var Button& = Create("Button",%hwnd,"OK",10,10,120,30)
SubClass Button&,1
whilenot ende&
wait /a>
endwhile
Window:
Julian57 (22.09.11)
The View source with wm_ncHitTest functions really super! thanks Andreas CompileMarkSeparation $H windows.ph
$H Messages.ph
$H Structs.ph
STRUCT TRect = ~Rect
STRUCT TPoint = ~Point
Proc HitTest
Parameters hCtl&,lParam&
Declare Point#
Declare Rect#
Dim Point#,TPoint
Dim Rect#,TRect
Point#.x& = LoWord(lParam&)
Point#.y& = HiWord(lParam&)
~ScreenToClient(hCtl&,Point#)
~GetWindowRect(hCtl&,Rect#)
~MapWindowPoints(~GetDesktopWindow(),%Hwnd,Rect#,2)
If (Point#.y& < 4) AND (Point#.x& < 4)
Dispose Point#,Rect#
Return ~HTTOPLEFT
ElseIf (Point#.y& < 4) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Return ~HTTOPRIGHT
ElseIf (Point#.y& >= (Rect#.bottom& - Rect#.top&-4)) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Return ~HTBOTTOMRIGHT
ElseIf (Point#.x& < 4) AND (Point#.y& >= (Rect#.bottom& - Rect#.top& - 4))
Dispose Point#,Rect#
Return ~HTBOTTOMLEFT
ElseIf Point#.y& < 4
Dispose Point#,Rect#
Return ~HTTOP
ElseIf Point#.x& < 4
Dispose Point#,Rect#
Return ~HTLEFT
ElseIf Point#.x& >= (Rect#.right& - Rect#.left& - 4)
Dispose Point#,Rect#
Return ~HTRIGHT
ElseIf Point#.y& >= (Rect#.bottom& - Rect#.top& - 4)
Dispose Point#,Rect#
Return ~HTBOTTOM
Else
Dispose Point#,Rect#
Return ~HTCAPTION
EndIf
ENDPROC
SubClassProc
If SubClassMessage(&sWnd,~WM_NCHITTEST)
Set("WinProc", 0)
Return HitTest(&swnd,&slParam)
Endif
ENDPROC
windowstyle 2+16+64
window 600,400
cls 255
var dg&=Create("Window",%hwnd,"",10,10,200,100)
StartPaint dg&
cls 255
EndPaint
SubClass dg&,1
SubClass %hwnd,1
while 1
waitinput 30
case iskey(27) : end
endwhile
|
|
|
| |
|
|