Author: gedmurphy Date: Wed Nov 7 02:23:25 2007 New Revision: 30232
URL: http://svn.reactos.org/svn/reactos?rev=30232&view=rev Log: - add functionality to save .rdp files - auto add file ip address to dialog - fix various bugs
Modified: trunk/reactos/base/applications/mstsc/connectdialog.c trunk/reactos/base/applications/mstsc/rdpfile.c trunk/reactos/base/applications/mstsc/todo.h
Modified: trunk/reactos/base/applications/mstsc/connectdialog.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/con... ============================================================================== --- trunk/reactos/base/applications/mstsc/connectdialog.c (original) +++ trunk/reactos/base/applications/mstsc/connectdialog.c Wed Nov 7 02:23:25 2007 @@ -84,7 +84,8 @@ HINSTANCE hInst; extern char g_servername[];
-void OnTabWndSelChange(PINFO pInfo) +static VOID +OnTabWndSelChange(PINFO pInfo) { switch (TabCtrl_GetCurSel(pInfo->hTab)) { @@ -100,6 +101,7 @@ break; } } +
static VOID FillServerAddesssCombo(PINFO pInfo) @@ -185,6 +187,8 @@ static VOID GeneralOnInit(PINFO pInfo) { + LPWSTR lpText; + SetWindowPos(pInfo->hGeneralPage, NULL, 15, @@ -225,8 +229,15 @@
FillServerAddesssCombo(pInfo);
- /* add address */ - //GetStringFromSettings(pInfo->pRdpSettings, L"full address"); + /* add file address */ + lpText = GetStringFromSettings(pInfo->pRdpSettings, + L"full address"); + if (lpText) + { + SetDlgItemTextW(pInfo->hGeneralPage, + IDC_SERVERCOMBO, + lpText); + }
}
@@ -252,7 +263,7 @@ switch(LOWORD(wParam)) { case IDC_SAVE: - + SaveRdpSettingsToFile(NULL, pInfo->pRdpSettings); break; }
@@ -276,7 +287,9 @@
static PSETTINGS_ENTRY -GetPossibleSettings(IN LPCTSTR DeviceName, OUT DWORD* pSettingsCount, OUT PSETTINGS_ENTRY* CurrentSettings) +GetPossibleSettings(IN LPCTSTR DeviceName, + OUT DWORD* pSettingsCount, + OUT PSETTINGS_ENTRY* CurrentSettings) { DEVMODE devmode; DWORD NbSettings = 0; @@ -286,7 +299,6 @@ HDC hDC; PSETTINGS_ENTRY Current; DWORD bpp, xres, yres, checkbpp; - DWORD curDispFreq;
/* Get current settings */ *CurrentSettings = NULL; @@ -304,15 +316,12 @@ if (!EnumDisplaySettingsEx(DeviceName, ENUM_CURRENT_SETTINGS, &devmode, dwFlags)) return NULL;
- curDispFreq = devmode.dmDisplayFrequency; - while (EnumDisplaySettingsEx(DeviceName, iMode, &devmode, dwFlags)) { - if ((devmode.dmBitsPerPel==8 || - devmode.dmBitsPerPel==16 || - devmode.dmBitsPerPel==24 || - devmode.dmBitsPerPel==32) && - devmode.dmDisplayFrequency==curDispFreq) + if (devmode.dmBitsPerPel==8 || + devmode.dmBitsPerPel==16 || + devmode.dmBitsPerPel==24 || + devmode.dmBitsPerPel==32) { checkbpp=1; } @@ -335,12 +344,12 @@ Current->dmPelsWidth = devmode.dmPelsWidth; Current->dmPelsHeight = devmode.dmPelsHeight; Current->dmBitsPerPel = devmode.dmBitsPerPel; - while (Next != NULL && ( - Next->dmPelsWidth < Current->dmPelsWidth || - (Next->dmPelsWidth == Current->dmPelsWidth && Next->dmPelsHeight < Current->dmPelsHeight) || - (Next->dmPelsHeight == Current->dmPelsHeight && - Next->dmPelsWidth == Current->dmPelsWidth && - Next->dmBitsPerPel < Current->dmBitsPerPel ))) + while (Next != NULL && + (Next->dmPelsWidth < Current->dmPelsWidth || + (Next->dmPelsWidth == Current->dmPelsWidth && Next->dmPelsHeight < Current->dmPelsHeight) || + (Next->dmPelsHeight == Current->dmPelsHeight && + Next->dmPelsWidth == Current->dmPelsWidth && + Next->dmBitsPerPel < Current->dmBitsPerPel ))) { Previous = Next; Next = Next->Flink; @@ -367,6 +376,7 @@ }
+static BOOL AddDisplayDevice(PINFO pInfo, PDISPLAY_DEVICE DisplayDevice) { PDISPLAY_DEVICE_ENTRY newEntry = NULL; @@ -482,12 +492,20 @@ return FALSE; }
+ static VOID OnResolutionChanged(PINFO pInfo, DWORD position) { TCHAR Buffer[64]; - - if (position == 4) + INT MaxSlider; + + MaxSlider = SendDlgItemMessageW(pInfo->hDisplayPage, + IDC_GEOSLIDER, + TBM_GETRANGEMAX, + 0, + 0); + + if (position == MaxSlider) { LoadString(hInst, IDS_FULLSCREEN, @@ -512,10 +530,10 @@ }
SendDlgItemMessage(pInfo->hDisplayPage, - IDC_SETTINGS_RESOLUTION_TEXT, - WM_SETTEXT, - 0, - (LPARAM)Buffer); + IDC_SETTINGS_RESOLUTION_TEXT, + WM_SETTEXT, + 0, + (LPARAM)Buffer);
}
@@ -529,6 +547,7 @@ DWORD index, i, num; DWORD MaxBpp = 0; UINT HighBpp; + DWORD width, height;
pInfo->CurrentDisplayDevice = pInfo->DisplayDeviceList; /* Update global variable */
@@ -619,18 +638,23 @@ (LPARAM)Buffer); }
- /* FIXME: read from file */ - for (index = 0; index < pInfo->CurrentDisplayDevice->ResolutionsCount; index++) - { - if (pInfo->CurrentDisplayDevice->Resolutions[index].dmPelsWidth == pInfo->CurrentDisplayDevice->CurrentSettings->dmPelsWidth && - pInfo->CurrentDisplayDevice->Resolutions[index].dmPelsHeight == pInfo->CurrentDisplayDevice->CurrentSettings->dmPelsHeight) - { - SendDlgItemMessage(pInfo->hDisplayPage, - IDC_GEOSLIDER, - TBM_SETPOS, - TRUE, - index); - break; + width = GetIntegerFromSettings(pInfo->pRdpSettings, L"desktopwidth"); + height = GetIntegerFromSettings(pInfo->pRdpSettings, L"desktopheight"); + + if (width && height) + { + for (index = 0; index < pInfo->CurrentDisplayDevice->ResolutionsCount; index++) + { + if (pInfo->CurrentDisplayDevice->Resolutions[index].dmPelsWidth == width && + pInfo->CurrentDisplayDevice->Resolutions[index].dmPelsHeight == height) + { + SendDlgItemMessage(pInfo->hDisplayPage, + IDC_GEOSLIDER, + TBM_SETPOS, + TRUE, + index); + break; + } } } }
Modified: trunk/reactos/base/applications/mstsc/rdpfile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/rdp... ============================================================================== --- trunk/reactos/base/applications/mstsc/rdpfile.c (original) +++ trunk/reactos/base/applications/mstsc/rdpfile.c Wed Nov 7 02:23:25 2007 @@ -74,9 +74,40 @@
static BOOL WriteRdpFile(HANDLE hFile, - PSETTINGS pSettings) -{ - + PRDPSETTINGS pRdpSettings) +{ + WCHAR line[MAXKEY + MAXVALUE + 4]; + DWORD BytesToWrite, BytesWritten; + BOOL bRet; + INT i; + + for (i = 0; i < pRdpSettings->NumSettings; i++) + { + if (pRdpSettings->pSettings[i].Type == L'i') + { + _snwprintf(line, MAXKEY + MAXVALUE + 4, L"%s:i:%d\r\n", + pRdpSettings->pSettings[i].Key, + pRdpSettings->pSettings[i].Value.i); + } + else + { + _snwprintf(line, MAXKEY + MAXVALUE + 4, L"%s:s:%s\r\n", + pRdpSettings->pSettings[i].Key, + pRdpSettings->pSettings[i].Value.s); + } + + BytesToWrite = wcslen(line) * sizeof(WCHAR); + + bRet = WriteFile(hFile, + line, + BytesToWrite, + &BytesWritten, + NULL); + if (!bRet || BytesWritten == 0) + return FALSE; + } + + return TRUE; }
@@ -242,12 +273,13 @@ }
-PRDPSETTINGS -LoadRdpSettingsFromFile(LPWSTR lpFile) -{ - PRDPSETTINGS pRdpSettings; +BOOL +SaveRdpSettingsToFile(LPWSTR lpFile, + PRDPSETTINGS pRdpSettings) +{ WCHAR pszPath[MAX_PATH]; HANDLE hFile; + BOOL bRet = FALSE;
/* use default file */ if (lpFile == NULL) @@ -273,6 +305,53 @@
if (lpFile) { + hFile = OpenRdpFile(lpFile, TRUE); + if (hFile) + { + if (WriteRdpFile(hFile, pRdpSettings)) + { + bRet = TRUE; + } + + CloseRdpFile(hFile); + } + } + + return bRet; +} + + +PRDPSETTINGS +LoadRdpSettingsFromFile(LPWSTR lpFile) +{ + PRDPSETTINGS pRdpSettings; + WCHAR pszPath[MAX_PATH]; + HANDLE hFile; + + /* use default file */ + if (lpFile == NULL) + { + HRESULT hr; + LPITEMIDLIST lpidl= NULL; + + hr = SHGetFolderLocation(NULL, + CSIDL_PERSONAL, + NULL, + 0, + &lpidl); + if (hr == S_OK) + { + if (SHGetPathFromIDListW(lpidl, pszPath)) + { + wcscat(pszPath, L"\Default.rdp"); + lpFile = pszPath; + CoTaskMemFree(lpidl); + } + } + } + + if (lpFile) + { LPWSTR lpBuffer = NULL;
pRdpSettings = HeapAlloc(GetProcessHeap(),
Modified: trunk/reactos/base/applications/mstsc/todo.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/tod... ============================================================================== --- trunk/reactos/base/applications/mstsc/todo.h (original) +++ trunk/reactos/base/applications/mstsc/todo.h Wed Nov 7 02:23:25 2007 @@ -19,5 +19,6 @@
PRDPSETTINGS LoadRdpSettingsFromFile(LPWSTR lpFile); +BOOL SaveRdpSettingsToFile(LPWSTR lpFile, PRDPSETTINGS pRdpSettings); INT GetIntegerFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue); LPWSTR GetStringFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue);