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

  • 相关阅读:
    LPTSTR、LPCSTR、LPCTSTR、LPSTR的意义
    字符,字节和编码
    堆和栈的区别
    js正则表达式限制文本框只能输入数字,小数点,英文字母
    WPF 中的 LinkButton
    WPF中DataGrid的应用
    C#获取web.config配置文件内容
    js中格式化时间字符串
    WPF中的用户控件(UserControl)
    VS2010安装其他版本framework的问题解决方案
  • 原文地址:https://www.cnblogs.com/shuaixf/p/2776168.html
Copyright © 2011-2022 走看看