initialize the main settings settings struct earlier as we'll need it to outside of the dialog

svn path=/trunk/; revision=30242
This commit is contained in:
Ged Murphy 2007-11-07 14:59:43 +00:00
parent 760b14d3cd
commit 53a432f25e
4 changed files with 44 additions and 44 deletions

View file

@ -900,7 +900,8 @@ DisplayDlgProc(HWND hDlg,
static BOOL static BOOL
OnMainCreate(HWND hwnd) OnMainCreate(HWND hwnd,
PRDPSETTINGS pRdpSettings)
{ {
PINFO pInfo; PINFO pInfo;
TCITEM item; TCITEM item;
@ -915,10 +916,8 @@ OnMainCreate(HWND hwnd)
GWLP_USERDATA, GWLP_USERDATA,
(LONG_PTR)pInfo); (LONG_PTR)pInfo);
/* read the default .rdp file */ /* add main settings pointer */
pInfo->pRdpSettings = LoadRdpSettingsFromFile(NULL); pInfo->pRdpSettings = pRdpSettings;
if (!pInfo->pRdpSettings)
return FALSE;
pInfo->hHeader = (HBITMAP)LoadImage(hInst, pInfo->hHeader = (HBITMAP)LoadImage(hInst,
MAKEINTRESOURCE(IDB_HEADER), MAKEINTRESOURCE(IDB_HEADER),
@ -989,7 +988,7 @@ DlgProc(HWND hDlg,
switch(Message) switch(Message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
OnMainCreate(hDlg); OnMainCreate(hDlg, (PRDPSETTINGS)lParam);
break; break;
case WM_COMMAND: case WM_COMMAND:
@ -1064,20 +1063,6 @@ DlgProc(HWND hDlg,
{ {
if (pInfo) if (pInfo)
{ {
if (pInfo->pRdpSettings)
{
if (pInfo->pRdpSettings->pSettings)
{
HeapFree(GetProcessHeap(),
0,
pInfo->pRdpSettings->pSettings);
}
HeapFree(GetProcessHeap(),
0,
pInfo->pRdpSettings);
}
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
pInfo); pInfo);
@ -1096,7 +1081,8 @@ HandleDefaultMessage:
} }
BOOL BOOL
OpenRDPConnectDialog(HINSTANCE hInstance) OpenRDPConnectDialog(HINSTANCE hInstance,
PRDPSETTINGS pRdpSettings)
{ {
INITCOMMONCONTROLSEX iccx; INITCOMMONCONTROLSEX iccx;
@ -1106,8 +1092,9 @@ OpenRDPConnectDialog(HINSTANCE hInstance)
iccx.dwICC = ICC_TAB_CLASSES; iccx.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&iccx); InitCommonControlsEx(&iccx);
return (DialogBox(hInst, return (DialogBoxParam(hInst,
MAKEINTRESOURCE(IDD_CONNECTDIALOG), MAKEINTRESOURCE(IDD_CONNECTDIALOG),
NULL, NULL,
(DLGPROC)DlgProc) == IDOK); (DLGPROC)DlgProc,
pRdpSettings) == IDOK);
} }

View file

@ -17,7 +17,7 @@ typedef struct _RDPSETTINGS
INT NumSettings; INT NumSettings;
} RDPSETTINGS, *PRDPSETTINGS; } RDPSETTINGS, *PRDPSETTINGS;
BOOL OpenRDPConnectDialog(HINSTANCE hInstance, PRDPSETTINGS pRdpSettings);
PRDPSETTINGS LoadRdpSettingsFromFile(LPWSTR lpFile); PRDPSETTINGS LoadRdpSettingsFromFile(LPWSTR lpFile);
BOOL SaveRdpSettingsToFile(LPWSTR lpFile, PRDPSETTINGS pRdpSettings); BOOL SaveRdpSettingsToFile(LPWSTR lpFile, PRDPSETTINGS pRdpSettings);
INT GetIntegerFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue); INT GetIntegerFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue);

View file

@ -74,7 +74,3 @@ ui_set_modifier_state(int code);
#define UI_MAX(a, b) (((a) > (b)) ? (a) : (b)) #define UI_MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef UI_MIN #undef UI_MIN
#define UI_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define UI_MIN(a, b) (((a) < (b)) ? (a) : (b))
/* in connectdialog.c */
BOOL OpenRDPConnectDialog();

View file

@ -23,6 +23,7 @@
#include <winuser.h> #include <winuser.h>
#include <stdio.h> #include <stdio.h>
#include "uimain.h" #include "uimain.h"
#include "todo.h"
#include "resource.h" #include "resource.h"
extern char g_username[]; extern char g_username[];
@ -1290,24 +1291,40 @@ main(int argc, char ** argv)
#else /* WITH_DEBUG */ #else /* WITH_DEBUG */
/*****************************************************************************/ /*****************************************************************************/
int WINAPI int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, WinMain(HINSTANCE hInstance,
LPTSTR lpCmdLine, int nCmdShow) HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{ {
PRDPSETTINGS pRdpSettings;
WSADATA d; WSADATA d;
int ret = 1; int ret = 1;
WSAStartup(MAKEWORD(2, 0), &d); if (WSAStartup(MAKEWORD(2, 0), &d) == 0)
{
pRdpSettings = LoadRdpSettingsFromFile(NULL);
//if (mi_process_cl(lpCmdLine)) if (pRdpSettings)
//{ {
if (OpenRDPConnectDialog(hInstance)) //mi_process_cl(lpCmdLine)
if (OpenRDPConnectDialog(hInstance,
pRdpSettings))
{ {
ui_main(); ui_main();
ret = 0; ret = 0;
} }
//}
HeapFree(GetProcessHeap(),
0,
pRdpSettings->pSettings);
HeapFree(GetProcessHeap(),
0,
pRdpSettings);
}
WSACleanup(); WSACleanup();
}
return ret; return ret;
} }