是否可以在 Windows 7 中为您的应用保留靠近屏幕边缘的屏幕区域?它的行为类似于 Windows 任务栏(即最大化的窗口不会与其重叠)。
我正在编写一个任务栏应用程序,它可以适本地支持多台显示器。主要目的是在每个屏幕上显示一个任务栏,其中仅包含该屏幕上的应用程序。我所知道的现有解决方案(Ulltramon、DisplayFusion)都不适用于 Win 7,而且都不是开源的。
C# 代码会很好,但也欢迎任何提示。
最佳答案
我觉得回答自己的问题很愚蠢,但多亏了 Michael 的提示,我找到了一个合适的 C# code sample .
using System;
using System.Runtime.InteropServices;
public class WorkArea
{
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="SystemParametersInfoA")]
private static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, IntPtr lpvParam, Int32 fuWinIni);
private const Int32 SPI_SETWORKAREA = 47;
public WorkArea(Int32 Left,Int32 Right,Int32 Top,Int32 Bottom)
{
_WorkArea.Left = Left;
_WorkArea.Top = Top;
_WorkArea.Bottom = Bottom;
_WorkArea.Right = Right;
}
public struct RECT
{
public Int32 Left;
public Int32 Right;
public Int32 Top;
public Int32 Bottom;
}
private RECT _WorkArea;
public void SetWorkingArea()
{
IntPtr ptr = IntPtr.Zero;
ptr = Marshal.AllocHGlobal(Marshal.SizeOf(_WorkArea));
Marshal.StructureToPtr(_WorkArea,ptr,false);
int i = SystemParametersInfo(SPI_SETWORKAREA,0,ptr,0);
}
}
关于c# - 在 Windows 7 中保留屏幕区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/836786/