SessionDialog.cpp 19.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
//  Copyright (C) 2002 Ultr@VNC Team Members. All Rights Reserved.
//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
//
//  This file is part of the VNC system.
//
//  The VNC system is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
//  USA.
//
// If the source code for the VNC system is not available from the place 
// whence you received this file, check http://www.uk.research.att.com/vnc or contact
// the authors on vnc@uk.research.att.com for information on obtaining it.


// SessionDialog.cpp: implementation of the SessionDialog class.

#include "stdhdrs.h"
#include "vncviewer.h"
#include "SessionDialog.h"
#include "Exception.h"

#define SESSION_MRU_KEY_NAME _T("Software\\ORL\\VNCviewer\\MRU")
#define NUM_MRU_ENTRIES 8

extern char sz_F1[64];
extern char sz_F2[64];
extern char sz_F3[64];
extern char sz_F4[64];
extern char sz_F5[128];
extern char sz_F6[64];
extern char sz_F7[128];
extern char sz_F8[128];
extern char sz_F9[64];
extern char sz_F10[64];
extern char sz_F11[64];

SessionDialog::SessionDialog(VNCOptions *pOpt, ClientConnection* pCC, CDSMPlugin* pDSMPlugin)
{
	m_pCC = pCC;
	m_pOpt = pOpt;
    //AaronP
//	m_pMRU = new MRU(SESSION_MRU_KEY_NAME);
	m_pMRU = new MRU(SESSION_MRU_KEY_NAME,26);
	//EndAaronP
	m_pDSMPlugin = pDSMPlugin;
}

SessionDialog::~SessionDialog()
{
    delete m_pMRU;
}

// It's exceedingly unlikely, but possible, that if two modal dialogs were
// closed at the same time, the static variables used for transfer between 
// window procedure and this method could overwrite each other.
int SessionDialog::DoDialog()
{
 	return DialogBoxParam(pApp->m_instance, DIALOG_MAKEINTRESOURCE(IDD_SESSION_DLG), 
		NULL, (DLGPROC) SessDlgProc, (LONG) this);
}

BOOL CALLBACK SessionDialog::SessDlgProc(  HWND hwnd,  UINT uMsg,  WPARAM wParam, LPARAM lParam ) {
	// This is a static method, so we don't know which instantiation we're 
	// dealing with. But we can get a pseudo-this from the parameter to 
	// WM_INITDIALOG, which we therafter store with the window and retrieve
	// as follows:
#ifndef _X64
	SessionDialog *_this = (SessionDialog *) GetWindowLong(hwnd, GWL_USERDATA);
#else
	SessionDialog *_this = (SessionDialog *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
#endif

	switch (uMsg) {

	case WM_INITDIALOG:
		{
#ifndef _X64
            SetWindowLong(hwnd, GWL_USERDATA, lParam);
#else
			SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
#endif
            SessionDialog *_this = (SessionDialog *) lParam;
            CentreWindow(hwnd);
			SetForegroundWindow(hwnd);
			_this->m_pCC->m_hSessionDialog = hwnd;

            // Set up recently-used list
            HWND hcombo = GetDlgItem(  hwnd, IDC_HOSTNAME_EDIT);
            TCHAR valname[256];

            for (int i = 0; i < _this->m_pMRU->NumItems(); i++) {
                _this->m_pMRU->GetItem(i, valname, 255);
                int pos = SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM) valname);

            }
            SendMessage(hcombo, CB_SETCURSEL, 0, 0);

			// sf@2002 - List available DSM Plugins
			HWND hPlugins = GetDlgItem(hwnd, IDC_PLUGINS_COMBO);
			int nPlugins = _this->m_pDSMPlugin->ListPlugins(hPlugins);
			if (!nPlugins)
			{
				SendMessage(hPlugins, CB_ADDSTRING, 0, (LPARAM) sz_F11);
			}
			else
			{
				// Use the first detected plugin, so the user doesn't have to check the option
				// HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
				// SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
			}
			SendMessage(hPlugins, CB_SETCURSEL, 0, 0);

			//AaronP
			if( strcmp( _this->m_pOpt->m_szDSMPluginFilename, "" ) != 0 && _this->m_pOpt->m_fUseDSMPlugin ) { 
				int pos = SendMessage(hPlugins, CB_FINDSTRINGEXACT, -1,
					(LPARAM)&(_this->m_pOpt->m_szDSMPluginFilename[0]));

				if( pos != CB_ERR ) {
					SendMessage(hPlugins, CB_SETCURSEL, pos, 0);
					HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
					SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
				}
			}
			//EndAaronP

			TCHAR tmphost[256];
			TCHAR tmphost2[256];
			_tcscpy(tmphost, _this->m_pOpt->m_proxyhost);
			if (strcmp(tmphost,"")!=NULL)
			{
			_tcscat(tmphost,":");
			_tcscat(tmphost,_itoa(_this->m_pOpt->m_proxyport,tmphost2,10));
			SetDlgItemText(hwnd, IDC_PROXY_EDIT, tmphost);
			}

			HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
			SendMessage(hViewOnly, BM_SETCHECK, _this->m_pOpt->m_ViewOnly, 0);

			HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
			SendMessage(hAutoScaling, BM_SETCHECK, _this->m_pOpt->m_fAutoScaling, 0);

			HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
			SendMessage(hExitCheck, BM_SETCHECK, _this->m_pOpt->m_fExitCheck, 0); //PGM @ Advantig

			HWND hProxy = GetDlgItem(hwnd, IDC_PROXY_CHECK);
			SendMessage(hProxy, BM_SETCHECK, _this->m_pOpt->m_fUseProxy, 0);


			// sf@2005 - Make the save settings optional but always enabled by default (for now)
			// (maybe disabled as default is better ?)
			HWND hSave = GetDlgItem(hwnd, IDC_SETDEFAULT_CHECK);
//ACT			SendMessage(hSave, BM_SETCHECK, true, 0);


			// sf@2002 - Select Modem Option as default
			_this->SetQuickOption(_this, hwnd);

			_this->m_fFromOptions = false;
			_this->m_fFromFile = false;

            return TRUE;
		}

	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
	    case IDC_DELETE:
			{
				char optionfile[MAX_PATH];
				char *tempvar=NULL;
				tempvar = getenv( "TEMP" );
				if (tempvar) strcpy(optionfile,tempvar);
				else strcpy(optionfile,"");
				strcat(optionfile,"\\options.vnc");
				DeleteFile(optionfile);
			}
			return TRUE;

		case IDOK:
			{
            TCHAR tmphost[256];
            TCHAR display[256];
            TCHAR fulldisplay[256];

			// sf@2005
			HWND hSave = GetDlgItem(hwnd, IDC_SETDEFAULT_CHECK);
			_this->m_pCC->saved_set = SendMessage(hSave, BM_GETCHECK, 0, 0) == BST_CHECKED;

			GetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, display, 256);
            _tcscpy(fulldisplay, display);
            if (!ParseDisplay(display, tmphost, 255, &_this->m_port)) {
                MessageBox(NULL, 
                    sz_F8, 
                    sz_F10, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
            } else {
                _tcscpy(_this->m_host_dialog, tmphost);
				_this->m_pMRU->AddItem(fulldisplay);
//				_tcscpy(_this->m_remotehost, fulldisplay);
                EndDialog(hwnd, TRUE);
            }

			GetDlgItemText(hwnd, IDC_PROXY_EDIT, display, 256);
            _tcscpy(fulldisplay, display);
            if (!ParseDisplay(display, tmphost, 255, &_this->m_proxyport)) {
                MessageBox(NULL, 
                    sz_F8, 
                    sz_F10, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
            } else {
                _tcscpy(_this->m_proxyhost, tmphost);
                EndDialog(hwnd, TRUE);
            }

			HWND hProxy = GetDlgItem(hwnd, IDC_PROXY_CHECK);
			if (SendMessage(hProxy, BM_GETCHECK, 0, 0) == BST_CHECKED)
			{
				_this->m_pOpt->m_fUseProxy = true;
				_this->m_fUseProxy = true;
			}
			else 
			{
				_this->m_pOpt->m_fUseProxy = false;
				_this->m_fUseProxy = false;
			}

			// sf@2002 - DSMPlugin loading
			// If Use plugin is checked, load the plugin if necessary
			HWND hPlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
			if (SendMessage(hPlugin, BM_GETCHECK, 0, 0) == BST_CHECKED)
			{
				TCHAR szPlugin[MAX_PATH];
				GetDlgItemText(hwnd, IDC_PLUGINS_COMBO, szPlugin, MAX_PATH);
				_this->m_pOpt->m_fUseDSMPlugin = true;
				strcpy(_this->m_pOpt->m_szDSMPluginFilename, szPlugin);

				if (!_this->m_pDSMPlugin->IsLoaded())
				{
					_this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening);
					if (_this->m_pDSMPlugin->IsLoaded())
					{
						if (_this->m_pDSMPlugin->InitPlugin())
						{
							_this->m_pDSMPlugin->SetEnabled(true);
							_this->m_pDSMPlugin->DescribePlugin();
						}
						else
						{
							_this->m_pDSMPlugin->SetEnabled(false);
							MessageBox(NULL, 
							sz_F7, 
							sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
							return TRUE;
						}
					}
					else
					{
						_this->m_pDSMPlugin->SetEnabled(false);
						MessageBox(NULL, 
							sz_F5, 
							sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
						return TRUE;
					}
				}
				else
				{
					// sf@2003 - If the plugin is already loaded here it has been loaded
					// by clicking on the config button: we need to init it !
					// But we must first check that the loaded plugin is the same that 
					// the one currently selected...
					_this->m_pDSMPlugin->DescribePlugin();
					if (_stricmp(_this->m_pDSMPlugin->GetPluginFileName(), szPlugin))
					{
						// Unload the previous plugin
						_this->m_pDSMPlugin->UnloadPlugin();
						// Load the new selected one
						_this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening);
					}

					if (_this->m_pDSMPlugin->IsLoaded())
					{
						if (_this->m_pDSMPlugin->InitPlugin())
						{
							_this->m_pDSMPlugin->SetEnabled(true);
							_this->m_pDSMPlugin->DescribePlugin();
						}
						else
						{
							_this->m_pDSMPlugin->SetEnabled(false);
							MessageBox(NULL, 
							sz_F7, 
							sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
							return TRUE;
						}
					}
					else
					{
						_this->m_pDSMPlugin->SetEnabled(false);
						MessageBox(NULL, 
							sz_F5, 
							sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
						return TRUE;
					}
				}
			}
			else // If Use plugin unchecked but the plugin is loaded, unload it
			{
				_this->m_pOpt->m_fUseDSMPlugin = false;
				if (_this->m_pDSMPlugin->IsEnabled())
				{
					_this->m_pDSMPlugin->UnloadPlugin();
					_this->m_pDSMPlugin->SetEnabled(false);
				}
			}

			if (_this->m_fFromOptions || _this->m_fFromFile)
			{
				EndDialog(hwnd, TRUE);
				return TRUE;
			}

			// sf@2002 - Quick options handling
			_this->ManageQuickOptions(_this, hwnd);

			HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
			_this->m_pOpt->m_ViewOnly = (SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);

			HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
			_this->m_pOpt->m_fAutoScaling = (SendMessage(hAutoScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);

			HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
			_this->m_pOpt->m_fExitCheck = (SendMessage(hExitCheck, BM_GETCHECK, 0, 0) == BST_CHECKED); //PGM @ Advantig

			EndDialog(hwnd, TRUE);
			return TRUE;
			}

		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return TRUE;

		case IDC_OPTIONBUTTON:
			{
				if (!_this->m_fFromFile)
				{
					_this->ManageQuickOptions(_this, hwnd);					

					HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
					_this->m_pOpt->m_ViewOnly = (SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);
					
					HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
					_this->m_pOpt->m_fAutoScaling = (SendMessage(hAutoScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);

					HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
					_this->m_pOpt->m_fExitCheck = (SendMessage(hExitCheck, BM_GETCHECK, 0, 0) == BST_CHECKED); //PGM @ Advantig

				}
				
				_this->m_pOpt->DoDialog();
				_this->m_fFromOptions = true;
				
				return TRUE;
			}

		// sf@2002 
		case IDC_PLUGIN_CHECK:
			{
				HWND hUse = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
				BOOL enable = SendMessage(hUse, BM_GETCHECK, 0, 0) == BST_CHECKED;
				HWND hButton = GetDlgItem(hwnd, IDC_PLUGIN_BUTTON);
				EnableWindow(hButton, enable);
			}
			return TRUE;


		case IDC_PLUGIN_BUTTON:
			{
			HWND hPlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
			if (SendMessage(hPlugin, BM_GETCHECK, 0, 0) == BST_CHECKED)
			{
				TCHAR szPlugin[MAX_PATH];
				GetDlgItemText(hwnd, IDC_PLUGINS_COMBO, szPlugin, MAX_PATH);
				// sf@2003 - The config button can be clicked several times with 
				// different selected plugins...
				bool fLoadIt = true;
				char szParams[32];
				strcpy(szParams, sz_F4);
				// If a plugin is already loaded, check if it is the same that the one 
				// we want to load.
				if (_this->m_pDSMPlugin->IsLoaded())
				{
					_this->m_pDSMPlugin->DescribePlugin();
					if (!_stricmp(_this->m_pDSMPlugin->GetPluginFileName(), szPlugin))
					{
						fLoadIt = false;
						_this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
					}
					else
					{
						// Unload the previous plugin
						_this->m_pDSMPlugin->UnloadPlugin();
						fLoadIt = true;
					}
				}

				if (!fLoadIt) return TRUE;

				if (_this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening))
				{
					// We don't know the password yet... no matter the plugin requires
					// it or not, we will provide it later (at plugin "real" startup)
					// Knowing the environnement ("viewer") right now can be usefull or
					// even mandatory for the plugin (specific params saving and so on...)
					// The plugin receives environnement info but isn't inited at this point
					_this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
				}
				else
				{
					MessageBox(NULL, 
						sz_F1, 
						sz_F3, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
				}
			}				
			return TRUE;
			}

		case IDC_LOADPROFILE_B:
			{
				TCHAR szFileName[MAX_PATH];
				memset(szFileName, '\0', MAX_PATH);
				if (_this->m_pCC->LoadConnection(szFileName, true) != -1)
				{
					TCHAR szHost[128];
					if (_this->m_pCC->m_port == 5900)
						_tcscpy(szHost, _this->m_pCC->m_host);
					else if (_this->m_pCC->m_port > 5900 && _this->m_pCC->m_port <= 5999)
						_stprintf(szHost, TEXT("%s:%d"), _this->m_pCC->m_host, _this->m_pCC->m_port - 5900);
					else
						_stprintf(szHost, TEXT("%s::%d"), _this->m_pCC->m_host, _this->m_pCC->m_port);

					SetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, szHost);
					//AaronP
					HWND hPlugins = GetDlgItem(hwnd, IDC_PLUGINS_COMBO);
					if( strcmp( _this->m_pOpt->m_szDSMPluginFilename, "" ) != 0 && _this->m_pOpt->m_fUseDSMPlugin ) { 
						int pos = SendMessage(hPlugins, CB_FINDSTRINGEXACT, -1,
							(LPARAM)&(_this->m_pOpt->m_szDSMPluginFilename[0]));

						if( pos != CB_ERR ) {
							SendMessage(hPlugins, CB_SETCURSEL, pos, 0);
							HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
							SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
						}
					}
					//EndAaronP
				}
				SetFocus(GetDlgItem(hwnd, IDC_HOSTNAME_EDIT));
 				_this->SetQuickOption(_this, hwnd);

   		        HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
		        SendMessage(hViewOnly, BM_SETCHECK, _this->m_pOpt->m_ViewOnly, 0);

				HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
				SendMessage(hAutoScaling, BM_SETCHECK, _this->m_pOpt->m_fAutoScaling, 0);

				HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
				SendMessage(hExitCheck, BM_SETCHECK, _this->m_pOpt->m_fExitCheck, 0); //PGM @ Advantig

				_this->m_fFromOptions = true;
				_this->m_fFromFile = true;
				return TRUE;
			}

		// [v1.0.2-jp1 fix]
		case IDC_HOSTNAME_DEL:
            HWND hcombo = GetDlgItem(  hwnd, IDC_HOSTNAME_EDIT);
			int sel = SendMessage(hcombo, CB_GETCURSEL, 0, 0);
			if(sel != CB_ERR){
				SendMessage(hcombo, CB_DELETESTRING, sel, 0);
				_this->m_pMRU->RemoveItem(sel);
			}
			return TRUE;
		}

		break;

	case WM_DESTROY:
		EndDialog(hwnd, FALSE);
		return TRUE;
	}
	return 0;
}


//
//  Set the Quick Option Radio button, depending on the current QuickOption
//
int SessionDialog::SetQuickOption(SessionDialog* p_SD, HWND hwnd)
{
	HWND hDyn = GetDlgItem(hwnd, IDC_DYNAMIC);
	SendMessage(hDyn, BM_SETCHECK, false, 0);
	HWND hLan = GetDlgItem(hwnd, IDC_LAN_RB);
	SendMessage(hLan, BM_SETCHECK, false, 0);
	HWND hUltraLan = GetDlgItem(hwnd, IDC_ULTRA_LAN_RB);
	SendMessage(hUltraLan, BM_SETCHECK, false, 0);
	HWND hMedium = GetDlgItem(hwnd, IDC_MEDIUM_RB);
	SendMessage(hMedium, BM_SETCHECK, false, 0);
	HWND hModem = GetDlgItem(hwnd, IDC_MODEM_RB);
	SendMessage(hModem, BM_SETCHECK, false, 0);
	HWND hSlow = GetDlgItem(hwnd, IDC_SLOW_RB);
	SendMessage(hSlow, BM_SETCHECK, false, 0);

	// sf@2002 - Select Modem Option as default
	switch (p_SD->m_pOpt->m_quickoption)
	{
	case 1: // AUTO
		{
		HWND hDyn = GetDlgItem(hwnd, IDC_DYNAMIC);
		SendMessage(hDyn, BM_SETCHECK, true, 0);
		}
		break;

	case 2: // LAN
		{
		HWND hLan = GetDlgItem(hwnd, IDC_LAN_RB);
		SendMessage(hLan, BM_SETCHECK, true, 0);
		}
		break;
	case 3: // MEDIUM
		{
		HWND hMedium = GetDlgItem(hwnd, IDC_MEDIUM_RB);
		SendMessage(hMedium, BM_SETCHECK, true, 0);
		}
		break;
	case 4: // MODEM
		{
		HWND hModem = GetDlgItem(hwnd, IDC_MODEM_RB);
		SendMessage(hModem, BM_SETCHECK, true, 0);
		}
		break;
	case 5: // SLOW
		{
		HWND hSlow = GetDlgItem(hwnd, IDC_SLOW_RB);
		SendMessage(hSlow, BM_SETCHECK, true, 0);
		}
		break;
	case 7: // LAN
		{
		HWND hUltraLan = GetDlgItem(hwnd, IDC_ULTRA_LAN_RB);
		SendMessage(hUltraLan, BM_SETCHECK, true, 0);
		}
		break;
	/*
	case 6: // BUSY
		{
		HWND hBusy = GetDlgItem(hwnd, IDC_BUSY_RB);
		SendMessage(hBusy, BM_SETCHECK, true, 0);
		}
		break;
	*/
	}
	return 0;
}


//
//  Get the selected Quick Option and set the parameters consequently
// 
int SessionDialog::ManageQuickOptions(SessionDialog* _this, HWND hwnd)
{
	// Auto Mode
	HWND hDynamic = GetDlgItem(hwnd, IDC_DYNAMIC);
	if ((SendMessage(hDynamic, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 1;

	// Options for LAN Mode
	HWND hUltraLan = GetDlgItem(hwnd, IDC_ULTRA_LAN_RB);
	if ((SendMessage(hUltraLan, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 7;

	// Options for LAN Mode
	HWND hLan = GetDlgItem(hwnd, IDC_LAN_RB);
	if ((SendMessage(hLan, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 2;

	// Options for Medium Mode
	HWND hMedium = GetDlgItem(hwnd, IDC_MEDIUM_RB);
	if ((SendMessage(hMedium, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 3;

	// Options for Modem Mode 
	HWND hModem = GetDlgItem(hwnd, IDC_MODEM_RB);
	if ((SendMessage(hModem, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 4;

	// Options for Slow Mode
	HWND hLow = GetDlgItem(hwnd, IDC_SLOW_RB);
	if ((SendMessage(hLow, BM_GETCHECK, 0, 0) == BST_CHECKED))
		_this->m_pOpt->m_quickoption = 5;

	// Set the params depending on the selected QuickOption
	_this->m_pCC->HandleQuickOption();

	return 0;
}