zoukankan      html  css  js  c++  java
  • 全屏显示

    I guess you know you can run your browser in full screen using the F11 shortcut key. Windows Explorer also supports this feature.

    Running in full screen, where an application UI covers the entire screen, over the TaskBar and any Desktop/Tool bars, is handy when a user has a limited screen size (netbooks) or when you just want more to be visible by the browser or the Windows Explorer.

    Running your application in full screen might also be handy if your users want to be focused only on your application's window.

    F11 - Full Screen

    Full screen means "full screen" - where the UI of the application gets "on top" of the TaskBar or any other tool bars - the entire UI of your application covers Windows desktop.

    If you have a main menu in your application you can add a menu item "full screen" and have it assigned the "f11" key for Shortcut property.

    Here's how to allow switching to the full screen view and back to the "normal" view - taking into account what "normal" was before your application went to the "full screen" mode.

    {$J+} //writeable constants on
    const
      rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
      ws : TWindowState = wsNormal;
    {$J-} //writeable constants off
    var
      r : TRect;
    begin
      if BorderStyle <> bsNone then
      begin
        ws := WindowState;
        rect := BoundsRect;
    
        BorderStyle := bsNone;
        r := Screen.MonitorFromWindow(Handle).BoundsRect;
        SetBounds(r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top) ;
      end
      else
      begin
        BorderStyle := bsSizeable;
        if ws = wsMaximized then
          WindowState := wsMaximized
        else
          SetBounds(rect.Left, rect.Top, rect.Right-rect.Left, rect.Bottom-rect.Top) ;
      end;
    end;
    The code above presumes that when not in full screen mode your main window has a border - i.e. the BorderStyle is not bsNone.

    To get the size of the full screen the MonitorFromWindow method of the Screen global variable is used. MonitorFromWindow retrieves the Monitor (TMonitor) that has the largest area of intersection with the bounding rectangle of a specified window (your main form in this case).

    The BoundsRect property gives the dimensions of the monitor in pixels, where (0,0) represents the top-left corner of the monitor. The BoundsRect property does not take into account any task bars or tool bars docked on the monitor.

    By using the "{$J+}" and "{$J-}" the typed constants declared in the code ("rect" and "ws") are made writable - their value will not get lost when the above code is called several times.

    Therefore: if the BorderStyle is not bsNone we presume that we are not in full screen mode. To enter the full screen mode, we set the BorderStyle property to bsNone and also use SetBounds to set the Left, Top, Width, and Height properties of the main form all at once.

    We also store the current bounds of the main window along with the WindowStyle - when going back from the full screen to restore the last state of the UI of the main application window.

    Note: To fill the usable area (not hiding the TaskBar) you can use the SystemParametersInfo API with SPI_GETWORKAREA

    转:http://delphi.about.com/od/delphitips2010/qt/delphi-application-full-screen-mode-f11.htm

  • 相关阅读:
    js实现页面的全屏与退出
    vue父组件访问子组件
    v-contextmenu的使用(右键菜单)
    vue实现tab切换
    vue中子组件向父组件传值
    vue中父组件传数据给子组件
    RNN
    用于超参数随机化搜索的几个分布
    Numpy 函数总结 (不断更新)
    神经网络求导
  • 原文地址:https://www.cnblogs.com/shuaixf/p/2776168.html
Copyright © 2011-2022 走看看