我使用远程桌面从一台装有Windows XP专业版SP3和一个屏幕的笔记本电脑连接到一台运行Windows7专业版并带有两个显示器的远程PC。
笔记本电脑的分辨率约为1024x768,远程PC上的每个显示器的分辨率约为1600x900。
在开始远程桌面会话之前,我将windows 7 PC第二台显示器上的所有窗口移到第一台显示器上。(笔记本电脑和PC都在同一办公区。)
远程桌面会话可以工作,但在关闭笔记本电脑上的会话并返回到远程Windows 7 PC上工作后,我通常必须重新定位和调整许多窗口的大小才能恢复到原始排列。
使用我当前的配置,我如何避免上面的“重新定位和调整大小”步骤?
如果笔记本电脑安装了Windows7专业版,这是否有助于解决这个问题?
发布于 2012-11-11 11:24:21
您可能应该将其移动到超级用户,但既然您在StackOverflow上请求,您可以实现一个程序来执行您所描述的操作。
在伪代码中:
class WindowPosition {
IntPtr hWnd;
RECT Location;
}
List<WindowPosition> positions = null;
void OnCaptureWindowPositionHotkey() {
positions = new List<WindowPosition>();
EnumWindows(enumStoreWindows, null);
}
void OnResetWindowPositionHotkey() {
EnumWindows(enumStoreWindows, null);
}
void enumSetWindows(IntPtr hwnd, IntPtr obj) {
positions.Add(new WindowPosition() {
hWnd = hwnd,
Location = GetWndLocation(hwnd)
};
}
RECT GetWndLocation(IntPtr hwnd) {
RECT outrect = null;
GetWindowRect(hwnd, out outrect);
return outrect;
}
void enumSetWindows(IntPtr hwnd, IntPtr obj) {
var loc = (from wl in positions
where wl.hWnd == hwnd
select wl).FirstOrDefault();
if (loc == null) return;
SetWindowPos(hwnd, null,
loc.Location.X,
loc.Location.Y,
loc.Location.Width,
loc.Location.Height,
0);
}其中EnumWindows、SetWindowPos和GetWindowRect都是Win32函数。请参阅:http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx、http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx和http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx。
https://stackoverflow.com/questions/13328222
复制相似问题