Seite 1 von 1

SizeBox erstellen

Verfasst: 29.03.2014 21:04
von SBond
Hallo Leute,

weiß jemand, ob man eine SizeBox (ohne Statusbar) erzeugen kann?
Oder kann man z.B. einem ImageGadget diese Funktionalität übertragen?


Ich verwende ein ContainerGadget als StatusBar-ersatz und das klappt soweit auch prima. Nur wäre es schön, wenn man dort irgendwie diese SizeBox einfügen könnte.

Gruß,
SBond

Re: SizeBox erstellen

Verfasst: 29.03.2014 22:37
von Danilo
Habe mal das Beispiel "Move Borderless Window with CanvasGadget.pb" umgeschrieben
zu "Resize Borderless Window with CanvasGadget.pb".

Code: Alles auswählen

Procedure Exit()
    End
EndProcedure

Procedure LeftMouseDown()
    Shared MouseDown, OffsetX, OffsetY
    MouseDown = #True
    OffsetX = GetGadgetAttribute(1,#PB_Canvas_MouseX)
    OffsetY = GetGadgetAttribute(1,#PB_Canvas_MouseY)
EndProcedure

Procedure LeftMouseUp()
    Shared MouseDown
    MouseDown = #False
EndProcedure

Procedure MouseMove()
    Shared MouseDown, OffsetX, OffsetY
    Protected w,h
    If MouseDown And GetGadgetAttribute(1,#PB_Canvas_Buttons)&#PB_Canvas_LeftButton
        w = WindowWidth(0)  - OffsetX+GetGadgetAttribute(1,#PB_Canvas_MouseX)
        h = WindowHeight(0) - OffsetY+GetGadgetAttribute(1,#PB_Canvas_MouseY)
        If w < 100 : w = 100 : EndIf
        ;If w > 800 : w = 800 : EndIf
        If h < 30 : h = 30 : EndIf
        ;If h > 600 : h = 600 : EndIf
        ResizeGadget(1,w-16,h-16,#PB_Ignore,#PB_Ignore)
        ResizeWindow(0,#PB_Ignore,#PB_Ignore,w,h)
    EndIf
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "Moveable window", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
    ;WindowBounds(0,100,30,800,600)
    ButtonGadget(0,10,10,100,25,"Exit")
    BindEvent(#PB_Event_Gadget,@Exit(),0,0,#PB_EventType_LeftClick)
    
    CanvasGadget(1,WindowWidth(0)-16,WindowHeight(0)-16,16,16)
    SetGadgetAttribute(1,#PB_Canvas_Cursor,#PB_Cursor_Hand)
    BindEvent(#PB_Event_Gadget,@LeftMouseDown(),0,1,#PB_EventType_LeftButtonDown)
    BindEvent(#PB_Event_Gadget,@LeftMouseUp()  ,0,1,#PB_EventType_LeftButtonUp)
    BindEvent(#PB_Event_Gadget,@MouseMove()    ,0,1,#PB_EventType_MouseMove)
    
    If StartDrawing(CanvasOutput(1))
        Box(0,0,OutputWidth(),OutputHeight(),RGB(0,0,128))
        StopDrawing()
    EndIf
    
    Repeat:WaitWindowEvent():ForEver
EndIf
Getestet mit Windows & Mac.

Re: SizeBox erstellen

Verfasst: 29.03.2014 22:44
von SBond
super.

darauf bin ich ja gar nicht gekommen. Die Lösung ist mal wieder ganz leicht :D


danke dir