当我只使用MoveWindow
函数一次时,它工作正常。 e.g
MoveWindow(handles[tempIndex + 1], x, 0, cx, cy, true);
但是当我把它放在一个循环中以移动许多窗口时,它会并排移动所有窗口但是在该边框之后重新调整大小(使用鼠标)是禁用的。当我将鼠标悬停在窗口的边框上时,当我按住鼠标左键并尝试移动边框然后它不移动并且看起来边框是固定的并且不可调整大小时,会出现重新调整大小的图标。这是我的代码
private void resizeToolStripMenuItem_Click(object sender, EventArgs e){
EnumWindows(new EnumWindowsProc(EnumTheWindows), IntPtr.Zero);
int width = 1366 / size;
int x = 0;
for (int i = 0; i < size; i++)
{
MoveWindow(handles[i], x, 0, width, 775, true);
UpdateWindow(handles[i]);
x = x + width + 1;
}
}
protected static bool EnumTheWindows(IntPtr hWnd, IntPtr lParam)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
RECT rct = new RECT();
placement.length = Marshal.SizeOf(placement);
int size1 = GetWindowTextLength(hWnd);
GetWindowPlacement(hWnd, ref placement);
if (size1++ > 0 && IsWindowVisible(hWnd))
{
if (!IsIconic(hWnd))
{
StringBuilder sb = new StringBuilder(size1);
GetWindowText(hWnd, sb, size1);
if (sb.ToString() != "DataCardMonitor" && sb.ToString() != "Program Manager")
{
MessageBox.Show(sb.ToString());
handles[tempHandle] = hWnd;
GetWindowRect(hWnd, ref rct);
rect[tempHandle] = rct;
tempHandle++;
size++;
}
}
}
return true;
}
为什么会这样?那有什么工作吗?