PS: Win98se
Code: Select all
Declare WinTest()
WinTest()
Structure WinInfoT
; Windowed
pi.l ; PB Window Identifier
ph.l ; PB Window Handle
wx.l ; Window X offset
wy.l ; Window Y offset
ww.l ; Window
wh.l ; Window
wt.s ; Window
wf.l ; Window
; Screen
sm.l ; Screen Mode (0: Windowed, 1: Fullscreen)
sx.l ; Screen X offset (windowed mode)
sy.l ; Screen Y offset (windowed mode)
sw.l ; Screen Width (fullscreen)
sh.l ; Screen Height (fullscreen)
sc.l ; Screen Colour Bits (fullscreen)
ws.l ; Window State (0: Opening, 1: Active, 2: Closing)
EndStructure
Procedure.l testWindow(x.l, y.l, w.l, h.l, wf.l, t.s)
Shared wi.WinInfoT
ExamineScreenModes()
wi\wx = x
wi\wy = y
wi\ww = w
wi\wh = h
wi\wf = wf
wi\wt = t
wi\sm = 0
wi\sx = 0
wi\sy = 0
wi\sw = w
wi\sh = h
wi\sc = ScreenModeDepth()
wi\ph = OpenWindow(wi\pi, wi\wx, wi\wy, wi\ww, wi\wh, wi\wf, wi\wt)
If wi\ws: CloseScreen(): EndIf
OpenWindowedScreen(wi\ph, wi\sx, wi\sy, wi\ww, wi\wh, 0, 0, 0)
wi\ws = 1
EndProcedure
Procedure.l testScreen(w.l, h.l, c.l, d.l, t.s)
Shared wi.WinInfoT
ExamineScreenModes()
wi\sm = 1
wi\sw = w
wi\sh = h
wi\sc = c
wi\wt = t
If wi\ws: CloseScreen(): EndIf
OpenScreen(wi\sw, wi\sh, wi\sc, wi\wt)
SetFrameRate(75)
wi\ws = 1
EndProcedure
Procedure.l testWinClose()
Shared wi.WinInfoT
wi\ws = 2
If wi\sm
CloseScreen()
Else
CloseWindow(wi\pi)
EndIf
EndProcedure
Procedure.l WinResize(w.l, h.l)
Shared wi.WinInfoT
If wi\sm: ProcedureReturn: EndIf
wi\ww = w
wi\wh = h
wi\sm = 0
wi\sw = w
wi\sh = h
If wi\ph = 0
wi\ph = OpenWindow(wi\pi, wi\wx, wi\wy, wi\ww, wi\wh, wi\wf, wi\wt)
EndIf
CloseScreen()
OpenWindowedScreen(wi\ph, wi\sx, wi\sy, wi\sw, wi\sh, 0, 0, 0)
EndProcedure
Procedure testDraw()
Shared wi.WinInfoT
If IsScreenActive()
; Simple PB test code
;
If wi\sm
StartDrawing(ScreenOutput())
Else
StartDrawing(WindowOutput())
EndIf
ClearScreen(192, 192, 255)
DrawingMode(4)
Box(0, 0, wi\sw, wi\sh , cRed)
LineXY(0, 0, wi\sw, wi\sh , cRed)
LineXY(0, wi\sh, wi\sw, 0 , cRed)
Circle((wi\sw-1)/2, (wi\sh-1)/2, (wi\sh-1)/2, cRed)
Locate(10,10)
DrawText(Str(wi\ww)+","+Str(wi\wh))
Locate(10,25)
DrawText(Str(wi\sw)+","+Str(wi\sh))
StopDrawing()
EndIf
EndProcedure
Procedure.l WinTest()
Shared wi.WinInfoT
wf = #PB_Window_SizeGadget ;: Adds the sizeable feature To a window.
InitSprite()
w=800: h=600: c=32: d=32: f=0
testWindow(0,0, w, h, wf, "Test")
; testScreen(w, h, c, d, "Test")
cBlack = RGB(0,0,0)
cWhite = RGB(255,255,255)
cRed = RGB(255,0,0)
cSky = RGB(192, 192, 255)
InitKeyboard()
Repeat
testDraw()
FlipBuffers()
If wi\sm=0
e = WindowEvent()
If e = #WM_SIZE: WinResize(WindowWidth(), WindowHeight()): EndIf
EndIf
Delay(1)
ExamineKeyboard()
If KeyboardReleased(#PB_KEY_F12)
If wi\sm
testWindow(wi\wx, wi\wy, wi\ww, wi\wh, wi\wf, wi\wt)
Else
testScreen(800, 600, 32, 16, wi\wt)
EndIf
EndIf
Until KeyboardPushed(#PB_KEY_ESCAPE)
testWinClose()
EndProcedure

