Simple example.
Please note the macro used to make the second window a topmost,
this is to avoid the taskbar eating up part of the window
when you move the window near the bottom of the screen.
The main window is allready a topmost automatically.
Code: Select all
Macro MakeWindowTopmost(window)
SetWindowPos_(WindowID(window),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_FRAMECHANGED)
EndMacro
InitSprite()
InitKeyboard()
#Flags=#PB_Window_Invisible|#PB_Window_Maximize|#PB_Window_BorderLess
OpenWindow(0,0,0,800,600,"our screen",#Flags)
HideWindow(0,#False)
SmartWindowRefresh(0,#True)
OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0),0,0,0,#PB_Screen_NoSynchronization)
#Flags2=#PB_Window_Invisible|#PB_Window_SystemMenu|#PB_Window_WindowCentered|#PB_Window_BorderLess
OpenWindow(1,0,0,200,200,"screen "+Str(WindowWidth(0))+"x"+Str(WindowHeight(0)),#Flags2,WindowID(0))
MakeWindowTopmost(1)
ButtonGadget(0,0,0,100,20,"Draw circle")
WebGadget(1,0,20,WindowWidth(1),WindowHeight(1)-20,"http://www.purebasic.com")
HideWindow(1,#False)
SmartWindowRefresh(1,#True)
Repeat
Event=WaitWindowEvent(1)
If Event=#PB_Event_Gadget
If EventGadget()=0
StartDrawing(ScreenOutput())
Circle(Random(WindowWidth(0)-1),Random(WindowHeight(0)-1),50,Random($FFFFFF))
StopDrawing()
FlipBuffers()
EndIf
EndIf
Until Event=#PB_Event_CloseWindow
make sure though that you close and re open the screen
as any resize will shut down the screen and fre it's buffer.
See PB manual about this under OpenWindowScreen()
Code: Select all
;Example: PB4 Beta 10
Procedure.l SetFullscreenMode(window.l,state.l)
Static style.l,x.l,y.l,w.l,h.l,mode.l=#False,oldwindow.l
Define.l hwnd
If ((window=-1) And (state=-1)) : ProcedureReturn mode : EndIf
If IsWindow(window)=#False : ProcedureReturn #False : EndIf
hwnd=WindowID(window)
If ((mode=#False) And (state=#True))
style=GetWindowLong_(hwnd,#GWL_STYLE)
oldwindow=window
mode=#True
x=WindowX(window)
y=WindowX(window)
w=WindowWidth(window)
h=WindowHeight(window)
SetWindowLong_(hwnd,#GWL_STYLE,#WS_POPUP)
SetWindowPos_(hwnd,#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED)
ShowWindow_(hwnd,#SW_MAXIMIZE)
Else
If ((mode=#True) And (oldwindow=window))
SetWindowLong_(hwnd,#GWL_STYLE,style)
SetWindowPos_(hwnd,#HWND_NOTOPMOST,x,y,w,h,#SWP_FRAMECHANGED)
ShowWindow_(hwnd,#SW_NORMAL)
mode=#False
Else
ProcedureReturn #False
EndIf
EndIf
ProcedureReturn #True
EndProcedure
Macro GetFullscreenMode() ;Returns #True if there currently is a fullscreen, #False if not.
SetFullscreenMode(-1,-1)
EndMacro
Macro MakeWindowTopmost(window)
SetWindowPos_(WindowID(window),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_FRAMECHANGED)
EndMacro
InitSprite()
InitKeyboard()
#Flags=#PB_Window_Invisible|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered
OpenWindow(0,0,0,800,600,"our screen",#Flags)
HideWindow(0,#False)
SmartWindowRefresh(0,#True)
SetFullscreenMode(0,#True)
OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0),0,0,0,#PB_Screen_NoSynchronization)
#Flags2=#PB_Window_Invisible|#PB_Window_SystemMenu|#PB_Window_WindowCentered|#PB_Window_BorderLess|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered
OpenWindow(1,0,0,200,200,"screen "+Str(WindowWidth(0))+"x"+Str(WindowHeight(0)),#Flags2,WindowID(0))
MakeWindowTopmost(1)
ButtonGadget(0,0,0,100,20,"Draw circle")
WebGadget(1,0,20,WindowWidth(1),WindowHeight(1)-20,"http://www.purebasic.com")
HideWindow(1,#False)
SmartWindowRefresh(1,#True)
Repeat
Event=WaitWindowEvent(1)
If Event=#PB_Event_Gadget
If EventGadget()=0
StartDrawing(ScreenOutput())
Circle(Random(WindowWidth(0)-1),Random(WindowHeight(0)-1),50,Random($FFFFFF))
StopDrawing()
FlipBuffers()
EndIf
EndIf
Until Event=#PB_Event_CloseWindow
If you minimize the second window or maximize it,
you will notice that it is still restricted by the workspace defaults.
Please see http://support.microsoft.com/default.as ... -us;179363
for more details on why this behaviour exist!
It is possible to override this but that is beyond the scope of these two examples!
Feel free to add improvements or variations of the examples to this thread if you have ideas or suggestions!