Ich hatte das gleiche Problem und hab`s mit GetActiveWindow() gelöst.
Code: Alles auswählen
InitSprite()
xP = 400
yP = 400
xP2 = xP/2
yP2 = yP/2
OpenWindow(0, 0, 0, xP+200, yP, "SCREEN", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 200, 0, xP, yP, 0, 0, 0)
screenon = 1
CreateSprite(1, xP, yP)
Phi1.f = 1
Phi1_.f = 0
Phi1__.f = 0
Phi2.f = -2
Phi2_.f = 0
Phi2__.f = 0
l1.f = 100
l2.f = 100
m1.f = 10
m2.f = 10
g.f = 9.81/70
TextGadget(110, 10, 10, 80, 20, "Masse 1") : StringGadget(111, 100, 10, 80, 20, StrF(m1))
TextGadget(120, 10, 40, 80, 20, "Länge 1") : StringGadget(121, 100, 40, 80, 20, StrF(l1))
TextGadget(130, 10, 70, 80, 20, "Phi 1") : StringGadget(131, 100, 70, 80, 20, StrF(Phi1))
TextGadget(210, 10, 110, 80, 20, "Masse 2") : StringGadget(211, 100, 110, 80, 20, StrF(m2))
TextGadget(220, 10, 140, 80, 20, "Länge 2") : StringGadget(221, 100, 140, 80, 20, StrF(l2))
TextGadget(230, 10, 170, 80, 20, "Phi 2") : StringGadget(231, 100, 170, 80, 20, StrF(Phi2))
ButtonGadget(0, 10, 300, 180, 20, "Simulation starten")
Repeat
Delay(5)
If GetActiveWindow() = 0
If screenon = 0
If OpenWindowedScreen(WindowID(0), 200, 0, xP, yP, 0, 0, 0)
CreateSprite(1, xP, yP)
screenon = 1
EndIf
EndIf
Else
screenon = 0
EndIf
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 0
UseBuffer(1)
ClearScreen(0)
UseBuffer(-1)
Phi1_.f = 0
Phi1__.f = 0
Phi2_.f = 0
Phi2__.f = 0
Phi1 = ValF(GetGadgetText(131))
Phi2 = ValF(GetGadgetText(231))
x1_ = 0
Case 111
m1 = ValF(GetGadgetText(111))
Case 121
l1 = ValF(GetGadgetText(121))
Case 131
Phi1 = ValF(GetGadgetText(131))
Case 211
m2 = ValF(GetGadgetText(211))
Case 221
l2 = ValF(GetGadgetText(221))
Case 231
Phi2 = ValF(GetGadgetText(231))
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 0
EndSelect
EndSelect
Until Not Event
ClearScreen(0)
For n = 1 To 10
Phi1__ = -g/l1*Sin(Phi1) -m2/(m1+m2)*(l2/l1)*(Cos(Phi2-Phi1)*Phi2__+Sin(Phi1-Phi2)*Phi2_*Phi2_)
Phi2__ = -g/l2*Sin(Phi2) -(l1/l2)*(Cos(Phi2-Phi1)*Phi1__-Sin(Phi1-Phi2)*Phi1_*Phi1_)
Next
Phi1_ + Phi1__
Phi1 + Phi1_
Phi2_ + Phi2__
Phi2 + Phi2_
x1 = xP2 + Sin(Phi1)*l1
y1 = yP2 + Cos(Phi1)*l1
x2 = x1 + Sin(Phi2)*l2
y2 = y1 + Cos(Phi2)*l2
If x1_
StartDrawing(SpriteOutput(1))
LineXY(x1, y1, x1_, y1_, $5050A0)
LineXY(x2, y2, x2_, y2_, $50A000)
StopDrawing()
EndIf
x1_ = x1
y1_ = y1
x2_ = x2
y2_ = y2
DisplaySprite(1,0,0)
StartDrawing(ScreenOutput())
DrawingMode(1)
LineXY(xP2, yP2, x1, y1, $808080)
Circle(x1, y1, 5, $A0A0F0)
LineXY(x1, y1, x2, y2, $808080)
Circle(x2, y2, 5, $A0F0A0)
DrawText(0, 50, StrF(E), $FFFFFF)
StopDrawing()
FlipBuffers()
ForEver