• 重回博客园


    暂别AS3生涯,重回C#,今天开始整理头绪写个随笔。

    关于Winform全屏的问题,网上的资料,都是差不多,将Window窗口最大化,然后去除边框和任务栏

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Text;
     7 using System.Windows.Forms;
     8 using System.Runtime.InteropServices; // Important!
     9 
    10 namespace FullScreenExample
    11 {
    12     public partial class Form1 : Form
    13     {
    14         [DllImport("user32.dll")]
    15         private static extern int FindWindow(string lpszClassName, string lpszWindowName);
    16         [DllImport("user32.dll")]
    17         private static extern int ShowWindow(int hWnd, int nCmdShow);
    18 
    19         private const int SW_HIDE = 0;
    20         private const int SW_SHOW = 1;
    21 
    22         private void full_maximize(object sender, EventArgs e)
    23         {
    24             //隐藏任务栏
    25 
    26             int hWnd = FindWindow("Shell_TrayWnd", "");
    27             ShowWindow(hWnd, SW_HIDE);
    28 
    29             FormBorderStyle = FormBorderStyle.None;
    30             this.Location = new Point(0, 0);
    31             this.WindowState = FormWindowState.Maximized;
    32         }
    33 
    34         public Form1()
    35         {
    36             InitializeComponent();
    37         }
    38 
    39         private void Form1_Load(object sender, EventArgs e)
    40         {
    41             full_maximize(sender, e);
    42         }
    43 
    44         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    45         {
    46             int hwnd = FindWindow("Shell_TrayWnd", "");
    47             ShowWindow(hwnd, SW_SHOW);
    48         }
    49     }
  • 相关阅读:
    C/C++字符串转换函数;
    MFC CTreeCtrl 递归遍历算法
    汉字转拼音
    Windows之权限讲解
    Ubuntu 保存文件时报E212
    ON_WM_MOUSEWHEEL无响应
    sln、db、opendb、vcxproj、filters、user文件跟踪说明
    iOS 9: UIStackView入门
    Swift语言Storyboard教程:第一部分
    springboot启动项目报错:ERROR:o.s.b.d.LoggingFailureAnalysisReporter解决办法
  • 原文地址:https://www.cnblogs.com/dzone/p/3642143.html
Copyright © 2020-2023  润新知