全螢幕

出自ProgWiki
跳至導覽 跳至搜尋

全螢幕(Fullscreen)

應用

網頁瀏覽器

document.addEventListener('DOMContentLoaded',function(){
 openFullscreen()
})
function openFullscreen() {
  let elem = document.documentElement
  if (elem.requestFullscreen) {
    elem.requestFullscreen()
  } else if (elem.mozRequestFullScreen) { /* Firefox */
    elem.mozRequestFullScreen()
  } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
    elem.webkitRequestFullscreen()
  } else if (elem.msRequestFullscreen) { /* IE/Edge */
    elem.msRequestFullscreen()
  }
}
/* Get the documentElement (<html>) to display the page in fullscreen */
var elem = document.documentElement;
 
/* View in fullscreen */
function openFullscreen() {
  if (elem.requestFullscreen) {
    elem.requestFullscreen();
  } else if (elem.webkitRequestFullscreen) { /* Safari */
    elem.webkitRequestFullscreen();
  } else if (elem.msRequestFullscreen) { /* IE11 */
    elem.msRequestFullscreen();
  }
}
 
/* Close fullscreen */
function closeFullscreen() {
  if (document.exitFullscreen) {
    document.exitFullscreen();
  } else if (document.webkitExitFullscreen) { /* Safari */
    document.webkitExitFullscreen();
  } else if (document.msExitFullscreen) { /* IE11 */
    document.msExitFullscreen();
  }
}

C++/DirectDraw

C++/DirectShow

C++/DirectX

C++/MFC

//at OnInitDialog
CRect rcDesktop;
rcDesktop.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
rcDesktop.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
rcDesktop.bottom = rcDesktop.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
MoveWindow(rcDesktop, FALSE);

C++/OpenCV

C++/OpenGL

C++/Qt

C++/SDL

C++/Win32

C++/WTL

C++/X11

C#/Unity

C#/UWP

C#/XNA

Delphi

procedure TForm1.FormCreate(Sender: TObject);
begin
  BorderStyle := bsNone;
  WindowState := wsMaximized;
end;

Java

Node.js/electron

var win = electron.remote.getCurrentWindow(); 
win.setFullScreen(true);

Python/tkinter

Unreal Engine 4

VB6

'Put this declaration on the top of the Code Window of the form
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long,          ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
 
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
 
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40
 
'Put this code in the Button_Click() event
'Or whereever u want to make the 
'screen full screen.
 
Dim cx As Long
Dim cy As Long
Dim RetVal As Long
 
' Determine if screen is already maximized.
If Me.WindowState = vbMaximized Then
    ' Set window to normal size
    Me.WindowState = vbNormal
End If
 
' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)
' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)
 
' Call API to set new size of window.
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW)

Windows Media Player

Windows Form