| |
|
|
| Button:
Andreas Miethe (21.09.11)
cela wird normalement sur qui Message WM_NCHITTEST geregelt. ici la fois un kleines Beispiel pour une skalier / verschiebbaren Button. Sollte sich wohl pour un la fenêtre anpassen laisser. KompilierenMarqueSéparation $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
la fenêtre:
Julian57 (22.09.11)
qui Voir le texte source avec wm_ncHitTest funktioniert wirklich super! merci Andreas KompilierenMarqueSéparation $H Windows.ph
$H Messages.ph
$H Structs.ph
STRUCT TRect = ~Rect
STRUCT TPoint = ~Point
Proc HitTest
Paramètres hCtl&,lParam&
Déclarer Point#
Déclarer Rect#
Faible Point#,TPoint
Faible Rect#,TRect
Point#.x& = LoWord(lParam&)
Point#.y& = HiWord(lParam&)
~ScreenToClient(hCtl&,Point#)
~GetWindowRect(hCtl&,Rect#)
~MapWindowPoints(~GetDesktopWindow(),%Hwnd,Rect#,2)
Si (Point#.y& < 4) AND (Point#.x& < 4)
Dispose Point#,Rect#
Retour ~HTTOPLEFT
ElseIf (Point#.y& < 4) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Retour ~HTTOPRIGHT
ElseIf (Point#.y& >= (Rect#.bottom& - Rect#.top&-4)) AND (Point#.x& >= (Rect#.right& - Rect#.left&-4))
Dispose Point#,Rect#
Retour ~HTBOTTOMRIGHT
ElseIf (Point#.x& < 4) AND (Point#.y& >= (Rect#.bottom& - Rect#.top& - 4))
Dispose Point#,Rect#
Retour ~HTBOTTOMLEFT
ElseIf Point#.y& < 4
Dispose Point#,Rect#
Retour ~HTTOP
ElseIf Point#.x& < 4
Dispose Point#,Rect#
Retour ~HTLEFT
ElseIf Point#.x& >= (Rect#.right& - Rect#.left& - 4)
Dispose Point#,Rect#
Retour ~HTRIGHT
ElseIf Point#.y& >= (Rect#.bottom& - Rect#.top& - 4)
Dispose Point#,Rect#
Retour ~HTBOTTOM
D'autre
Dispose Point#,Rect#
Retour ~HTCAPTION
EndIf
ENDPROC
SubClassProc
Si SubClassMessage(&sWnd,~WM_NCHITTEST)
Set("WinProc", 0)
Retour HitTest(&swnd,&slParam)
Endif
ENDPROC
style de fenêtre 2+16+64
window 600,400
cls 255
var dg&=Créer("Window",%hwnd,»,10,10,200,100)
Début de peinture dg&
cls 255
EndPaint
SubClass dg&,1
SubClass %hwnd,1
tandis que 1
waitinput 30
cas iskey(27) : end
endwhile
|
|
|
| |
|
|