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

  • 相关阅读:
    状态压缩 + 暴力 HDOJ 4770 Lights Against Dudely
    简单几何(推公式) UVA 11646 Athletics Track
    简单几何(四边形形状) UVA 11800 Determine the Shape
    简单几何(求交点) UVA 11437 Triangle Fun
    计算几何模板
    简单几何(相对运动距离最值) UVA 11796 Dog Distance
    简单几何(求划分区域) LA 3263 That Nice Euler Circuit
    覆盖的面积 HDU
    Desert King 最小比率生成树 (好题)
    约会安排 (区间合并)毒瘤题
  • 原文地址:https://www.cnblogs.com/shuaixf/p/2776168.html
Copyright © 2011-2022 走看看