Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

c# - Reserve screen area in Windows 7

Is it possible to reserve a screen area near an edge of the screen for your app in Windows 7? It would behave similar to the Windows taskbar (i.e. maximized windows would not overlap with it).

I'm writing a taskbar app with proper support for multiple monitors. The primary purpose is to show a taskbar on each screen containing only the apps on that screen. None of the existing solutions (Ulltramon, DisplayFusion) I know of work for Win 7, and none are open source.

C# code would be nice, but any hints are appreciated as well.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I feel silly answering my own question, but thanks to Michael's hint, I found an appropriate 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);
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...