C#實(shí)現(xiàn)窗體全屏的兩種方法
本文為大家分享了C#實(shí)現(xiàn)窗體全屏的具體代碼,供大家參考,具體內(nèi)容如下
方法一:不過此方法有時(shí)候會出現(xiàn)莫名的bug
//程序啟動(dòng)路徑,與生成程序的exe文件在同一目錄下 public String exePath = Application.StartupPath; //定義窗體寬高 int screenWidth = 0; int screenHeight = 0; screenWidth = (int)System.Windows.SystemParameters.PrimaryScreenWidth; screenHeight = (int)System.Windows.SystemParameters.PrimaryScreenHeight; // 設(shè)置全屏 this.FormBorderStyle = FormBorderStyle.None; //設(shè)置窗體為無邊框樣式 this.WindowState = FormWindowState.Maximized; //最大化窗體 this.Left = 0; this.Top = 0; this.Width = screenWidth; this.Height = screenHeight; //窗體背景圖 this.BackgroundImage = Image.FromFile(exePath + "文件名");
方法二:
//程序啟動(dòng)路徑,與生成程序的exe文件在同一目錄下 public String exePath = Application.StartupPath; //窗口左上角位置 public Point m_formAutographShowPos; //設(shè)置窗體尺寸 this.Width = (int)System.Windows.SystemParameters.PrimaryScreenWidth; this.Height = (int)System.Windows.SystemParameters.PrimaryScreenHeight; this.ClientSize = new System.Drawing.Size(Width, Height); //計(jì)算初始位置 m_formAutographShowPos.X = 0; m_formAutographShowPos.Y = 0; Location = m_formAutographShowPos; //窗體背景圖 this.BackgroundImage = Image.FromFile(exePath + "文件名");
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C# 復(fù)制指定節(jié)點(diǎn)的所有子孫節(jié)點(diǎn)到新建的節(jié)點(diǎn)下
這篇文章主要介紹了C# 復(fù)制指定節(jié)點(diǎn)的所有子孫節(jié)點(diǎn)到新建的節(jié)點(diǎn)下的相關(guān)資料,非常不錯(cuò)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2016-10-10c#中WebService的介紹及調(diào)用方式小結(jié)
這篇文章主要給大家介紹了關(guān)于c#中的WebService及其調(diào)用方式的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-11-11C#實(shí)現(xiàn)圖形區(qū)域組合操作的方法
這篇文章主要介紹了C#實(shí)現(xiàn)圖形區(qū)域組合操作的方法,涉及C#操作圖片實(shí)現(xiàn)組合操作的相關(guān)技巧,需要的朋友可以參考下2015-06-06C#實(shí)現(xiàn)DataTable數(shù)據(jù)行列轉(zhuǎn)換
這篇文章介紹了C#實(shí)現(xiàn)DataTable數(shù)據(jù)行列轉(zhuǎn)換的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04C#?SetWindowPos函數(shù)實(shí)例詳解
在C#中,SetWindowPos函數(shù)用于設(shè)置窗口的位置和大小,這篇文章主要介紹了C#?SetWindowPos函數(shù)實(shí)例詳解,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2024-03-03C#使用RegNotifyChangeKeyValue監(jiān)聽注冊表更改的方法小結(jié)
RegNotifyChangeKeyValue的最后一個(gè)參數(shù)傳遞false,表示以同步的方式監(jiān)聽,這篇文章主要介紹了C#使用RegNotifyChangeKeyValue監(jiān)聽注冊表更改的方法小結(jié),需要的朋友可以參考下2024-06-06