Code: Alles auswählen
Enumeration
#frmResizeExample
#cmdTopLeft
#cmdTopRight
#cmdLeft
#cmdTop
#cmdRight
#cmdBottom
#cmdBottomLeft
#cmdBottomRight
#cmdExit
EndEnumeration
Procedure.l IsMouseOverGadget(Gadget.l)
Protected wnd.l
Protected re.RECT
Protected pt.POINT
wnd=GadgetID(Gadget)
If wnd
GetWindowRect_(wnd,re)
GetCursorPos_(pt)
ProcedureReturn PtInRect_(re,pt\x,pt\y)
EndIf
EndProcedure
Procedure ResizeGadgets()
Protected x.l, y.l, w.l, h.l
; Topleft braucht keinen resize
; [...]
; TopRight
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdTopRight)
y = 0
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdTopRight, x, y, w, h)
; Left
x = 0
y = GadgetHeight(#cmdTopLeft)
w = #PB_Ignore
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTopLeft) - GadgetHeight(#cmdBottomLeft)
ResizeGadget(#cmdLeft, x, y, w, h)
; Top
x = GadgetWidth(#cmdTopLeft)
y = 0
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdTopLeft) - GadgetWidth(#cmdTopRight)
h = #PB_Ignore
ResizeGadget(#cmdTop, x, y, w, h)
; Right
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdRight)
y = GadgetHeight(#cmdTopRight)
w = #PB_Ignore
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTopRight) - GadgetHeight(#cmdBottomRight)
ResizeGadget(#cmdRight, x, y, w, h)
; Bottom
x = GadgetWidth(#cmdBottomLeft)
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottom)
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdBottomLeft)- GadgetWidth(#cmdBottomRight)
h = #PB_Ignore
ResizeGadget(#cmdBottom, x, y, w, h)
; BottomLeft
x = 0
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottomLeft)
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdBottomLeft, x, y, w, h)
; BottomRight
x = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdBottomRight)
y = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdBottomRight)
w = #PB_Ignore
h = #PB_Ignore
ResizeGadget(#cmdBottomRight, x, y, w, h)
; Exit-Button
x = GadgetWidth(#cmdLeft)
y = GadgetHeight(#cmdTop)
w = WindowWidth(#frmResizeExample) - GadgetWidth(#cmdLeft) - GadgetWidth(#cmdRight)
h = WindowHeight(#frmResizeExample) - GadgetHeight(#cmdTop) - GadgetHeight(#cmdBottom)
ResizeGadget(#cmdExit, x, y, w, h)
EndProcedure
Procedure ResizeBorderlessWindow(ResizeWhat.l)
ReleaseCapture_()
SendMessage_(WindowID(#frmResizeExample), #WM_NCLBUTTONDOWN, ResizeWhat, 0)
EndProcedure
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(#frmResizeExample))
ButtonGadget(#cmdTopLeft, 0, 0, 30, 30, "tl")
ButtonGadget(#cmdTopRight, 0, 0, 30, 30, "tr")
ButtonGadget(#cmdLeft, 0, 0, 30, 0, "l")
ButtonGadget(#cmdTop, 0, 0, 0, 30, "t")
ButtonGadget(#cmdRight, 0, 0, 30, 0, "r")
ButtonGadget(#cmdBottom, 0, 0, 0, 30, "b")
ButtonGadget(#cmdBottomLeft, 0, 0, 30, 30, "bl")
ButtonGadget(#cmdBottomRight, 0, 0, 30, 30, "br")
ButtonGadget(#cmdExit, 25, 25, 50, 40, "Exit")
ResizeGadgets()
Repeat
WWE = WaitWindowEvent()
EG = EventGadget()
Select WWE
Case #WM_LBUTTONDOWN
If IsMouseOverGadget(#cmdTopLeft) : ResizeBorderlessWindow(#HTTOPLEFT)
ElseIf IsMouseOverGadget(#cmdTopRight) : ResizeBorderlessWindow(#HTTOPRIGHT)
ElseIf IsMouseOverGadget(#cmdTop) : ResizeBorderlessWindow(#HTTOP)
ElseIf IsMouseOverGadget(#cmdLeft) : ResizeBorderlessWindow(#HTLEFT)
ElseIf IsMouseOverGadget(#cmdRight) : ResizeBorderlessWindow(#HTRIGHT)
ElseIf IsMouseOverGadget(#cmdBottom) : ResizeBorderlessWindow(#HTBOTTOM)
ElseIf IsMouseOverGadget(#cmdBottomLeft) : ResizeBorderlessWindow(#HTBOTTOMLEFT)
ElseIf IsMouseOverGadget(#cmdBottomRight) : ResizeBorderlessWindow(#HTBOTTOMRIGHT)
ElseIf IsMouseOverGadget(#cmdExit) : Quit = #True
EndIf
Case #PB_Event_SizeWindow
ResizeGadgets()
EndSelect
Until Quit = #True
EndIf
EndIf
Grüße ... Kiffi