diff --git a/reactos/base/applications/mstsc/connectdialog.c b/reactos/base/applications/mstsc/connectdialog.c index bcb1b9368ef..f408b153496 100644 --- a/reactos/base/applications/mstsc/connectdialog.c +++ b/reactos/base/applications/mstsc/connectdialog.c @@ -900,7 +900,8 @@ DisplayDlgProc(HWND hDlg, static BOOL -OnMainCreate(HWND hwnd) +OnMainCreate(HWND hwnd, + PRDPSETTINGS pRdpSettings) { PINFO pInfo; TCITEM item; @@ -915,10 +916,8 @@ OnMainCreate(HWND hwnd) GWLP_USERDATA, (LONG_PTR)pInfo); - /* read the default .rdp file */ - pInfo->pRdpSettings = LoadRdpSettingsFromFile(NULL); - if (!pInfo->pRdpSettings) - return FALSE; + /* add main settings pointer */ + pInfo->pRdpSettings = pRdpSettings; pInfo->hHeader = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_HEADER), @@ -989,7 +988,7 @@ DlgProc(HWND hDlg, switch(Message) { case WM_INITDIALOG: - OnMainCreate(hDlg); + OnMainCreate(hDlg, (PRDPSETTINGS)lParam); break; case WM_COMMAND: @@ -1064,20 +1063,6 @@ DlgProc(HWND hDlg, { if (pInfo) { - if (pInfo->pRdpSettings) - { - if (pInfo->pRdpSettings->pSettings) - { - HeapFree(GetProcessHeap(), - 0, - pInfo->pRdpSettings->pSettings); - } - - HeapFree(GetProcessHeap(), - 0, - pInfo->pRdpSettings); - } - HeapFree(GetProcessHeap(), 0, pInfo); @@ -1096,7 +1081,8 @@ HandleDefaultMessage: } BOOL -OpenRDPConnectDialog(HINSTANCE hInstance) +OpenRDPConnectDialog(HINSTANCE hInstance, + PRDPSETTINGS pRdpSettings) { INITCOMMONCONTROLSEX iccx; @@ -1106,8 +1092,9 @@ OpenRDPConnectDialog(HINSTANCE hInstance) iccx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&iccx); - return (DialogBox(hInst, - MAKEINTRESOURCE(IDD_CONNECTDIALOG), - NULL, - (DLGPROC)DlgProc) == IDOK); + return (DialogBoxParam(hInst, + MAKEINTRESOURCE(IDD_CONNECTDIALOG), + NULL, + (DLGPROC)DlgProc, + pRdpSettings) == IDOK); } diff --git a/reactos/base/applications/mstsc/todo.h b/reactos/base/applications/mstsc/todo.h index 5e83cf894c1..14f07745a18 100644 --- a/reactos/base/applications/mstsc/todo.h +++ b/reactos/base/applications/mstsc/todo.h @@ -17,7 +17,7 @@ typedef struct _RDPSETTINGS INT NumSettings; } RDPSETTINGS, *PRDPSETTINGS; - +BOOL OpenRDPConnectDialog(HINSTANCE hInstance, PRDPSETTINGS pRdpSettings); PRDPSETTINGS LoadRdpSettingsFromFile(LPWSTR lpFile); BOOL SaveRdpSettingsToFile(LPWSTR lpFile, PRDPSETTINGS pRdpSettings); INT GetIntegerFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue); diff --git a/reactos/base/applications/mstsc/uimain.h b/reactos/base/applications/mstsc/uimain.h index 09e3cb33c20..7b979fe7215 100644 --- a/reactos/base/applications/mstsc/uimain.h +++ b/reactos/base/applications/mstsc/uimain.h @@ -74,7 +74,3 @@ ui_set_modifier_state(int code); #define UI_MAX(a, b) (((a) > (b)) ? (a) : (b)) #undef UI_MIN #define UI_MIN(a, b) (((a) < (b)) ? (a) : (b)) - -/* in connectdialog.c */ -BOOL OpenRDPConnectDialog(); - diff --git a/reactos/base/applications/mstsc/win32.c b/reactos/base/applications/mstsc/win32.c index 89de484363f..5aa1ef11fb1 100644 --- a/reactos/base/applications/mstsc/win32.c +++ b/reactos/base/applications/mstsc/win32.c @@ -23,6 +23,7 @@ #include #include #include "uimain.h" +#include "todo.h" #include "resource.h" extern char g_username[]; @@ -1290,24 +1291,40 @@ main(int argc, char ** argv) #else /* WITH_DEBUG */ /*****************************************************************************/ int WINAPI -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, int nCmdShow) +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) { - WSADATA d; - int ret = 1; + PRDPSETTINGS pRdpSettings; + WSADATA d; + int ret = 1; - WSAStartup(MAKEWORD(2, 0), &d); + if (WSAStartup(MAKEWORD(2, 0), &d) == 0) + { + pRdpSettings = LoadRdpSettingsFromFile(NULL); - //if (mi_process_cl(lpCmdLine)) - //{ - if (OpenRDPConnectDialog(hInstance)) - { - ui_main(); - ret = 0; - } - //} + if (pRdpSettings) + { + //mi_process_cl(lpCmdLine) + if (OpenRDPConnectDialog(hInstance, + pRdpSettings)) + { + ui_main(); + ret = 0; + } - WSACleanup(); + HeapFree(GetProcessHeap(), + 0, + pRdpSettings->pSettings); + + HeapFree(GetProcessHeap(), + 0, + pRdpSettings); + } + + WSACleanup(); + } return ret; }