SizeBox erstellen

Für allgemeine Fragen zur Programmierung mit PureBasic.
SBond
Beiträge: 266
Registriert: 22.05.2013 20:35

SizeBox erstellen

Beitrag 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
41 6c 73 6f 20 77 65 6e 6e 20 64 75 20 73 6f 20 76 69 65 6c 20 4c 61 6e 67 65 77 65 69 6c 65 20 68 61 73 74 2c 20 64 61 6e 6e 20 6b 61 6e 6e 73 74 20 64 75 20 61 75 63 68 20 67 6c 65 69 63 68 20 7a 75 20 6d 69 72 20 6b 6f 6d 6d 65 6e 20 75 6e 64 20 61 62 77 61 73 63 68 65 6e 2e

:D
Benutzeravatar
Danilo
-= Anfänger =-
Beiträge: 2284
Registriert: 29.08.2004 03:07

Re: SizeBox erstellen

Beitrag 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.
Zuletzt geändert von Danilo am 29.03.2014 22:45, insgesamt 1-mal geändert.
cya,
...Danilo
"Ein Genie besteht zu 10% aus Inspiration und zu 90% aus Transpiration" - Max Planck
SBond
Beiträge: 266
Registriert: 22.05.2013 20:35

Re: SizeBox erstellen

Beitrag von SBond »

super.

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


danke dir
41 6c 73 6f 20 77 65 6e 6e 20 64 75 20 73 6f 20 76 69 65 6c 20 4c 61 6e 67 65 77 65 69 6c 65 20 68 61 73 74 2c 20 64 61 6e 6e 20 6b 61 6e 6e 73 74 20 64 75 20 61 75 63 68 20 67 6c 65 69 63 68 20 7a 75 20 6d 69 72 20 6b 6f 6d 6d 65 6e 20 75 6e 64 20 61 62 77 61 73 63 68 65 6e 2e

:D
Antworten