I'm writing a small utility where I want to allow the user to press a shortcut key combination to expand to full screen with no border and then be able to press the same shortcut to return to the previous mode. I have everything working and can set Maximize and Normal, but I can't see how to hide the title bar and remove the border and then re-enable it. Does anybody have an pointers?
Thanks, Colin
Set Fullscreen Programatically
Re: Set Fullscreen Programatically
And by full screen I also mean with no title bar, so also turning this off and on again.
Colin
Colin
Colin
Re: Set Fullscreen Programatically
Maybe this can help you:
and
Code: Select all
ShowWindow_(ToolBarID(#ToolBar),#SW_HIDE)
ShowWindow_(StatusBarID(#StatusBar),#SW_HIDE)
; then make a resize to previous stored position and size of window
Code: Select all
ShowWindow_(ToolBarID(#ToolBar),#SW_SHOW)
ShowWindow_(StatusBarID(#StatusBar),#SW_SHOW)
ResizeWindow(#Window, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN)-TaskBarHeight)

Re: Set Fullscreen Programatically
Thanks, but this is for the ToolBar and StatusBar of which my program has neither. Basically I want the window to flip between normal and (borderless with no titlebar)Lord wrote:Maybe this can help you:andCode: Select all
ShowWindow_(ToolBarID(#ToolBar),#SW_HIDE) ShowWindow_(StatusBarID(#StatusBar),#SW_HIDE) ; then make a resize to previous stored position and size of window
Code: Select all
ShowWindow_(ToolBarID(#ToolBar),#SW_SHOW) ShowWindow_(StatusBarID(#StatusBar),#SW_SHOW) ResizeWindow(#Window, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN)-TaskBarHeight)
Colin
Colin
Re: Set Fullscreen Programatically
I'm not on Windows right now, so I can't test it, but I found this: viewtopic.php?p=283204#p283204
Re: Set Fullscreen Programatically
F11 : Caption / No Caption
F12 : Maximize / Restore
Mouse LBUTTONDOWN : Drag & Move
F12 : Maximize / Restore
Mouse LBUTTONDOWN : Drag & Move
Code: Select all
#SC_DragMove = $F012
OpenWindow(0,0,0,400,300,"Test",#PB_Window_SystemMenu |#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SetWindowColor(0,#Gray)
AddKeyboardShortcut(0,#PB_Shortcut_F11,10)
AddKeyboardShortcut(0,#PB_Shortcut_F12,20)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case 10
Run10 ! 1
If Run10 = 1
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)&~ #WS_THICKFRAME &~ #WS_DLGFRAME)
ElseIf Run10 = 0
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) |#WS_DLGFRAME)
EndIf
Case 20
Run20 ! 1
If Run20 = 1
SetWindowState(0,#PB_Window_Maximize)
ElseIf Run20 = 0
SetWindowState(0,#PB_Window_Normal)
EndIf
EndSelect
Case #WM_LBUTTONDOWN
SetCursor_(LoadCursor_(0, #IDC_HAND))
SendMessage_(WindowID(0), #WM_SYSCOMMAND , #SC_DragMove,0)
EndSelect
Until Quit = 1
End
Egypt my love
Re: Set Fullscreen Programatically
Is it something like this you want:
Code: Select all
Enumeration
#Window
#ToolBar
#StatusBar
EndEnumeration
#F11 = 11; Toggle between fullscreen and window
#ShowTaskBar = #True; Set to #False to hide Taskbar in fullscreen mode
OpenWindow(#Window, 0, 0, 640, 480, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
; Just some "decoration"
CreateToolBar(#ToolBar, WindowID(#Window))
ToolBarStandardButton(1, #PB_ToolBarIcon_New)
CreateStatusBar(#StatusBar, WindowID(#Window))
AddKeyboardShortcut(#Window,#PB_Shortcut_F11,11)
xpos=WindowX(#Window) : ww=WindowWidth(#Window)
ypos=WindowY(#Window) : wh=WindowHeight(#Window)
CompilerIf #ShowTaskBar
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopWorkArea.RECT, 0)
DesktopWidth=GetSystemMetrics_(#SM_CXSCREEN)
DesktopHeight=GetSystemMetrics_(#SM_CYSCREEN)
TaskBarHeight=DesktopHeight-DesktopWorkArea\Bottom
CompilerElse
TaskBarHeight=0
CompilerEndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case #F11
Max ! 1
If Max = 1; maximize
xpos=WindowX(#Window):ww=WindowWidth(#Window)
ypos=WindowY(#Window):wh=WindowHeight(#Window)
SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, GetWindowLongPtr_(WindowID(#Window), #GWL_STYLE) & ~#WS_DLGFRAME & ~#PB_Window_SizeGadget)
SetWindowPos_(WindowID(#Window), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED | #SWP_DRAWFRAME | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER)
ShowWindow_(ToolBarID(#ToolBar), #SW_HIDE)
ShowWindow_(StatusBarID(#StatusBar), #SW_HIDE)
ResizeWindow(#Window, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN)-TaskBarHeight)
ElseIf Max = 0; restore
SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, GetWindowLongPtr_(WindowID(#Window), #GWL_STYLE) | #WS_DLGFRAME | #PB_Window_SizeGadget)
SetWindowPos_(WindowID(#Window), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED | #SWP_DRAWFRAME | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER)
ShowWindow_(ToolBarID(#ToolBar), #SW_SHOW)
ShowWindow_(StatusBarID(#StatusBar), #SW_SHOW)
ResizeWindow(#Window, xpos, ypos, ww, wh)
EndIf
EndSelect
EndSelect
Until Quit = 1
End

Re: Set Fullscreen Programatically
Same as above, but utilizing BindEvent and Procedure.
Code: Select all
Enumeration
#Window
#ToolBar
#StatusBar
EndEnumeration
#F11 = 11 ; Toggle between fullscreen and window
#Escape = 27 ; to close window in fullscreen mode, you may also use a shared variable to switch during runtime
#ShowTaskBar = #True; Set to #False to hide Taskbar in fullscreen mode
Procedure FullScreen()
Static First=#True, Max, xpos, ypos, ww, wh
If First=#True
If #ShowTaskBar=#True
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopWorkArea.RECT, 0)
DesktopWidth=GetSystemMetrics_(#SM_CXSCREEN)
DesktopHeight=GetSystemMetrics_(#SM_CYSCREEN)
TaskBarHeight=DesktopHeight-DesktopWorkArea\Bottom
Else
TaskBarHeight=0
EndIf
xpos=WindowX(#Window):ww=WindowWidth(#Window)
ypos=WindowY(#Window):wh=WindowHeight(#Window)
First=#False
EndIf
Max ! 1
If Max = 1; maximize
xpos=WindowX(#Window):ww=WindowWidth(#Window)
ypos=WindowY(#Window):wh=WindowHeight(#Window)
SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, GetWindowLongPtr_(WindowID(#Window), #GWL_STYLE) & ~#WS_DLGFRAME & ~#PB_Window_SizeGadget)
SetWindowPos_(WindowID(#Window), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED | #SWP_DRAWFRAME | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER)
ShowWindow_(ToolBarID(#ToolBar), #SW_HIDE)
ShowWindow_(StatusBarID(#StatusBar), #SW_HIDE)
ResizeWindow(#Window, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN)-TaskBarHeight)
; don't forget to resize Gadgets
ElseIf Max = 0; restore
SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, GetWindowLongPtr_(WindowID(#Window), #GWL_STYLE) | #WS_DLGFRAME | #PB_Window_SizeGadget)
SetWindowPos_(WindowID(#Window), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED | #SWP_DRAWFRAME | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER)
ShowWindow_(ToolBarID(#ToolBar), #SW_SHOW)
ShowWindow_(StatusBarID(#StatusBar), #SW_SHOW)
ResizeWindow(#Window, xpos, ypos, ww, wh)
; don't forget to resize Gadgets
EndIf
EndProcedure
Procedure WindowClose()
Shared Quit
Quit=#True
EndProcedure
OpenWindow(#Window, 0, 0, 640, 480, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
; Just some "decoration"
CreateToolBar(#ToolBar, WindowID(#Window))
ToolBarStandardButton(1, #PB_ToolBarIcon_New)
CreateStatusBar(#StatusBar, WindowID(#Window))
; use F11 to toggle window <-> fullscreen mode
AddKeyboardShortcut(#Window,#PB_Shortcut_F11,11)
BindEvent(#PB_Event_Menu, @Fullscreen(), #Window, 11)
; 'normal' close window
BindEvent(#PB_Event_CloseWindow, @WindowClose(), #Window)
; to close window in fullscreen mode
AddKeyboardShortcut(#Window,#PB_Shortcut_Escape,27)
BindEvent(#PB_Event_Menu, @WindowClose(), #Window, 27)
Repeat
WaitWindowEvent()
Until Quit=#True
End
