C# 为什么MoveWindow函数在循环中使用时禁用边框大小调整?
当我只使用一次C# 为什么MoveWindow函数在循环中使用时禁用边框大小调整?,c#,winapi,pinvoke,C#,Winapi,Pinvoke,当我只使用一次MoveWindow功能时,它就可以正常工作了。e、 g MoveWindow(handles[tempIndex + 1], x, 0, cx, cy, true); 但当我把它放在一个循环中移动许多窗口时,它会将所有窗口并排移动,但在这之后,边界重新调整(使用鼠标)被禁用。当我将鼠标悬停在窗口的边框上时,当我按住鼠标左键并尝试移动边框时,会出现“重新调整大小”图标,但边框不会移动,并且边框似乎是固定的,无法调整大小。这是我的代码 private void resizeToo
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;
}
private void resizeToolStripMenuItem\u单击(对象发送方,事件参数e){
EnumWindows(新的EnumWindowsProc(EnumTheWindows),IntPtr.Zero);
内部宽度=1366/尺寸;
int x=0;
对于(int i=0;i0&&IsWindowVisible(hWnd))
{
如果(!二次曲线(hWnd))
{
StringBuilder sb=新的StringBuilder(尺寸1);
GetWindowText(hWnd、sb、size1);
if(sb.ToString()!=“DataCardMonitor”和&sb.ToString()!=“Program Manager”)
{
Show(sb.ToString());
句柄[tempHandle]=hWnd;
GetWindowRect(hWnd,参考rct);
rect[tempHandle]=rct;
tempHandle++;
大小++;
}
}
}
返回true;
}
为什么会这样?这方面有什么办法吗 这些是谁的窗口?仅供参考,我认为没有必要更新windows。如果MoveWindow的最后一个参数为true,则重新定位后会向窗口发送绘制消息。UpdateWindow发送相同的事件消息。您正在请求窗口重新绘制两次。重新定位许多窗口是为此而发明的。@DavidHeffernan这些窗口不属于我的程序。这些只是桌面上显示的窗口。我只是把它们放在桌面上。