以编程方式最大化屏幕一半的窗口

问题描述 投票:7回答:3

我想最大化屏幕左侧的随机窗口。我可以在代码中使用Windows Aero功能吗?这个窗口可以像鼠标一样最大化。我只是想以编程方式做到这一点。

我使用C#,我可以得到窗口的IntPtr

如果可能,不用伪造鼠标或键盘输入。

c# windows winapi aero
3个回答
5
投票

这可以在没有p / invoke的情况下完成。

试试这个:

Rectangle rect = Screen.PrimaryScreen.WorkingArea;
rect.Width = rect.Width / 2;
Bounds = rect;

这会将当前窗口置于主屏幕的左侧。

然后只需将其添加到屏幕右侧即可。

Location = new Point(rect.Width, 0);

3
投票

它不完全一样,但它很好用:

ShowWindow(handle, SW_MAXIMIZE);
// for a split second you might see a maximized window here
MoveWindow(handle, 0, 0, Screen.PrimaryScreen.WorkingArea.Width / 2, Screen.PrimaryScreen.WorkingArea.Height, true);

0
投票

将需要繁重的提升实时安置,特别是对于非子进程。示例 - www.ishadow.com/vdm。对于手动“修复”最大化窗口位置MoveWindow(hWnd,startPos,0,winWidth,winHeight,true)经常在ShowWindow(hWnd,SW_MAXIMIZE)之后(在Windows 10上尝试任务管理器)如上所述。

© www.soinside.com 2019 - 2024. All rights reserved.