OpenWindowedScreen()
Syntax
Result = OpenWindowedScreen(WindowID, x, y, Width, Height, AutoStretch, RightOffset, BottomOffset)Description
Open a new screen area according to given parameters on the given Window, which must be opened before using OpenWindow(). The "windowed screen" is able to use the hardware acceleration the same way than full-size OpenScreen() command.
If AutoStretch is 1, then the screen area will automatically resize (and its contents will be zoomed to new screen size) when the window size changes.
RightOffset and BottomOffset are used to define a margin on the right and bottom of the window (for statusbar for example).
The opened screen is created with 2 video buffers to allow you to do double buffering, especially useful for games. The buffers can be manipulated with the FlipBuffers() command.
If the screen fails to open, the result is '0'.
Note: Only one windowed screen can be opened at one time.
Example 1: (fixed screen size with gadgets)If InitSprite() = 0 MessageRequester("Error", "Can't open screen & sprite enviroment!", 0) End EndIf If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If CreateGadgetList(WindowID(0)) ButtonGadget(0, 170, 135, 45, 20, "Quit") EndIf If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160, 0, 0, 0) CreateSprite(0, 20, 20) If StartDrawing(SpriteOutput(0)) Box(0, 0, 20, 20, RGB(255, 0, 155)) Box(5, 5, 10, 10, RGB(155, 0, 255)) StopDrawing() EndIf Else MessageRequester("Error", "Can't open windowed screen!", 0) End EndIf EndIf direction = 2 Repeat ; It's very important to process all the events remaining in the queue at each frame ; Repeat Event = WindowEvent() Select Event Case #PB_Event_Gadget If EventGadget() = 0 End EndIf Case #PB_Event_CloseWindow End EndSelect Until Event = 0 FlipBuffers() ClearScreen(RGB(0, 0, 0)) DisplaySprite(0, x, x) x + direction If x > 140 : direction = -2 : EndIf If x < 0 : direction = 2 : EndIf Delay(1) ForEver
Example 2: (screen with enabled auto-stretch and bottom-offset feature)If InitSprite() = 0 MessageRequester("Error", "Can't open screen & sprite enviroment!", 0) End EndIf If OpenWindow(0, 0, 0, 320, 140, "A screen in a window...", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered) If CreateStatusBar(0, WindowID(0)) AddStatusBarField(320) StatusBarText(0, 0, "Automatically zoomed screen area when changing window size...") EndIf If OpenWindowedScreen(WindowID(0), 0, 0, 1, 1, 1, 0, 20) ; we don't need exact screen width/height, because it will be automatically stretched... Else MessageRequester("Error", "Can't open windowed screen!", 0) End EndIf EndIf Repeat ; It's very important to process all the events remaining in the queue at each frame ; Repeat Event = WindowEvent() If Event = #PB_Event_CloseWindow End EndIf Until Event = 0 FlipBuffers() ClearScreen(RGB(0, 0, 200)) Delay(1) ForEver
For a more detailed example look at
WindowedScreen.pb
Supported OS
All