2012-11-11 17 views
0

我使用遠程桌面將Windows XP Professional SP3筆記本電腦和一個屏幕連接到運行帶有兩個顯示器的Windows 7 Professional的遠程PC。遠程桌面會話後,窗口大小/位置發生了更改

筆記本電腦的分辨率約爲1024x768,而遠程PC上的每個顯示器大約爲1600x900。

在開始遠程桌面會話之前,我將Windows 7 PC的第二臺顯示器上的所有窗口移動到第一臺顯示器。 (筆記本電腦和PC都在同一個辦公區域內)。

遠程桌面會話工作正常,但在筆記本電腦上關閉會話並返回到遠程Windows 7 PC上工作後,我通常必須重新定位並調整大小的窗戶回到原來的安排。

用我目前的配置,我該如何避免上面的「重新定位和調整大小」步驟?

如果筆記本電腦有Windows 7專業版,那有助於解決這個問題嗎?

回答

0

您應該將其移至超級用戶,但由於您在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); 
} 

其中EnumWindowsSetWindowPosGetWindowRect都是Win32函數。參見: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx

相關問題