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
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);
}

View file

@ -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);

View file

@ -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();

View file

@ -23,6 +23,7 @@
#include <winuser.h>
#include <stdio.h>
#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;
}