When my program switches to fullscreen (windowed), its hide the menu until the mouse is moved.
i would like to know if is possible to avoid the moving of window while the menu show/hide? Or minimize the effect...
I found that with -1 in Y parameter of windowedScreen the effect is minimized (at least on my computer).
Here a very simple code to demonstrate:
Code: Select all
Procedure Init_Vars()
Global fullscreen,screenh,screenw
hWndM = OpenWindow(0,0,0,640,500,"Example",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
CanvasGadget(0, 0, 0, 640, 480)
InitSprite()
If ExamineScreenModes()
While NextScreenMode()
If ScreenModeWidth()=640 And ScreenModeHeight()=480
ScreenW=ScreenModeWidth():ScreenH=ScreenModeHeight()
Break
EndIf
Wend
EndIf
AddKeyboardShortcut(0, #PB_Shortcut_F4, 10)
CreateMenu(0,WindowID(0))
MenuTitle("File")
MenuItem(10,"FullScreen")
MenuItem(20,"Quit")
EndProcedure
Procedure menutime(*THREAD)
Shared tmenu
tmenu=2
Delay(3000)
tmenu=1
EndProcedure
Procedure menu()
Shared threadmenu
Event=WindowEvent()
If Event= #PB_Event_Menu
If EventMenu()=10
If Not fullscreen
fullscreen=1
StopDrawing()
FreeGadget(0)
SetMenuItemState(0,10,1)
OpenWindowedScreen(WindowID(0),0,-1,screenw,screenh,1,0,0,#PB_Screen_NoSynchronization)
StartDrawing(ScreenOutput())
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)&~ #WS_THICKFRAME &~ #WS_DLGFRAME)
threadmenu=CreateThread(@menutime(),0)
SetWindowState(0,#PB_Window_Maximize)
Else
fullscreen=0
HideMenu(0,0)
StopDrawing()
SetMenuItemState(0,10,0)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) |#WS_DLGFRAME)
SetWindowState(0,#PB_Window_Normal)
CanvasGadget(0, 0, 0, 640, 480)
EndIf
EndIf
ElseIf EventMenu()=20
End
EndIf
EndProcedure
Procedure events(hWndM, uMsg, wParam, lParam)
Shared moux,mouy,fullscreen,tmenu,threadmenu
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NCCALCSIZE
If fullscreen
Debug "changed"
EndIf
Case #WM_MOUSEMOVE
If fullscreen
CursorInfo.POINT
GetCursorPos_(CursorInfo)
If tmenu=0 And (CursorInfo\x <> moux And CursorInfo\y > 19)
threadmenu=CreateThread(@menutime(),0)
moux=CursorInfo\x
HideMenu(0,0)
ElseIf CursorInfo\y < 19 And CursorInfo\y <> mouy
SetCursorPos_(CursorInfo\x,20)
mouy=CursorInfo\y
moux=CursorInfo\x
ElseIf tmenu > 0
If IsThread(threadmenu):KillThread(threadmenu):EndIf
threadmenu=CreateThread(@menutime(),0)
moux=CursorInfo\x
EndIf
EndIf
Case #WM_CLOSE
End
EndSelect
ProcedureReturn result
EndProcedure
Procedure menus()
Shared tmenu
If fullscreen =0
StopDrawing()
StartDrawing(CanvasOutput(0))
Box(0,0,640,480,RGB(0,0,125))
DrawText(300,190,"CANVAS")
DrawText(280,210,"F4 Fullscreen")
menu()
Else
StopDrawing()
FlipBuffers()
menu()
If tmenu=1
HideMenu(0,1)
tmenu=0
EndIf
StartDrawing(ScreenOutput())
Box(0,0,640,480,RGB(125,0,0))
DrawText(280,100,"SCREEN")
DrawText(270,120,"WINDOWED")
EndIf
;...
EndProcedure
Init_Vars()
SetWindowCallback(@events())
Repeat
Delay(10)
menus()
ForEver