Switch Full Screen bordeless<==> Fenêtré (Window)
Publié : sam. 13/déc./2014 18:47
Ce code avec un peu d'API pour obtenir une application dans lequel il est possible d'alterner d'un mode fenêtré vers un mode FullScreen sans bordure et inversement.
Pas de gadget test, je n'ai laissé que l'essentiel. Vous passez d'un mode à l'autre avec la combinaison de touche Ctrl + Touche Entrée.
Pas de gadget test, je n'ai laissé que l'essentiel. Vous passez d'un mode à l'autre avec la combinaison de touche Ctrl + Touche Entrée.
Code : Tout sélectionner
Enumeration Window
#Mainform
EndEnumeration
Enumeration KeyBoard
#FullScreen
EndEnumeration
Global WindowStyle.i=#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget
Define fullScreen.b
Procedure OnResize()
Debug "On Resize"
EndProcedure
Procedure FullScreen()
Protected hWnd = WindowID(#Mainform)
Select GetWindowState(#Mainform)
Case #PB_Window_Normal
SetWindowState(#Mainform, #PB_Window_Maximize)
SetWindowLong_(hWnd, #GWL_STYLE, GetWindowLong_(hWnd, #GWL_STYLE)&~#WS_CAPTION&~#WS_SIZEBOX)
;Windows XP Only
;SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED|#SWP_DRAWFRAME)
Case #PB_Window_Maximize
SetWindowState(#Mainform, #PB_Window_Normal)
SetWindowLong_(hWnd, #GWL_STYLE, GetWindowLong_(hWnd, #GWL_STYLE)|#WS_CAPTION|#WS_SIZEBOX)
;Windows XP Only
;SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED|#SWP_DRAWFRAME)
Case #PB_Window_Minimize
EndSelect
EndProcedure
OpenWindow(#Mainform, 0, 0, 500, 400, "Full Screen Bordeless", WindowStyle)
AddKeyboardShortcut(#Mainform, #PB_Shortcut_Control|#PB_Shortcut_Return, #FullScreen)
BindEvent(#PB_Event_Menu, @fullScreen(), #Mainform, #FullScreen)
BindEvent(#PB_Event_SizeWindow, @OnResize())
Repeat : Until WaitWindowEvent(10) = #PB_Event_CloseWindow