我可以用這種方法級聯所有視窗嗎
[DllImport("user32.dll")]
public static extern ushort CascadeWindows(
HWND hwndParent,
uint wHow,
ref RECT lpRect,
uint cKids,
ref HWND lpKids
);
但除了呼叫該方法的當前視窗(或我有 HWND 的視窗)?
CascadeWindows(NULL, MDITILE_ZORDER, NULL, 0, NULL); // "Cascade windows"
編輯: 我試過了,但它只移動了主視窗而不是所有其他視窗:
Rectangle rect = new Rectangle(0, 0, 1740, 1010);
var arrayRange = Process.GetProcesses()
.Where(x =>
!string.IsNullOrEmpty(x.MainWindowTitle) &&
!x.MainWindowTitle.Contains("Main Window")
)
.Select(x => x.Handle).ToArray();
user32.CascadeWindows(nullptr, 0, ref rect, 0, ref arrayRange); // "Cascade windows"
并且還更正了函式宣告
[DllImport("user32.dll")] public static extern ushort CascadeWindows( IntPtr hwndParent, uint wHow, ref Rectangle lpRect, uint cKids, IntPtr[] lpKids);
uj5u.com熱心網友回復:
使用 C# 可以這樣做:
var arrayRange = Process.GetProcesses()
.Where(x =>
!string.IsNullOrEmpty(x.MainWindowTitle) &&
!x.MainWindowTitle.Contains("MainWindow")
);
//.Select(x => x.Handle).ToArray();
int X = 25; int Y = 25;
foreach (var proc in arrayRange)
{
//DLL Import user32.dll
user32.MoveWindow(proc.MainWindowHandle, X, Y, 335, 335, 1);
X = 18; Y = 18;
}
我相信 C/C 中有一個選項可以對來自 user32.DLL 的行程句柄和 MoveWindow 執行相同的操作。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/428302.html
