WinForm


About Per Monitor-DPI aware for WinForms Applications

WinForms is the traditional .NET desktop application workload running on Windows. For historical reasons, there are some problems with its support for high DPI and for different DPI screens, and this article explores the possible solutions. Windows "96" PPI history The default DPI for Windows systems (more precisely called PPI) is 96. PPI means pixel per inch, which means how many pixels are …


C#将窗口最小化到系统托盘,并显示图标和快捷菜单

1. 拖一个notifyIcon和一个contextMenuStrip过来,他们会出现在窗体设计器的最下方: 然后完成你的menu,它暂时会出现在form上,但没关系,运行的时候不会显示。 2. 给notifyIcon设置icon属性,这一步很重要,不然系统托盘处不会有图标。然后将ContextMenuStrip属性设置为刚才的那个快捷菜单。 3. 现在运行程序的时候,任务栏右下角系统托盘处就会有我们的图标和菜单: 4. 现在我们来处理最小化隐藏和还原的问题: 首先要将form的ShowInTaskBar属性设为false,这样它就不会在任务栏中显示。但如果现在最小化,屏幕左下角仍然会有一条细小的标题栏。这里我们需要手工处理一下: 在form的resize事件里这样写: private void frmMain_Resize(object sender, …