Fix: Window manager view check reads stale state after restore

The window manager's "view" action checks the window state against the
ItemData.Data[2] field populated when the list was built. The right-click
show/hide/maximize/minimize handlers updated only the list control's display
text via SetItemText, leaving Data[2] stale. After restoring a minimized
window, viewing still reported "该窗口已最小化" until the dialog was reopened.

Sync Data[2] alongside SetItemText in all four handlers so the view check and
the status-column sort both see the current state.

Co-Authored-By: deepseek-v4-pro
This commit is contained in:
yuanyuanxiang
2026-08-26 21:24:07 +02:00
parent d55d40e7a2
commit d99122b25f

View File

@@ -541,6 +541,7 @@ void CSystemDlg::OnWlistHide()
lpMsgBuf[0]=CMD_WINDOW_TEST; //窗口处理数据头
DWORD hwnd = data->ID; //得到窗口的句柄一同发送
pListCtrl->SetItemText(nItem,2,"hidden"); //注意这时将列表中的显示状态为"隐藏"
data->Data[2] = "hidden"; // 同步 ItemData避免查看/排序读到旧状态
//这样在删除列表条目时就不删除该项了 如果删除该项窗口句柄会丢失 就永远也不能显示了
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD)); //得到窗口的句柄一同发送
DWORD dHow=SW_HIDE; //窗口处理参数 0
@@ -564,6 +565,7 @@ void CSystemDlg::OnWlistRecover()
lpMsgBuf[0]= CMD_WINDOW_TEST;
DWORD hwnd = data->ID;
pListCtrl->SetItemText(nItem,2,"normal");
data->Data[2] = "normal"; // 同步 ItemData避免查看/排序读到旧状态
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
DWORD dHow=SW_NORMAL;
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
@@ -586,6 +588,7 @@ void CSystemDlg::OnWlistMax()
lpMsgBuf[0]= CMD_WINDOW_TEST;
DWORD hwnd = data->ID;
pListCtrl->SetItemText(nItem,2,"maximized");
data->Data[2] = "maximized"; // 同步 ItemData避免查看/排序读到旧状态
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
DWORD dHow=SW_MAXIMIZE;
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
@@ -608,6 +611,7 @@ void CSystemDlg::OnWlistMin()
lpMsgBuf[0]= CMD_WINDOW_TEST;
DWORD hwnd = data->ID;
pListCtrl->SetItemText(nItem,2,"minimized");
data->Data[2] = "minimized"; // 同步 ItemData避免查看/排序读到旧状态
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
DWORD dHow=SW_MINIMIZE;
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));