| |
|
|
| Button:
Andreas Miethe (21.09.11)
Das se normalerweise en Message WM_NCHITTEST geregelt. Hier veces una kleines Ejemplo para una skalier / verschiebbaren Button. Sollte se wohl para una Ventana adaptar dejar. KompilierenMarcaSeparación $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
Ventana:
Julian57 (22.09.11)
Der Ver código fuente con wm_ncHitTest funktioniert wirklich super! Gracias Andreas KompilierenMarcaSeparación $H Windows.ph
$H Messages.ph
$H Structs.ph
STRUCT TRect = ~Rect
STRUCT TPoint = ~Punto
Proc HitTest
Parámetros hCtl&,lParam&
Declarar Punto#
Declarar Rect#
Dim Punto#,TPoint
Dim Rect#,TRect
Punto#.x& = LoWord(lParam&)
Punto#.y& = HiWord(lParam&)
~ScreenToClient(hCtl&,Punto#)
~GetWindowRect(hCtl&,Rect#)
~MapWindowPoints(~GetDesktopWindow(),%Hwnd,Rect#,2)
If (Punto#.y& < 4) AND (Punto#.x& < 4)
Disponer Punto#,Rect#
Volver ~HTTOPLEFT
ElseIf (Punto#.y& < 4) AND (Punto#.x& >= (Rect#.right& - Rect#.left&-4))
Disponer Punto#,Rect#
Volver ~HTTOPRIGHT
ElseIf (Punto#.y& >= (Rect#.bottom& - Rect#.top&-4)) AND (Punto#.x& >= (Rect#.right& - Rect#.left&-4))
Disponer Punto#,Rect#
Volver ~HTBOTTOMRIGHT
ElseIf (Punto#.x& < 4) AND (Punto#.y& >= (Rect#.bottom& - Rect#.top& - 4))
Disponer Punto#,Rect#
Volver ~HTBOTTOMLEFT
ElseIf Punto#.y& < 4
Disponer Punto#,Rect#
Volver ~HTTOP
ElseIf Punto#.x& < 4
Disponer Punto#,Rect#
Volver ~HTLEFT
ElseIf Punto#.x& >= (Rect#.right& - Rect#.left& - 4)
Disponer Punto#,Rect#
Volver ~HTRIGHT
ElseIf Punto#.y& >= (Rect#.bottom& - Rect#.top& - 4)
Disponer Punto#,Rect#
Volver ~HTBOTTOM
Más
Disponer Punto#,Rect#
Volver ~HTCAPTION
EndIf
ENDPROC
SubClassProc
If SubClassMessage(&sWnd,~WM_NCHITTEST)
Conjunto("WinProc", 0)
Volver HitTest(&swnd,&slParam)
Endif
ENDPROC
windowstyle 2+16+64
window 600,400
cls 255
var dg&=Crear("Window",%hwnd,"",10,10,200,100)
StartPaint dg&
cls 255
EndPaint
SubClass dg&,1
SubClass %hwnd,1
mientras que 1
waitinput 30
caso iskey(27) : end
endwhile
|
|
|
| |
|
|