/*  Project Tec3270

	 SUBSYSTEM:    Tec3270.exe (Tec3270 application)
	 FILE:         alffndlg.cpp
	 AUTHOR:       Alcindo Ferreira Filho

	 OVERVIEW:

    ALFFColorSelect, ALFFConnectDlg, ALFFRemotePrinterDlg
    Classes Implementation, Tec3270 session specific dialogs.

    COPYRIGHT:    © 1998-2007
                  Alcindo Ferreira Filho
                  <alcindo@inttec.com.br>

    LICENSE:      Tec3270_License (docs/Tec3270_License.txt)
*/
#include "alffnall.h"

//{{ALFFMDIChild Dialogs Implementation}}
///////////////////////////////////////////////////////////
// ALFFColorSelect
// ===========
// Implementation Source
//
ALFFColorSelect::ALFFColorSelect (TWindow* parent,
											 ALFFConnData* cnnData,
											 TResId idDlg,
											 bool sessCol):
											 ALFFDialog(parent, idDlg)
{
 /* Get the Application IniFile Pointer*/
 Tec3270App *theApp = TYPESAFE_DOWNCAST(GetApplication(),Tec3270App);
 iniFile = theApp->GetIniFile();

 /* Save Connection Data Address */
 connData  =  cnnData;
 clParent  =  parent;
 pMsgs  = new ALFFMsgs(this);
 sessColors = sessCol;
 virtTerm   =  new TGroupBox(this,IDC_ALFFGRPVTERM);

 /* Colors Static Objects */
 normalText     =  new ALFFStatic(this,IDC_ALFFNORMTEXTCOLOR,NULL,connData->scrCharColor);
 bkgdColor      =  new ALFFStatic(this,IDC_ALFFBKGDCOLOR,NULL,connData->scrBkgdColor);
 bkgd3270Color  =  new ALFFStatic(this,IDC_ALFFBKGD3270,NULL,connData->scr3270BkgdColor);
 nProtNormText  =  new ALFFStatic(this,IDC_ALFFNPRTNORMCOLOR,NULL,connData->scrNormalUnprotTextColor);
 nProtHighText  =  new ALFFStatic(this,IDC_ALFFNPRTHIGHCOLOR,NULL,connData->scrHighlightUnprotTextColor);
 protNormText   =  new ALFFStatic(this,IDC_ALFFPROTNORMCOLOR,NULL,connData->scrNormalProtTextColor);
 protHighText   =  new ALFFStatic(this,IDC_ALFFPROTHIGHCOLOR,NULL,connData->scrHighlightProtTextColor);
 neutral   		 =  new ALFFStatic(this,IDC_NEUTRAL,NULL,connData->neutral);
 blue   			 =  new ALFFStatic(this,IDC_BLUE,NULL,connData->blue);
 red   			 =  new ALFFStatic(this,IDC_RED,NULL,connData->red);
 pink           =  new ALFFStatic(this,IDC_PINK,NULL,connData->pink);
 green          =  new ALFFStatic(this,IDC_GREEN,NULL,connData->green);
 turquoise      =  new ALFFStatic(this,IDC_TURQUOISE,NULL,connData->turquoise);
 yellow         =  new ALFFStatic(this,IDC_YELLOW,NULL,connData->yellow);
 inverseNeutral =  new ALFFStatic(this,IDC_INVERSENEUTRAL,NULL,connData->inverseNeutral);
 black          =  new ALFFStatic(this,IDC_BLACK,NULL,connData->black);
 deepBlue       =  new ALFFStatic(this,IDC_DEEPBLUE,NULL,connData->deepBlue);
 orange         =  new ALFFStatic(this,IDC_ORANGE,NULL,connData->orange);
 purple         =  new ALFFStatic(this,IDC_PURPLE,NULL,connData->purple);
 paleGreen      =  new ALFFStatic(this,IDC_PALEGREEN,NULL,connData->paleGreen);
 paleTurquoise  =  new ALFFStatic(this,IDC_PALETURQUOISE,NULL,connData->paleTurquoise);
 gray           =  new ALFFStatic(this,IDC_GRAY,NULL,connData->gray);
 white          =  new ALFFStatic(this,IDC_WHITE,NULL,connData->white);
}

ALFFColorSelect::~ALFFColorSelect()
{
 delete pMsgs;
 delete virtTerm;

 /* Destroying Color Static Objects */
 delete normalText;
 delete bkgdColor;
 delete bkgd3270Color;
 delete nProtNormText;
 delete nProtHighText;
 delete protNormText;
 delete protHighText;
 delete  neutral;
 delete  blue;
 delete  red;
 delete  pink;
 delete  green;
 delete  turquoise;
 delete  yellow;
 delete  inverseNeutral;
 delete  black;
 delete  deepBlue;
 delete  orange;
 delete  purple;
 delete  paleGreen;
 delete  paleTurquoise;
 delete  gray;
 delete  white;
}

void
ALFFColorSelect::SetupWindow()
{
 /* Call Base Class Setup Window */
 ALFFDialog::SetupWindow();
 char text[STRINGMSGLEN+1];

 if (sessColors)
  {
	virtTerm->EnableWindow(false);
	normalText->SetBkgdColor(GetSysColor(COLOR_MENU));
	normalText->EnableWindow(false);
	bkgdColor->SetBkgdColor(GetSysColor(COLOR_MENU));
	bkgdColor->EnableWindow(false);
  }
 else
  {
	/* Set Virtual Terminal Text Colors */
	pMsgs->LoadString(IDS_ALFFCOLORNORMTEXT,text,STRINGMSGLEN);
	normalText->SetBkgdColor(connData->scrBkgdColor);
	normalText->SetTextColor(connData->scrCharColor);
	normalText->SetText(text);

	pMsgs->LoadString(IDS_ALFFCOLORBKGD,text,STRINGMSGLEN);
	bkgdColor->SetBkgdColor(connData->scrBkgdColor);
	bkgdColor->SetTextColor((~connData->scrBkgdColor) & 0x00FFFFFF);
	bkgdColor->SetText(text);
  }

 /* Set 3278 Terminal Text Colors */
 pMsgs->LoadString(IDS_ALFFCOLORBKGD3270,text,STRINGMSGLEN);
 bkgd3270Color->SetBkgdColor(connData->scr3270BkgdColor);
 bkgd3270Color->SetTextColor((~connData->scr3270BkgdColor) & 0x00FFFFFF);
 bkgd3270Color->SetText(text);

 pMsgs->LoadString(IDS_ALFFCOLORNORMNOTPROT,text,STRINGMSGLEN);
 nProtNormText->SetBkgdColor(connData->scr3270BkgdColor);
 nProtNormText->SetTextColor(connData->scrNormalUnprotTextColor);
 nProtNormText->SetText(text);

 pMsgs->LoadString(IDS_ALFFCOLORHIGHNOTPROT,text,STRINGMSGLEN);
 nProtHighText->SetBkgdColor(connData->scr3270BkgdColor);
 nProtHighText->SetTextColor(connData->scrHighlightUnprotTextColor);
 nProtHighText->SetText(text);

 pMsgs->LoadString(IDS_ALFFCOLORNORMPROT,text,STRINGMSGLEN);
 protNormText->SetBkgdColor(connData->scr3270BkgdColor);
 protNormText->SetTextColor(connData->scrNormalProtTextColor);
 protNormText->SetText(text);

 pMsgs->LoadString(IDS_ALFFCOLORHIGHPROT,text,STRINGMSGLEN);
 protHighText->SetBkgdColor(connData->scr3270BkgdColor);
 protHighText->SetTextColor(connData->scrHighlightProtTextColor);
 protHighText->SetText(text);

 /* Set 3279 Terminal Colors */
 pMsgs->LoadString(IDS_NEUTRAL,text,STRINGMSGLEN);
 neutral->SetBkgdColor(connData->neutral);
 neutral->SetTextColor(~(connData->neutral) & 0x00FFFFFF);
 neutral->SetText(text);

 pMsgs->LoadString(IDS_BLUE,text,STRINGMSGLEN);
 blue->SetBkgdColor(connData->blue);
 blue->SetTextColor(~(connData->blue) & 0x00FFFFFF);
 blue->SetText(text);

 pMsgs->LoadString(IDS_RED,text,STRINGMSGLEN);
 red->SetBkgdColor(connData->red);
 red->SetTextColor((~connData->red) & 0x00FFFFFF);
 red->SetText(text);

 pMsgs->LoadString(IDS_PINK,text,STRINGMSGLEN);
 pink->SetBkgdColor(connData->pink);
 pink->SetTextColor((~connData->pink) & 0x00FFFFFF);
 pink->SetText(text);

 pMsgs->LoadString(IDS_GREEN,text,STRINGMSGLEN);
 green->SetBkgdColor(connData->green);
 green->SetTextColor((~connData->green) & 0x00FFFFFF);
 green->SetText(text);

 pMsgs->LoadString(IDS_TURQUOISE,text,STRINGMSGLEN);
 turquoise->SetBkgdColor(connData->turquoise);
 turquoise->SetTextColor((~connData->turquoise) & 0x00FFFFFF);
 turquoise->SetText(text);

 pMsgs->LoadString(IDS_YELLOW,text,STRINGMSGLEN);
 yellow->SetBkgdColor(connData->yellow);
 yellow->SetTextColor((~connData->yellow) & 0x00FFFFFF);
 yellow->SetText(text);

 pMsgs->LoadString(IDS_INVERSENEUTRAL,text,STRINGMSGLEN);
 inverseNeutral->SetBkgdColor(connData->inverseNeutral);
 inverseNeutral->SetTextColor((~connData->inverseNeutral) & 0x00FFFFFF);
 inverseNeutral->SetText(text);

 pMsgs->LoadString(IDS_BLACK,text,STRINGMSGLEN);
 black->SetBkgdColor(connData->black);
 black->SetTextColor((~connData->black) & 0x00FFFFFF);
 black->SetText(text);

 pMsgs->LoadString(IDS_DEEPBLUE,text,STRINGMSGLEN);
 deepBlue->SetBkgdColor(connData->deepBlue);
 deepBlue->SetTextColor((~connData->deepBlue) & 0x00FFFFFF);
 deepBlue->SetText(text);

 pMsgs->LoadString(IDS_ORANGE,text,STRINGMSGLEN);
 orange->SetBkgdColor(connData->orange);
 orange->SetTextColor((~connData->orange) & 0x00FFFFFF);
 orange->SetText(text);

 pMsgs->LoadString(IDS_PURPLE,text,STRINGMSGLEN);
 purple->SetBkgdColor(connData->purple);
 purple->SetTextColor((~connData->purple) & 0x00FFFFFF);
 purple->SetText(text);

 pMsgs->LoadString(IDS_PALEGREEN,text,STRINGMSGLEN);
 paleGreen->SetBkgdColor(connData->paleGreen);
 paleGreen->SetTextColor((~connData->paleGreen) & 0x00FFFFFF);
 paleGreen->SetText(text);

 pMsgs->LoadString(IDS_PALETURQUOISE,text,STRINGMSGLEN);
 paleTurquoise->SetBkgdColor(connData->paleTurquoise);
 paleTurquoise->SetTextColor((~connData->paleTurquoise) & 0x00FFFFFF);
 paleTurquoise->SetText(text);

 pMsgs->LoadString(IDS_GRAY,text,STRINGMSGLEN);
 gray->SetBkgdColor(connData->gray);
 gray->SetTextColor((~connData->gray) & 0x00FFFFFF);
 gray->SetText(text);

 pMsgs->LoadString(IDS_WHITE,text,STRINGMSGLEN);
 white->SetBkgdColor(connData->white);
 white->SetTextColor((~connData->white) & 0x00FFFFFF);
 white->SetText(text);
}

void
ALFFColorSelect::CmOk()
{
 ALFFDialog::CmOk();
}

void
ALFFColorSelect::CmHelp()
{
/* Get the Application IniFile Pointer  */
 Tec3270App *theApp = TYPESAFE_DOWNCAST(GetApplication(),Tec3270App);
 ALFFHelp* helpFile = theApp->GetHelpFile();

 HWND helpWin = helpFile->ShowHelp(HH_HELP_CONTEXT, IDH_HELP_CHANGE_COLOR, IDH_POPUP_WINDOW);
 if (!helpWin)
   pMsgs->Message(IDS_ALFFHELPNOTAVAIL, IDS_TEC3270_HELP_ERR);
}

COLORREF
ALFFColorSelect::SelectColor(const COLORREF initColor)
{
 /* Color variables */
 CHOOSECOLOR cc;
 COLORREF clr;
 COLORREF aclrCust[16];
 int i;

 /* Set the custom color controls to white. */
 for (i = 0; i < 16; i++)
	aclrCust[i] = RGB(255, 255, 255);

 /* Initialize clr to actual color. */
 clr = COLORREF(initColor);

 /* Set all structure fields to zero. */
 memset(&cc, 0, sizeof(CHOOSECOLOR));

 /* Initialize the necessary CHOOSECOLOR members. */
 cc.lStructSize = sizeof(CHOOSECOLOR);
 cc.hwndOwner = this->HWindow;
 cc.rgbResult = clr;
 cc.lpCustColors = aclrCust;
 cc.Flags = CC_FULLOPEN | CC_RGBINIT; //| CC_SHOWHELP;
 if (ChooseColor(&cc))
  {
	/* Use cc.rgbResult to select requested color. */
	return cc.rgbResult;
  }
  else return clr;
}
LRESULT
ALFFColorSelect::EvCommand(uint controlId, HWND , uint /*notifyCode*/)
{
 COLORREF newColor;
 char defaultColors[21] = "DEFAULT COLORS";
 /*
  * controlId is the control identifier that is related to some
  * option on Connect Dialog.
  */
 switch (controlId)
  {
	/* Connect to PushButton Pressed */
	case			        IDOK: CmOk();
									  break;

	/* Cancel Connect Operation PushButton Pressed */
	case		       IDCANCEL: ALFFDialog::CmCancel();
									  break;


	/* Help to this Dialog Fields */
	case            IDHELP: CmHelp();
									break;

	/* Change Standard Default Colors */
	case       IDCHANGESTD: if (pMsgs->Message(IDS_CHANGESTDCOLORS,
															 IDS_ALFFCHOOSECOLORS,
															 true) == IDOK)
									 {
										iniFile->WriteLong(defaultColors,"BKGD3270COLOR",connData->scr3270BkgdColor);
										iniFile->WriteLong(defaultColors,"NORMNPRTTEXT",connData->scrNormalUnprotTextColor);
										iniFile->WriteLong(defaultColors,"HIGHNPRTTEXT",connData->scrHighlightUnprotTextColor);
										iniFile->WriteLong(defaultColors,"NORMPROTTEXT",connData->scrNormalProtTextColor);
										iniFile->WriteLong(defaultColors,"HIGHPROTTEXT",connData->scrHighlightProtTextColor);
										iniFile->WriteLong(defaultColors,"NEUTRAL",connData->neutral);
										iniFile->WriteLong(defaultColors,"BLUE",connData->blue);
										iniFile->WriteLong(defaultColors,"RED",connData->red);
										iniFile->WriteLong(defaultColors,"PINK",connData->pink);
										iniFile->WriteLong(defaultColors,"GREEN",connData->green);
										iniFile->WriteLong(defaultColors,"TURQUOISE",connData->turquoise);
										iniFile->WriteLong(defaultColors,"YELLOW",connData->yellow);
										iniFile->WriteLong(defaultColors,"INVERSENEUTRAL",connData->inverseNeutral);
										iniFile->WriteLong(defaultColors,"BLACK",connData->black);
										iniFile->WriteLong(defaultColors,"DEEPBLUE",connData->deepBlue);
										iniFile->WriteLong(defaultColors,"ORANGE",connData->orange);
										iniFile->WriteLong(defaultColors,"PURPLE",connData->purple);
										iniFile->WriteLong(defaultColors,"PALEGREEN",connData->paleGreen);
										iniFile->WriteLong(defaultColors,"PALETURQUOISE",connData->paleTurquoise);
										iniFile->WriteLong(defaultColors,"GRAY",connData->gray);
										iniFile->WriteLong(defaultColors,"WHITE",connData->white);
									}
									break;

	case  IDC_ALFFNORMTEXTCOLOR: /* Change Virtual Terminal Text Color */
										  newColor = SelectColor(connData->scrCharColor);
										  connData->scrCharColor = newColor;
										  normalText->SetTextColor(connData->scrCharColor);
										  break;

	case      IDC_ALFFBKGDCOLOR: /* Change Background Color */
											 connData->scrBkgdColor = SelectColor(connData->scrBkgdColor);
											 normalText->SetBkgdColor(connData->scrBkgdColor);
											 bkgdColor->SetBkgdColor(connData->scrBkgdColor);
											 bkgdColor->SetTextColor((~connData->scrBkgdColor) & 0x00FFFFFF);
										  break;

	case       IDC_ALFFBKGD3270: /* Change Background Color */
											 connData->scr3270BkgdColor = SelectColor(connData->scr3270BkgdColor);
											 bkgd3270Color->SetBkgdColor(connData->scr3270BkgdColor);
											 bkgd3270Color->SetTextColor((~connData->scr3270BkgdColor) & 0x00FFFFFF);
											 nProtNormText->SetBkgdColor(connData->scr3270BkgdColor);
											 nProtHighText->SetBkgdColor(connData->scr3270BkgdColor);
											 protNormText->SetBkgdColor(connData->scr3270BkgdColor);
											 protHighText->SetBkgdColor(connData->scr3270BkgdColor);
										  break;

	case  IDC_ALFFNPRTNORMCOLOR: /* Change 3278 Not Protected Normal Bright Color */
										  newColor = SelectColor(connData->scrNormalUnprotTextColor);
										  connData->scrNormalUnprotTextColor = newColor;
										  nProtNormText->SetTextColor(connData->scrNormalUnprotTextColor);
										  break;

	case  IDC_ALFFNPRTHIGHCOLOR: /* Change 3278 Not Protected Normal Bright Color */
										  newColor = SelectColor(connData->scrHighlightUnprotTextColor);
										  connData->scrHighlightUnprotTextColor = newColor;
										  nProtHighText->SetTextColor(connData->scrHighlightUnprotTextColor);
										  break;

	case  IDC_ALFFPROTNORMCOLOR: /* Change 3278 Not Protected Normal Bright Color */
										  newColor = SelectColor(connData->scrNormalProtTextColor);
										  connData->scrNormalProtTextColor = newColor;
										  protNormText->SetTextColor(connData->scrNormalProtTextColor);
										  break;

	case  IDC_ALFFPROTHIGHCOLOR: /* Change 3278 Not Protected Normal Bright Color */
										  newColor = SelectColor(connData->scrHighlightProtTextColor);
										  connData->scrHighlightProtTextColor = newColor;
										  protHighText->SetTextColor(connData->scrHighlightProtTextColor);
										  break;

	case            IDC_NEUTRAL: /* Change 3279 NEUTRAL Color */
										  newColor = SelectColor(connData->neutral);
										  connData->neutral = newColor;
										  neutral->SetBkgdColor(connData->neutral);
										  neutral->SetTextColor((~connData->neutral) & 0x00FFFFFF);
										  break;

	case               IDC_BLUE: /* Change 3279 BLUE Color */
										  newColor = SelectColor(connData->blue);
										  connData->blue = newColor;
										  blue->SetBkgdColor(connData->blue);
										  blue->SetTextColor((~connData->blue) & 0x00FFFFFF);
										  break;

	case                IDC_RED: /* Change 3279 RED Color */
										  newColor = SelectColor(connData->red);
										  connData->red = newColor;
										  red->SetBkgdColor(connData->red);
										  red->SetTextColor((~connData->red) & 0x00FFFFFF);
										  break;

	case               IDC_PINK: /* Change 3279 PINK Color */
										  newColor = SelectColor(connData->pink);
										  connData->pink = newColor;
										  pink->SetBkgdColor(connData->pink);
										  pink->SetTextColor((~connData->pink) & 0x00FFFFFF);
										  break;

	case              IDC_GREEN: /* Change 3279 GREEN Color */
										  newColor = SelectColor(connData->green);
										  connData->green = newColor;
										  green->SetBkgdColor(connData->green);
										  green->SetTextColor((~connData->green) & 0x00FFFFFF);
										  break;

	case          IDC_TURQUOISE: /* Change 3279 TURQUOISE Color */
										  newColor = SelectColor(connData->turquoise);
										  connData->turquoise = newColor;
										  turquoise->SetBkgdColor(connData->turquoise);
										  turquoise->SetTextColor((~connData->turquoise) & 0x00FFFFFF);
										  break;

	case             IDC_YELLOW: /* Change 3279 YELLOW Color */
										  newColor = SelectColor(connData->yellow);
										  connData->yellow = newColor;
										  yellow->SetBkgdColor(connData->yellow);
										  yellow->SetTextColor((~connData->yellow) & 0x00FFFFFF);
										  break;

	case     IDC_INVERSENEUTRAL: /* Change 3279 INVERSENEUTRAL Color */
										  newColor = SelectColor(connData->inverseNeutral);
										  connData->inverseNeutral = newColor;
										  inverseNeutral->SetBkgdColor(connData->inverseNeutral);
										  inverseNeutral->SetTextColor((~connData->inverseNeutral) & 0x00FFFFFF);
										  break;

	case              IDC_BLACK: /* Change 3279 BLACK Color */
										  newColor = SelectColor(connData->black);
										  connData->black = newColor;
										  black->SetBkgdColor(connData->black);
										  black->SetTextColor((~connData->black) & 0x00FFFFFF);
										  break;

	case           IDC_DEEPBLUE: /* Change 3279 DEEPBLUE Color */
										  newColor = SelectColor(connData->deepBlue);
										  connData->deepBlue = newColor;
										  deepBlue->SetBkgdColor(connData->deepBlue);
										  deepBlue->SetTextColor((~connData->deepBlue) & 0x00FFFFFF);
										  break;

	case             IDC_ORANGE: /* Change 3279 ORANGE Color */
										  newColor = SelectColor(connData->orange);
										  connData->orange = newColor;
										  orange->SetBkgdColor(connData->orange);
										  orange->SetTextColor((~connData->orange) & 0x00FFFFFF);
										  break;

	case             IDC_PURPLE: /* Change 3279 PURPLE Color */
										  newColor = SelectColor(connData->purple);
										  connData->purple = newColor;
										  purple->SetBkgdColor(connData->purple);
										  purple->SetTextColor((~connData->purple) & 0x00FFFFFF);
										  break;

	case          IDC_PALEGREEN: /* Change 3279 PALE GREEN Color */
										  newColor = SelectColor(connData->paleGreen);
										  connData->paleGreen = newColor;
										  paleGreen->SetBkgdColor(connData->paleGreen);
										  paleGreen->SetTextColor((~connData->paleGreen) & 0x00FFFFFF);
										  break;

	case      IDC_PALETURQUOISE: /* Change 3279 PALE TURQUOISE Color */
										  newColor = SelectColor(connData->paleTurquoise);
										  connData->paleTurquoise = newColor;
										  paleTurquoise->SetBkgdColor(connData->paleTurquoise);
										  paleTurquoise->SetTextColor((~connData->paleTurquoise) & 0x00FFFFFF);
										  break;

	case               IDC_GRAY: /* Change 3279 GRAY Color */
										  newColor = SelectColor(connData->gray);
										  connData->gray = newColor;
										  gray->SetBkgdColor(connData->gray);
										  gray->SetTextColor((~connData->gray) & 0x00FFFFFF);
										  break;

	case              IDC_WHITE: /* Change 3279 WHITE Color */
										  newColor = SelectColor(connData->white);
										  connData->white = newColor;
										  white->SetBkgdColor(connData->white);
										  white->SetTextColor((~connData->white) & 0x00FFFFFF);
										  break;


	default      : pMsgs->Message( IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
						break;
  }

 return 1L;
}


///////////////////////////////////////////////////////////
// ALFFConnDlg
// ===========
// Implementation Source
//
ALFFConnectDlg::ALFFConnectDlg (TWindow* parent,
										  ALFFConnData* cnnData,
										  TResId idDlg, int config) :
										  ALFFDialog(parent, idDlg)
{
 connData = cnnData;
 cdParent = parent;
 cdOpt = config;

 pMsgs  = new ALFFMsgs(this);

 if (cdOpt == SESSCONFIG)
	{
	 closeButton = new TButton(this, IDOK);
	 addButton = NULL;
	 delButton = NULL;
	 updButton = NULL;
	}
 else
	{
	 closeButton = NULL;
	 addButton = new TButton(this,IDC_ALFFSESSADD);
	 delButton = new TButton(this,IDC_ALFFSESSDEL);
	 updButton = new TButton(this,IDC_ALFFSESSUPDATE);
	}

 /* Construct Dialog Objects */
 connListBox = new TComboBox(this, IDC_ALFFSESSCOMBOX);

 /* Connection Host Name and Port Number */
 hostName    = new TEdit(this, IDC_ALFFHOSTNAME, HOSTNAMELEN);
 portNumber  = new TEdit(this, IDC_ALFFPORTNUMB);
 portNumber->SetValidator(new TFilterValidator("0-9"));
 useSSLV2      = new TCheckBox(this, IDC_ALFFUSESSLV2);
 useSSLV3      = new TCheckBox(this, IDC_ALFFUSESSLV3);

 /* Connection Disconnect Options */
 whenDiscGrp = new TGroupBox(this, IDC_ALFFWHENDISCGRP);
 connReconn  = new TRadioButton(this, IDC_ALFFRECONNECT, whenDiscGrp);
 connExit    = new TRadioButton(this, IDC_ALFFSESSEXITCLOSE, whenDiscGrp);
 doNothing   = new TRadioButton(this, IDC_ALFFSESSDONOTHING, whenDiscGrp);

 /* Connection Time Programming Options */
 connTimeGrp = new TGroupBox(this,IDC_ALFFPROGACT);
 timeOutOpt  = new TRadioButton(this, IDC_ALFFPROGTIMEOUT, connTimeGrp);
 idleTimeOpt = new TRadioButton(this, IDC_ALFFPROGIDLE, connTimeGrp);
 pressKeyOpt = new TRadioButton(this, IDC_ALFFPROGPRESSKEY, connTimeGrp);
 noActionOpt = new TRadioButton(this, IDC_ALFFPROGDONOTHING, connTimeGrp);

 intvTimeTit = new TStatic(this,IDC_ALFFSESSINTVTIMETIT);
 intvTime    = new TEdit(this, IDC_ALFFSESSINTVTIME,6);
 intvTime->SetValidator(new TFilterValidator("0-9"));
 pressKeyTit = new TStatic(this,IDC_ALFFSESSKEYPRESSTIT);
 pressKey    = new TComboBox(this, IDC_ALFFSESSKEYPRESS);

 /* Connection Special Options */
 bringTop    = new TCheckBox(this, IDC_ALFFSESSBRINGTOP);
 actYale     = new TCheckBox(this, IDC_ALFFSESSYALENULL);
 connLog     = new TCheckBox(this, IDC_ALFFSESSLOG);
 soundAlm    = new TCheckBox(this, IDC_ALFFSESSSOUNDALM);
 monTime     = new TEdit(this, IDC_ALFFSESSMONTIME,6);
 monTime->SetValidator(new TFilterValidator("0-9"));


 /* Connection Terminal Type and Code Page */
 termType    = new TComboBox(this, IDC_ALFFSESSTERMTYPE);
 terminalNetName = new TEdit(this, IDC_ALFFTERMNETNAME,9);
 codePage    = new TComboBox(this, IDC_ALFFSESSCODEPAGE);
 connRemPrt  = new TButton(this, IDC_ALFFSESSREMPRT);

 /* Connection Script Processing Options */
 scriptOn    = new TRadioButton(this, IDC_ALFFSESSSCPTON);
 scriptTit   = new TStatic(this, IDC_ALFFSCRIPTFILE);
 scriptFile  = new TEdit(this, IDC_ALFFSESSSCPTFILENAME);
 scriptBrowse = new TButton(this, IDC_ALFFSCRPTBROWSE);

 /* Get the Application IniFile Pointer*/
 Tec3270App *theApp = TYPESAFE_DOWNCAST(GetApplication(),
													 Tec3270App);
 iniFile = theApp->GetIniFile();

 /* Connection List Controls .......................*/
 connList = new char[MAXSESSIONS*(SESSNAMELEN+1)];
 connIndex = new short[MAXSESSIONS];
 connSelIndex = 0;
 connQuantity = 0;
}

ALFFConnectDlg::~ALFFConnectDlg()
{
	 delete pMsgs;

    connListBox->ClearList();
	 delete connListBox;
    
	 delete [] connList;
	 delete [] connIndex;

	 if (closeButton)
		delete closeButton;
	 if (addButton)
		delete addButton;
	 if (delButton)
		 delete delButton;
	 if (updButton)
		 delete updButton;

	 /* Connection Host Name and Port Number */
	 delete hostName;
	 delete portNumber;
	 delete useSSLV2;
  	 delete useSSLV3;

	 /* Connection Disconnect Options */
	 delete whenDiscGrp;
	 delete connReconn;
	 delete connExit;
	 delete doNothing;

	 /* Connection Timeout Options */
	 delete connTimeGrp;
	 delete timeOutOpt;
	 delete idleTimeOpt;
	 delete pressKeyOpt;
	 delete noActionOpt;
	 delete intvTimeTit;
	 delete intvTime;
	 delete pressKeyTit;
    pressKey->ClearList();
	 delete pressKey;

	 /* Connection Special Options */
	 delete bringTop;
	 delete soundAlm;
	 delete actYale;
	 delete connLog;
	 delete monTime;

	 /* Connection Terminal Type and Code Page */
    termType->ClearList();
	 delete termType;
    delete terminalNetName;
    codePage->ClearList();
	 delete codePage;
    delete connRemPrt;

	 /* Connection Script Processing Options */
	 delete scriptOn;
	 delete scriptTit;
	 delete scriptFile;
	 delete scriptBrowse;
}


void
ALFFConnectDlg::SetupWindow()
{
 int length;
 char temp[SESSNAMELEN];
 int i;
 int j;

 /* Call Base Class Setup Window */
 ALFFDialog::SetupWindow();

 /* Setup Default PushButton To Session Configurator or Session Connection */
 if (closeButton)
  {
	char closeCaption[STRINGMSGLEN+1];
	pMsgs->LoadString( IDS_ALFFSESSSETUPCLOSE,closeCaption,STRINGMSGLEN);
	closeButton->SetCaption(closeCaption);
  }

 /* Load Connection Press Key */
 length = 1;
 for (i = IDS_IDLEKEYBASE+1; length; i++)
	{
	 length = pMsgs->LoadString(i,temp,SESSNAMELEN-1);
	 if (length)
		 pressKey->AddString(temp);
	}

 if (cdOpt != SESSCHANGE)
 {
  /*
	* Load Connection List Box:
	*/
  char connSection[21] = "CONNECTIONS";

  /* Initialize connections name list to nulls for identifying list end */
  memset(connList,NULL,MAXSESSIONS*(SESSNAMELEN+1));
  for (i = 0; i < MAXSESSIONS; i++)
	{
	 connIndex[i] = -1;
	}

  connListBox->Clear();
  connListBox->SetRedraw(false);
  pMsgs->LoadString(IDS_SESSNEWSESS,connData->connName,SESSNAMELEN-1);

  /* Getting All Connections already defined */
  int rc = iniFile->GetInt(connSection,"QUANTITY",0);
  if (rc)
	{
	 iniFile->GetString(connSection,NULL,connData->connName,
								 connList,MAXSESSIONS*(SESSNAMELEN+1));
	 /* Process all connections that was read and build an access index */
	 i = 0;
	 char* pConnList = connList;
	 while (strlen(pConnList))
	  {
		 if (strcmp(pConnList,"QUANTITY"))
			connIndex[i++] = (short)(pConnList-connList);
		 pConnList += strlen(pConnList)+1;
	  }
	 if (i > 0)
	  {
		for (j = 0; j < i; j++)
		{
		 pConnList = connList+connIndex[j];
		 if (connListBox->AddString(pConnList) < 0)
		  TXOwl(IDS_SESSLISTADDERR );
		}
		connListBox->SetSelIndex(0);
		connSelIndex = 0;
		connQuantity = i;
		LoadConnection(connList);
		strcpy(connData->connName,connList);
		newConn = false;
	  }
	 else newConn = true;
	}
	else newConn = true;
  connListBox->SetRedraw(true);

  /* Load Connection Terminal Type */
  length = 1;
  for (i = IDS_ALFFTERMBASE+1; length; i++)
	{
	 length = pMsgs->LoadString(i,temp,SESSNAMELEN-1);
	 if (length)
		termType->AddString(temp);
	}

  /* Load Connection Terminal Code Page */
  length = 1;
  for (i = IDS_ALFFCODEPAGE+1; length; i++)
	{
	 length = pMsgs->LoadString(i,temp,SESSNAMELEN-1);
	 if (length)
	  codePage->AddString(temp);
	}
 }
 else
  {
   /* It is an old connection/session definition */
	newConn = false;

	/* Show All Session Data On Dialog */
	UpdateDialog();

	/* Disable All Data That Cannot Be Modified */
	connListBox->SetText(connData->connName);
	connListBox->EnableWindow(false);
	hostName->EnableWindow(false);
	portNumber->EnableWindow(false);
	useSSLV2->EnableWindow(false);
  	useSSLV3->EnableWindow(false);
	connLog->EnableWindow(false);

	/* Set Current Terminal type */
	length = pMsgs->LoadString(IDS_ALFFTERMBASE+connData->termType+1,temp,SESSNAMELEN-1);
	if (length)
	 {
	  termType->AddString(temp);
	  termType->SetSelIndex(0);
	 }
	termType->EnableWindow(false);

   /* Current Netname MUST be read_only */
   terminalNetName->EnableWindow(false);

	/* Set Current Code Page */
	length = pMsgs->LoadString(IDS_ALFFCODEPAGE+connData->codePage+1,temp,SESSNAMELEN-1);
	if (length)
	 {
	  codePage->AddString(temp);
	  codePage->SetSelIndex(0);
	 }
	codePage->EnableWindow(false);

   /* Remote Printer Option cannot be modified here */
   connRemPrt->EnableWindow(false);

	/* Connection Script Processing Options */
	scriptOn->EnableWindow(false);
	scriptTit->EnableWindow(false);
	scriptFile->EnableWindow(false);
	scriptBrowse->EnableWindow(false);

	addButton->EnableWindow(false);
	delButton->EnableWindow(false);
	updButton->EnableWindow(false);
  }

 // This is an protection to Tec3270 cancel when this dialog is open.
 buttonPressed = IDCANCEL;
}

bool
ALFFConnectDlg::AddConnection(const char* connName)
{
 char connSection[21] = "CONNECTIONS";
 if (strlen(connName))
  {
	if (iniFile->WriteInt(connSection,connData->connName,0))
	 {
	  connQuantity+=1;
	  if (iniFile->WriteInt(connSection,"QUANTITY",connQuantity))
		 return true;
	  else return false;
	 }
	 else return false;
  }
  else return false;
}

bool
ALFFConnectDlg::DeleteConnection(const char* connName)
{
 char connSection[21] = "CONNECTIONS";
 char defaultColors[21]= "DEFAULT COLORS";

 if (strlen(connName))
  {
	if ( (iniFile->WriteString(connSection,connData->connName,NULL))
	 && (iniFile->WriteString(connData->connName,NULL,NULL)) )
	  {
		connQuantity-=1;
		if (iniFile->WriteInt(connSection,"QUANTITY",connQuantity))
		 {
		  /* Reset Connection Struct */
		  connData->connName[0] = NULL;
		  connData->hostName[0] = NULL;
		  connData->portNumber = 23;    				//Normal Telnet Port
        connData->securityMethod  = ALFFSSLComm::ALFFNONE;  // Don't Use secure connection
		  connData->connReconn = false;     		//No automatic reconnection
		  connData->connExit  = true;       		//Exit when Connection Closed;
		  connData->connDoNothing = false;  		//As above procedure active this is false;
		  connData->actOption = NO_TIMER;     		//No session time action;
		  connData->intvTime = 0;						//No interval timer;
		  connData->pressKey  = 0;           		//Enter key assumed;
		  connData->bringTop = true;        		//When message arrive bring to top
		  connData->actYale = false;		   		//No Yale Nulls Processing
		  connData->connLog = false;       			//Create No Log File
		  connData->soundAlm = true;        		//Sound Alarm ON;
		  connData->monTime = 10;			      	//Monitoring session by 10 seconds;
		  connData->termType = 1;      				//Assume Term 3278 Model 2
        connData->terminalNetName[0] = NULL;    // No Netname specified
		  connData->codePage = 0;      				//Assume EBCDIC Code Page 037
        connData->printerNetName[0] = NULL;
        connData->printerAssociated = true;     // Terminal associated remote printer
        connData->printerOnly = false;       	// Do not connect only the printer
		  connData->scriptOn = false;       		//Assume No Script File;
		  connData->scriptFile[0] = NULL;
		  connData->hostName[0] = NULL;
		  connData->scrCharColor = iniFile->GetLong(defaultColors,"TEXTCOLOR",TERMCHAR);
		  connData->scrBkgdColor = iniFile->GetLong(defaultColors,"BKGDCOLOR",TERMBKGD);
		  connData->scr3270BkgdColor = iniFile->GetLong(defaultColors,"BKGD3270COLOR",BKGD3270);
		  connData->scrNormalUnprotTextColor = iniFile->GetLong(defaultColors,"NORMNPRTTEXT",NORMALUNPROT);
		  connData->scrHighlightUnprotTextColor = iniFile->GetLong(defaultColors,"HIGHNPRTTEXT",HIGHUNPROT);
		  connData->scrNormalProtTextColor = iniFile->GetLong(defaultColors,"NORMPROTTEXT",NORMALPROT);
		  connData->scrHighlightProtTextColor = iniFile->GetLong(defaultColors,"HIGHPROTTEXT",HIGHPROT);
		  connData->neutral = iniFile->GetLong(defaultColors,"NEUTRAL",DEFNEUTRAL);
		  connData->blue = iniFile->GetLong(defaultColors,"BLUE",DEFBLUE);
		  connData->red = iniFile->GetLong(defaultColors,"RED",DEFRED);
		  connData->pink = iniFile->GetLong(defaultColors,"PINK",DEFPINK);
		  connData->green = iniFile->GetLong(defaultColors,"GREEN",DEFGREEN);
		  connData->turquoise = iniFile->GetLong(defaultColors,"TURQUOISE",DEFTURQUOISE);
		  connData->yellow = iniFile->GetLong(defaultColors,"YELLOW",DEFYELLOW);
		  connData->inverseNeutral =  iniFile->GetLong(defaultColors,"INVERSENEUTRAL",DEFINVNEUTRAL);
		  connData->black = iniFile->GetLong(defaultColors,"BLACK",DEFBLACK);
		  connData->deepBlue = iniFile->GetLong(defaultColors,"DEEPBLUE",DEFDEEPBLUE);
		  connData->orange = iniFile->GetLong(defaultColors,"ORANGE",DEFORANGE);
		  connData->purple = iniFile->GetLong(defaultColors,"PURPLE",DEFPURPLE);
		  connData->paleGreen = iniFile->GetLong(defaultColors,"PALEGREEN",DEFPALEGREEN);
		  connData->paleTurquoise = iniFile->GetLong(defaultColors,"PALETURQUOISE",DEFPALETURQUOISE);
		  connData->gray = iniFile->GetLong(defaultColors,"GRAY",DEFGRAY);
		  connData->white = iniFile->GetLong(defaultColors,"WHITE",DEFWHITE);
		  return true;
		}
		else return false;
	 }
	 else return false;
  }
  else return false;
}

bool
ALFFConnectDlg::LoadConnection(const char* connName)
{
 if (strlen(connName))
  {
   strcpy(connData->connName,connName);
	if (iniFile->GetString(connName,"HOSTNAME","Enter HostName",
								  connData->hostName, HOSTNAMELEN-1))
		{
       if (!strcmp(connData->hostName,"Enter HostName"))
         return false;
       else
        {
		   connData->portNumber = iniFile->GetInt(connName,"PORTNUM",23);
         connData->securityMethod  = iniFile->GetInt(connName,"SECURITYMETHOD",ALFFSSLComm::ALFFNONE);
		   connData->connReconn = iniFile->GetInt(connName,"RECONNECT",0);
		   connData->connExit   = iniFile->GetInt(connName,"EXIT",1);
		   connData->connDoNothing  = iniFile->GetInt(connName,"DONOTHING",0);
		   connData->actOption = iniFile->GetInt(connName,"ACTOPTION",NO_TIMER);
		   connData->intvTime   = iniFile->GetInt(connName,"INTVTIME",0);
		   connData->pressKey    = iniFile->GetInt(connName,"PRESSKEY",0);
		   connData->bringTop   = iniFile->GetInt(connName,"BRINGTOTOP",1);
		   connData->actYale = iniFile->GetInt(connName,"YALE",0);
		   connData->connLog = iniFile->GetInt(connName,"LOGFILE",0);
		   connData->soundAlm = iniFile->GetInt(connName,"SOUND",1);
		   connData->monTime   = iniFile->GetInt(connName,"MONTIME",10);
		   connData->termType = iniFile->GetInt(connName,"TERMINAL",0);
         iniFile->GetString(connName, "NETNAME", "", connData->terminalNetName, 9);
		   connData->codePage = iniFile->GetInt(connName,"CODEPAGE",0);

         /* -----------  Remote Printer Session Config Info -------------------  */
         iniFile->GetString(connName, "PRINTERNETNAME", "", connData->printerNetName,  9);
   	   connData->printerInact = iniFile->GetInt(connName,"INACTIVATEPRINTER",0);
         connData->printerAssociated = iniFile->GetInt(connName,"ASSOCIATEDPRINTER",1);
         connData->printerOnly = iniFile->GetInt(connName,"PRINTERONLY",0);
	 		connData->printerOnColor = iniFile->GetInt(connName,"PRINTERONCOLOR",1);
	 		connData->printerDimen =  iniFile->GetInt(connName,"PRINTERDIMENSIONING",0);
	 		connData->printerIgnoreFF = iniFile->GetInt(connName,"PRINTERIGNOREFF",0);
	 		connData->printerBreakLine = iniFile->GetInt(connName,"PRINTERBREAKLINE",0);
	 		connData->printerTabWidth =  iniFile->GetInt(connName,"PRINTERTABWIDTH",9);
	 		connData->printerCharPerInch = iniFile->GetInt(connName,"PRINTERCHARPERINCH",10);
	 		connData->printerLinePerInch =  iniFile->GetInt(connName,"PRINTERLINEPERINCH",6);
	 		connData->printerCharPerLine = iniFile->GetInt(connName,"PRINTERCHARPERLINE",132);
	 		connData->printerLinePerPage =  iniFile->GetInt(connName,"PRINTERLINEPERPAGE",66);
	 		connData->printerTimeInact =   iniFile->GetInt(connName,"PRINTERTIMEINACT",0);
	 		connData->printerTimeConcat = iniFile->GetInt(connName,"PRINTERTIMECONCAT",0);
	 		connData->printerTimeEnd =  iniFile->GetInt(connName,"PRINTERTIMEEND",0);
	 		connData->printerNullLine = iniFile->GetInt(connName,"PRINTERNULLLINE",0);
	 		connData->printerNullAsSpace = iniFile->GetInt(connName,"PRINTERNULLASSPACE",1);
	 		connData->printerIgnoreAttr =  iniFile->GetInt(connName,"PRINTERIGNOREATTR",0);
         connData->printerFFAsSpace =   iniFile->GetInt(connName,"PRINTERFFASSPACE",1);
	 		connData->printerFFAnyPos =  iniFile->GetInt(connName,"PRINTERFFANYPOS",1);
	 		connData->printerEndLineNL = iniFile->GetInt(connName,"PRINTERENDLINENL",0);
	 		connData->printerEndLineCR = iniFile->GetInt(connName,"PRINTERENDLINECR",0);
	 		connData->printerSCSErr =   iniFile->GetInt(connName,"PRINTERSCSERR",0);
	 		connData->printerInheritParm = iniFile->GetInt(connName,"PRINTERHERITPARM",1);
    		/*---------------------------------------------------------------------------*/

		   connData->scriptOn   = iniFile->GetInt(connName,"SCRIPT",0);
		   iniFile->GetString(connName,"SCRIPTNAME","",connData->scriptFile, MAXPATH);
		   //connData->scrCharColor = iniFile->GetLong(connName,"TEXTCOLOR",TERMCHAR);
		   //connData->scrBkgdColor = iniFile->GetLong(connName,"BKGDCOLOR",TERMBKGD);
		   connData->scr3270BkgdColor = iniFile->GetLong(connName,"BKGD3270COLOR",BKGD3270);
		   connData->scrNormalUnprotTextColor = iniFile->GetLong(connName,"NORMNPRTTEXT",NORMALUNPROT);
		   connData->scrHighlightUnprotTextColor = iniFile->GetLong(connName,"HIGHNPRTTEXT",HIGHUNPROT);
		   connData->scrNormalProtTextColor = iniFile->GetLong(connName,"NORMPROTTEXT",NORMALPROT);
		   connData->scrHighlightProtTextColor = iniFile->GetLong(connName,"HIGHPROTTEXT",HIGHPROT);
		   connData->neutral = iniFile->GetLong(connName,"NEUTRAL",DEFNEUTRAL);
		   connData->blue = iniFile->GetLong(connName,"BLUE",DEFBLUE);
		   connData->red = iniFile->GetLong(connName,"RED",DEFRED);
		   connData->pink = iniFile->GetLong(connName,"PINK",DEFPINK);
		   connData->green = iniFile->GetLong(connName,"GREEN",DEFGREEN);
		   connData->turquoise = iniFile->GetLong(connName,"TURQUOISE",DEFTURQUOISE);
		   connData->yellow = iniFile->GetLong(connName,"YELLOW",DEFYELLOW);
		   connData->inverseNeutral =  iniFile->GetLong(connName,"INVERSENEUTRAL",DEFINVNEUTRAL);
		   connData->black = iniFile->GetLong(connName,"BLACK",DEFBLACK);
		   connData->deepBlue = iniFile->GetLong(connName,"DEEPBLUE",DEFDEEPBLUE);
		   connData->orange = iniFile->GetLong(connName,"ORANGE",DEFORANGE);
		   connData->purple = iniFile->GetLong(connName,"PURPLE",DEFPURPLE);
		   connData->paleGreen = iniFile->GetLong(connName,"PALEGREEN",DEFPALEGREEN);
		   connData->paleTurquoise = iniFile->GetLong(connName,"PALETURQUOISE",DEFPALETURQUOISE);
		   connData->gray = iniFile->GetLong(connName,"GRAY",DEFGRAY);
  		   connData->white = iniFile->GetLong(connName,"WHITE",DEFWHITE);
		   return true;
        }
		}
		else return false;
  }
  else return false;
}

void
ALFFConnectDlg::SaveConnection(const char* connName)
{
 if (strlen(connName))
  {
	iniFile->WriteString(connName,"HOSTNAME",connData->hostName);
	iniFile->WriteInt(connName,"PORTNUM",connData->portNumber);
	iniFile->WriteInt(connName,"SECURITYMETHOD",connData->securityMethod);
	iniFile->WriteInt(connName,"RECONNECT",connData->connReconn);
	iniFile->WriteInt(connName,"EXIT",connData->connExit);
	iniFile->WriteInt(connName,"DONOTHING",connData->connDoNothing);
	iniFile->WriteInt(connName,"ACTOPTION",connData->actOption);
	iniFile->WriteInt(connName,"INTVTIME",connData->intvTime);
	iniFile->WriteInt(connName,"PRESSKEY",connData->pressKey);
	iniFile->WriteInt(connName,"BRINGTOTOP",connData->bringTop);
	iniFile->WriteInt(connName,"YALE",connData->actYale);
	iniFile->WriteInt(connName,"LOGFILE",connData->connLog);
	iniFile->WriteInt(connName,"SOUND",connData->soundAlm);
	iniFile->WriteInt(connName,"MONTIME",connData->monTime);
	iniFile->WriteInt(connName,"TERMINAL",connData->termType);
	iniFile->WriteString(connName,"NETNAME",connData->terminalNetName);
	iniFile->WriteInt(connName,"CODEPAGE",connData->codePage);

   /* -----------  Remote Printer Session Config Info -------------------  */
   iniFile->WriteString(connName, "PRINTERNETNAME", connData->printerNetName);
   iniFile->WriteInt(connName, "INACTIVATEPRINTER",connData->printerInact);
   iniFile->WriteInt(connName, "ASSOCIATEDPRINTER", connData->printerAssociated);
   iniFile->WriteInt(connName, "PRINTERONLY", connData->printerOnly);
	iniFile->WriteInt(connName, "PRINTERONCOLOR", connData->printerOnColor);
	iniFile->WriteInt(connName, "PRINTERDIMENSIONING", connData->printerDimen);
	iniFile->WriteInt(connName, "PRINTERIGNOREFF", connData->printerIgnoreFF);
	iniFile->WriteInt(connName, "PRINTERBREAKLINE",connData->printerBreakLine);
	iniFile->WriteInt(connName, "PRINTERTABWIDTH", connData->printerTabWidth);
	iniFile->WriteInt(connName, "PRINTERCHARPERINCH", connData->printerCharPerInch);
	iniFile->WriteInt(connName, "PRINTERLINEPERINCH", connData->printerLinePerInch);
	iniFile->WriteInt(connName, "PRINTERCHARPERLINE", connData->printerCharPerLine);
	iniFile->WriteInt(connName, "PRINTERLINEPERPAGE", connData->printerLinePerPage);
	iniFile->WriteInt(connName, "PRINTERTIMEINACT", connData->printerTimeInact);
	iniFile->WriteInt(connName, "PRINTERTIMECONCAT", connData->printerTimeConcat);
	iniFile->WriteInt(connName, "PRINTERTIMEEND", connData->printerTimeEnd);
	iniFile->WriteInt(connName, "PRINTERNULLLINE", connData->printerNullLine);
	iniFile->WriteInt(connName, "PRINTERNULLASSPACE", connData->printerNullAsSpace);
	iniFile->WriteInt(connName, "PRINTERIGNOREATTR", connData->printerIgnoreAttr);
   iniFile->WriteInt(connName, "PRINTERFFASSPACE", connData->printerFFAsSpace);
	iniFile->WriteInt(connName, "PRINTERFFANYPOS", connData->printerFFAnyPos);
	iniFile->WriteInt(connName, "PRINTERENDLINENL", connData->printerEndLineNL);
	iniFile->WriteInt(connName, "PRINTERENDLINECR", connData->printerEndLineCR);
	iniFile->WriteInt(connName, "PRINTERSCSERR", connData->printerSCSErr);
	iniFile->WriteInt(connName, "PRINTERHERITPARM", connData->printerInheritParm);
   /*---------------------------------------------------------------------------*/

	iniFile->WriteInt(connName,"SCRIPT",connData->scriptOn);
	iniFile->WriteString(connName,"SCRIPTNAME",connData->scriptFile);
	iniFile->WriteLong(connName,"BKGD3270COLOR",connData->scr3270BkgdColor);
	iniFile->WriteLong(connName,"NORMNPRTTEXT",connData->scrNormalUnprotTextColor);
	iniFile->WriteLong(connName,"HIGHNPRTTEXT",connData->scrHighlightUnprotTextColor);
	iniFile->WriteLong(connName,"NORMPROTTEXT",connData->scrNormalProtTextColor);
	iniFile->WriteLong(connName,"HIGHPROTTEXT",connData->scrHighlightProtTextColor);
	iniFile->WriteLong(connName,"NEUTRAL",connData->neutral);
	iniFile->WriteLong(connName,"BLUE",connData->blue);
	iniFile->WriteLong(connName,"RED",connData->red);
	iniFile->WriteLong(connName,"PINK",connData->pink);
	iniFile->WriteLong(connName,"GREEN",connData->green);
	iniFile->WriteLong(connName,"TURQUOISE",connData->turquoise);
	iniFile->WriteLong(connName,"YELLOW",connData->yellow);
	iniFile->WriteLong(connName,"INVERSENEUTRAL",connData->inverseNeutral);
	iniFile->WriteLong(connName,"BLACK",connData->black);
	iniFile->WriteLong(connName,"DEEPBLUE",connData->deepBlue);
	iniFile->WriteLong(connName,"ORANGE",connData->orange);
	iniFile->WriteLong(connName,"PURPLE",connData->purple);
	iniFile->WriteLong(connName,"PALEGREEN",connData->paleGreen);
	iniFile->WriteLong(connName,"PALETURQUOISE",connData->paleTurquoise);
	iniFile->WriteLong(connName,"GRAY",connData->gray);
	iniFile->WriteLong(connName,"WHITE",connData->white);
  }
}

void
ALFFConnectDlg::UpdateDialog()
{
 char string[20];

 /* Initialize Host Name and Port Number Controls */
 if (connData->hostName)
	hostName->SetText(connData->hostName);
  else hostName->Clear();
 if (connData->portNumber)
  {
	itoa(connData->portNumber, string, 10);
	portNumber->SetText(string);
  }
  else portNumber->Clear();

 /* Use SSL option */
 if (connData->securityMethod == ALFFSSLComm::ALFFSSLV2)
  {
   useSSLV2->Check();
   useSSLV3->Uncheck();
  }
 else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV23)
  {
   useSSLV2->Check();
   useSSLV3->Check();
  }
 else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV3)
  {
   useSSLV2->Check();
   useSSLV3->Check();
  }
 else if (connData->securityMethod == ALFFSSLComm::ALFFNONE)
  {
   useSSLV2->Uncheck();
   useSSLV3->Uncheck();
  }
 else throw ALFFException(IDS_ALFFSSLMETHODERROR);

 /* Connection Disconnect Options */
 connReconn->Uncheck();
 connExit->Uncheck();
 doNothing->Uncheck();

 if (connData->connReconn)
	connReconn->Check();
 else if (connData->connExit)
	connExit->Check();
 else if (connData->connDoNothing)
	doNothing->Check();

 /* Connection Time Programming Options */
 timeOutOpt->Uncheck();
 idleTimeOpt->Uncheck();
 pressKeyOpt->Uncheck();
 noActionOpt->Uncheck();

 switch (connData->actOption)
  {
	case     KEY_TIMER: pressKeyOpt->Check();
							  if (connData->intvTime)
								{
								 itoa(connData->intvTime,string,10);
								 intvTime->SetText(string);
								}
							  else intvTime->Clear();
							  pressKey->SetSelIndex(connData->pressKey);
							  pressKey->EnableWindow(true);
							  pressKeyTit->EnableWindow(true);
							  break;
	case    IDLE_TIMER: idleTimeOpt->Check();
							  if (connData->intvTime)
								{
								 itoa(connData->intvTime,string,10);
								 intvTime->SetText(string);
								}
							  else intvTime->Clear();
							  pressKey->SetSelIndex(connData->pressKey);
							  pressKey->EnableWindow(true);
							  pressKeyTit->EnableWindow(true);
							  break;
	case   CLOSE_TIMER: timeOutOpt->Check();
							  if (connData->intvTime)
								{
								 itoa(connData->intvTime,string,10);
								 intvTime->SetText(string);
								}
							  else intvTime->Clear();
							  intvTime->EnableWindow(true);
							  pressKey->EnableWindow(false);
							  pressKeyTit->EnableWindow(false);
							  pressKey->Clear();
							  break;

	case      NO_TIMER:
	default           : noActionOpt->Check();
							  intvTime->EnableWindow(false);
							  intvTimeTit->EnableWindow(false);
							  pressKey->EnableWindow(false);
							  pressKeyTit->EnableWindow(false);
							  pressKey->Clear();
							  intvTime->Clear();
							  break;
  }

 /* Session Special Options */
 if (connData->bringTop)
	 bringTop->Check();
	else bringTop->Uncheck();
 if (connData->actYale)
	 actYale->Check();
	else actYale->Uncheck();
 if (connData->connLog)
	 connLog->Check();
	else connLog->Uncheck();
 if (connData->soundAlm)
	 soundAlm->Check();
	else soundAlm->Uncheck();

 if (connData->monTime)
  {
	itoa(connData->monTime,string,10);
	monTime->SetText(string);
  }
 else monTime->Clear();

 /* Set Connection Terminal Type */
 termType->SetSelIndex(connData->termType);

 /* Set Connection Terminal Netname */
 if (connData->terminalNetName)
    {
     terminalNetName->Clear();
     terminalNetName->Insert(connData->terminalNetName);
	  terminalNetName->EnableWindow(true);
    }

 /* Set Connection Terminal Code Page */
 codePage->SetSelIndex(connData->codePage);

 /* Connection Script Processing Options */
 if (connData->scriptOn)
  {
	scriptOn->Check();
	if (connData->scriptFile)
	 {
	  scriptFile->Clear();
	  scriptFile->Insert(connData->scriptFile);
	  scriptTit->EnableWindow(true);
	  scriptFile->EnableWindow(true);
	  scriptBrowse->EnableWindow(true);
	 }
  }
  else
	{
	 scriptFile->Clear();
	 scriptOn->Uncheck();
	 scriptTit->EnableWindow(false);
	 scriptFile->EnableWindow(false);
	 scriptBrowse->EnableWindow(false);
	}

}

void
ALFFConnectDlg::CmHelp()
{
 /* Get the Application IniFile Pointer  */
 Tec3270App *theApp = TYPESAFE_DOWNCAST(GetApplication(),Tec3270App);
 ALFFHelp* helpFile = theApp->GetHelpFile();
 HWND helpWin = helpFile->ShowHelp(HH_HELP_CONTEXT, IDH_HELP_SESSION_CONFIG, IDH_POPUP_WINDOW);
 if (!helpWin)
   pMsgs->Message(IDS_ALFFHELPNOTAVAIL, IDS_TEC3270_HELP_ERR);
}

TResult
ALFFConnectDlg::EvCommand(uint controlId, THandle , uint notifyCode)
{
 struct ffblk fileInfo;
 char text[HOSTNAMELEN+1];
 char portN[8];
 char selConn[SESSNAMELEN+1];
 char* openScpTitle;
 char  scriptFileName[STRINGMSGLEN+1];
 char  scriptFileExt[STRINGMSGLEN+1];
 long timeCount;

 /*
  * controlId is the control identifier that is related to some
  * option on Connect Dialog.
  */

 switch (controlId)
  {
	/* Connect to PushButton Pressed */
	case			        IDOK: buttonPressed = IDOK;
                             ALFFDialog::CmOk();
									  break;

	/* Cancel Connect Operation PushButton Pressed */
	case		       IDCANCEL: buttonPressed = IDCANCEL;
                             ALFFDialog::CmCancel();
									  break;

	/* Save this Connection Configuration on Ini File */
	case 	   IDC_ALFFSESSADD: if (newConn)
										{
										 if (strlen(connData->connName))
										  {
											/* Add the new connection */
											if (connData->scriptOn &&
												 !strlen(connData->scriptFile))
											 {	 												  /* The Script File Name Was Not Found */
											  if (pMsgs->Message(IDS_SESSSCPTFILENOTFOUND,
															 IDS_ALFFSESSTITLE,true)== IDOK)
												{
												 scriptFile->SetFocus();
												 break;
												}
												else
												 {
												  connData->scriptFile[0]=NULL;
												  scriptFile->Clear();
												 }
											  }
											SaveConnection(connData->connName);
											AddConnection(connData->connName);
											connListBox->AddString(connData->connName);
											newConn = false;
										  }
										  else
											pMsgs->Message(IDS_SESSNAMEEMPTY,IDS_ALFFSESSTITLE);
										}
										else
										  pMsgs->Message(IDS_SESSALREADYEXIST,IDS_ALFFSESSTITLE);
									  break;

	/* Update this  Connection Parms*/
	case	IDC_ALFFSESSUPDATE: if (!newConn)
										{
										 /* Update the connection */
										 if (connData->scriptOn &&
												 !strlen(connData->scriptFile))
										  {	 												  /* The Script File Name Was Not Found */
											if (pMsgs->Message(IDS_SESSSCPTFILENOTFOUND,
															 IDS_ALFFSESSTITLE,true)== IDOK)
											 {
											  scriptFile->SetFocus();
											  break;
											 }
											 else
											  {
												connData->scriptFile[0]=NULL;
												scriptFile->Clear();
											  }
										  }
										 SaveConnection(connData->connName);
										}
										else
										  pMsgs->Message(IDS_SESSUPDONOTEXIST,IDS_ALFFSESSTITLE);
									  break;

	/* Delete this Connection Configuration from Ini File */
	case 	   IDC_ALFFSESSDEL: if (!newConn)
										{
										 if (pMsgs->Message(IDS_SESSSUREDEL,IDS_ALFFSESSTITLE, true)
												 == IDOK)
											{
											 /* Delete the connection and take it out from the list box*/
											 if (DeleteConnection(connData->connName))
											  {
												connListBox->DeleteString(connSelIndex);
												connData->connName[0]=NULL;
												UpdateDialog();
												newConn = true;
											  }
											  else
												pMsgs->Message(IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
											}
										}
										else
										  pMsgs->Message(IDS_SESSDONOTEXIST,IDS_ALFFSESSTITLE);
									  break;


	/* Help to this Dialog Fields */
	case            IDHELP: CmHelp();
									break;

	/* Select or Insert New Connection Parms */
	case 	IDC_ALFFSESSCOMBOX: switch (notifyCode)
										{
										 /* Combo box notification codes */
										 case   CBN_ERRSPACE: pMsgs->Message(IDS_SESSDLGERROR,
																						 IDS_ALFFSESSTITLE);
																	 break;

										 case   CBN_SETFOCUS:
										 case  CBN_SELCHANGE: connSelIndex = connListBox->GetSelIndex();
																	 connListBox->GetString(selConn,connSelIndex);
                                                    if (strcmp(connData->connName,selConn))
																	    { LoadConnection(selConn); }
																	 newConn = false;
																	 UpdateDialog();
																	 break;

										 case  CBN_KILLFOCUS: connListBox->GetText(connData->connName,SESSNAMELEN);
																	 connSelIndex = connListBox->GetSelIndex();
																	 connListBox->GetString(selConn,connSelIndex);
																	 if (strcmp(connData->connName,selConn))
																		newConn = true;
																	  else newConn = false;
																	 break;
										}
									  break;

	/* Select Host Name and Port Number   */
	case  IDC_ALFFHOSTNAME: if (notifyCode == EN_KILLFOCUS)
									 {
									  hostName->GetText(text,HOSTNAMELEN-1);
									  strcpy(connData->hostName,text);
									 }
									break;

	case  IDC_ALFFPORTNUMB: if (notifyCode == EN_KILLFOCUS)
									 {
									  portNumber->GetText(portN,6);
									  connData->portNumber = atoi(portN);
									 }
									break;

	case    IDC_ALFFUSESSLV2: if (connData->securityMethod == ALFFSSLComm::ALFFNONE)
									  {
										useSSLV2->Check();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV2;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV2)
									  {
										useSSLV2->Uncheck();
										connData->securityMethod = ALFFSSLComm::ALFFNONE;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV23)
									  {
										useSSLV2->Uncheck();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV3;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV3)
									  {
										useSSLV2->Check();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV23;
									  }
									 else  throw ALFFException(IDS_ALFFSSLMETHODERROR);
									break;

	case    IDC_ALFFUSESSLV3: if (connData->securityMethod == ALFFSSLComm::ALFFNONE)
									  {
										useSSLV3->Check();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV3;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV3)
									  {
										useSSLV3->Uncheck();
										connData->securityMethod = ALFFSSLComm::ALFFNONE;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV23)
									  {
										useSSLV3->Uncheck();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV2;
									  }
								    else if (connData->securityMethod == ALFFSSLComm::ALFFSSLV2)
									  {
										useSSLV3->Check();
										connData->securityMethod = ALFFSSLComm::ALFFSSLV23;
									  }
									 else  throw ALFFException(IDS_ALFFSSLMETHODERROR);
									break;

	/* Select or Insert When Disconnect Group Options */
	case 	IDC_ALFFWHENDISCGRP: switch(notifyCode)
										{
										  case      IDC_ALFFRECONNECT: if (notifyCode == BN_CLICKED)
																				  {
																					connData->connReconn=true;
																					connData->connExit=false;
																					connData->connDoNothing=false;
																				  }
																				 break;
										  case  IDC_ALFFSESSEXITCLOSE:  if (notifyCode == BN_CLICKED)
																				  {
																					connData->connReconn=false;
																					connData->connExit=true;
																					connData->connDoNothing=false;
																				  }
																				 break;
										  case  IDC_ALFFSESSDONOTHING: if (notifyCode == BN_CLICKED)
																				  {
																					connData->connReconn=false;
																					connData->connExit=false;
																					connData->connDoNothing=true;
																				  }
																				 break;
										  default      : pMsgs->Message( IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
															  break;
										}
										break;

	case      IDC_ALFFRECONNECT: if (notifyCode == BN_CLICKED)
											{
											 connData->connReconn=true;
											 connData->connExit=false;
											 connData->connDoNothing=false;
											}
										  break;
	case  IDC_ALFFSESSEXITCLOSE: if (notifyCode == BN_CLICKED)
											{
											 connData->connReconn=false;
											 connData->connExit=true;
											 connData->connDoNothing=false;
											}
										  break;
	case  IDC_ALFFSESSDONOTHING: if (notifyCode == BN_CLICKED)
											{
											 connData->connReconn=false;
											 connData->connExit=false;
											 connData->connDoNothing=true;
											}
										  break;

	/* Connection Timeouts Configurator */
	case 	IDC_ALFFPROGACT: switch(notifyCode)
								  {
									case   IDC_ALFFPROGTIMEOUT: if (notifyCode == BN_CLICKED)
																			{
																			 connData->actOption = CLOSE_TIMER;
																			 intvTimeTit->EnableWindow(true);
																			 intvTime->EnableWindow(true);
																			 pressKeyTit->EnableWindow(false);
                                                          pressKey->SetSelIndex(-1);
																			 pressKey->EnableWindow(false);
																			 pressKey->Clear();
																			}
																		 break;

									case     IDC_ALFFPROGIDLE:  if (notifyCode == BN_CLICKED)
																			{
																			 connData->actOption = IDLE_TIMER;
																			 intvTimeTit->EnableWindow(true);
																			 intvTime->EnableWindow(true);
																			 pressKeyTit->EnableWindow(true);
																			 pressKey->EnableWindow(true);
																			 pressKey->SetSelIndex(connData->pressKey);
																			}
																		 break;

									case  IDC_ALFFPROGPRESSKEY: if (notifyCode == BN_CLICKED)
																		  {
																			connData->actOption = KEY_TIMER;
																			intvTimeTit->EnableWindow(true);
																			intvTime->EnableWindow(true);
																			pressKeyTit->EnableWindow(true);
																			pressKey->EnableWindow(true);
																			pressKey->SetSelIndex(connData->pressKey);
																		  }
																		 break;

									case IDC_ALFFPROGDONOTHING: if (notifyCode == BN_CLICKED)
																		  {
																			connData->actOption = NO_TIMER;
																			intvTimeTit->EnableWindow(false);
																			intvTime->EnableWindow(false);
																			pressKeyTit->EnableWindow(false);
																			pressKey->SetSelIndex(-1);
																			pressKey->EnableWindow(false);
																			pressKey->Clear();
																		  }
																		 break;


													 default      : pMsgs->Message( IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
																		 break;
								  }
								  break;

	case   IDC_ALFFPROGTIMEOUT: if (notifyCode == BN_CLICKED)
											 {
											  connData->actOption = CLOSE_TIMER;
											  intvTimeTit->EnableWindow(true);
											  intvTime->EnableWindow(true);
											  pressKeyTit->EnableWindow(false);
											  pressKey->EnableWindow(false);
											  pressKey->SetSelIndex(-1);
											  pressKey->Clear();
											 }
										 break;

	case     IDC_ALFFPROGIDLE:  if (notifyCode == BN_CLICKED)
											 {
											  connData->actOption = IDLE_TIMER;
											  intvTimeTit->EnableWindow(true);
											  intvTime->EnableWindow(true);
											  pressKeyTit->EnableWindow(true);
											  pressKey->EnableWindow(true);
											  pressKey->SetSelIndex(connData->pressKey);
											 }
										 break;

	case  IDC_ALFFPROGPRESSKEY: if (notifyCode == BN_CLICKED)
											 {
											  connData->actOption = KEY_TIMER;
											  intvTimeTit->EnableWindow(true);
											  intvTime->EnableWindow(true);
											  pressKeyTit->EnableWindow(true);
											  pressKey->EnableWindow(true);
											  pressKey->SetSelIndex(connData->pressKey);
											 }
										 break;

	case IDC_ALFFPROGDONOTHING: if (notifyCode == BN_CLICKED)
											 {
											  connData->actOption = NO_TIMER;
											  intvTimeTit->EnableWindow(false);
											  intvTime->EnableWindow(false);
											  pressKeyTit->EnableWindow(false);
											  pressKey->EnableWindow(false);
                                   pressKey->SetSelIndex(-1);
											  pressKey->Clear();
											 }
											break;

	case  IDC_ALFFSESSINTVTIME: if (notifyCode == EN_CHANGE)
											  {
												intvTime->GetText(portN,6);
												timeCount = atol(portN);
											  }
											 else if (notifyCode == EN_KILLFOCUS)
											 {
											  intvTime->GetText(portN,6);
											  timeCount = atol(portN);
											  if (timeCount > 65535L)
												{
												 pMsgs->Message(IDS_SESSTIMEOUTERR,IDS_ALFFSESSTITLE);
												 intvTime->SetFocus();
												}
												else if (timeCount)
														{
														 connData->intvTime = (uint)timeCount;
														 pressKey->SetSelIndex(connData->pressKey);
														}
												else
														{
														 connData->intvTime = 0;
														 intvTime->Clear();
														 pressKey->SetSelIndex(-1);
														}
											  }
											break;

	case  IDC_ALFFSESSKEYPRESS: if (notifyCode == CBN_SELCHANGE)
											  connData->pressKey = pressKey->GetSelIndex();
											break;

	/* Selecting Terminal Configuration Like Sound Alarm, Nulls Processing...*/
	case  IDC_ALFFSESSBRINGTOP: if (connData->bringTop)
											 {
											  bringTop->Uncheck();
											  connData->bringTop = false;
											 }
											 else
											  {
												bringTop->Check();
												connData->bringTop = true;
											  }
											break;
	case  IDC_ALFFSESSYALENULL:   if (connData->actYale)
											 {
											  actYale->Uncheck();
											  connData->actYale = false;
											 }
											 else
											  {
												actYale->Check();
												connData->actYale = true;
											  }
											break;

	case       IDC_ALFFSESSLOG:   if (connData->connLog)
											 {
											  connLog->Uncheck();
											  connData->connLog = false;
											 }
											 else
											  {
												connLog->Check();
												connData->connLog = true;
											  }
											break;

	case  IDC_ALFFSESSSOUNDALM:   if (connData->soundAlm)
											 {
											  soundAlm->Uncheck();
											  connData->soundAlm = false;
											 }
											 else
											  {
												soundAlm->Check();
												connData->soundAlm = true;
											  }
											break;
	case   IDC_ALFFSESSMONTIME: if (notifyCode == EN_CHANGE)
											  {
												monTime->GetText(portN,6);
												timeCount = atol(portN);
											  }
											 else if (notifyCode == EN_KILLFOCUS)
											 {
											  monTime->GetText(portN,6);
											  timeCount = atol(portN);
											  if (timeCount > 65535L)
												{
												 pMsgs->Message(IDS_SESSTIMEOUTERR,IDS_ALFFSESSTITLE);
												 monTime->SetFocus();
												}
												else if (timeCount)
														 connData->monTime = (uint)timeCount;
												else
														{
														 connData->monTime = 0;
														 monTime->Clear();
														}
											  }
											break;

	/* Terminal Type, Netname, Code Page and Remote Printer on Host Configuration */
	case  IDC_ALFFSESSTERMTYPE:   if (notifyCode == CBN_SELCHANGE)
											 connData->termType = termType->GetSelIndex();
											break;
   case  IDC_ALFFTERMNETNAME:    if (notifyCode == EN_KILLFOCUS)
												terminalNetName->GetText(connData->terminalNetName,9);
											  break;

	case  IDC_ALFFSESSCODEPAGE:   if (notifyCode == CBN_SELCHANGE)
											 connData->codePage = codePage->GetSelIndex();
											break;

	/* Configure Session Terminal Colors  */
	case    IDC_ALFFSESSCOLORS: ALFFColorSelect(this,connData).Execute();
										 break;

   /* Configure Remote Printer */
	case  IDC_ALFFSESSREMPRT:   ALFFRemotePrinterDlg(this,connData).Execute();
										 break;

	/* Script Controls: On/Off, Select File Name, Browse File Name */
	case  IDC_ALFFSESSSCPTON:   if (!connData->scriptOn)
											 {
												connData->scriptOn=true;
												scriptOn->Check();
												if (connData->scriptFile)
												 {
												  scriptFile->Clear();
												  scriptFile->Insert(connData->scriptFile);
												  scriptTit->EnableWindow(true);
												  scriptFile->EnableWindow(true);
												  scriptBrowse->EnableWindow(true);
												 }
                                    scriptBrowse->SetFocus();
										    }
										 else
											  {
												connData->scriptOn=false;
												scriptFile->Clear();
												scriptOn->Uncheck();
												scriptTit->EnableWindow(false);
												scriptFile->EnableWindow(false);
												scriptBrowse->EnableWindow(false);
											  }
										 break;
	case  IDC_ALFFSESSSCPTFILENAME: if (notifyCode == EN_KILLFOCUS)
											  {
												scriptFile->GetText(connData->scriptFile,MAXPATH-1);
                                    if (strlen(connData->scriptFile))
                                     {
												  if (findfirst(connData->scriptFile,&fileInfo,0))
												  {
												   /* The Script File Name Was Not Found */
												   if (pMsgs->Message(IDS_SESSSCPTFILENOTFOUND,
																	  IDS_ALFFSESSTITLE,true)== IDOK)
													 scriptFile->SetFocus();
													else
													  {
														connData->scriptFile[0]=NULL;
														scriptFile->Clear();
													  }
												  }
                                     }
                                    else
                                     {
												  connData->scriptOn=false;
												  scriptFile->Clear();
												  scriptOn->Uncheck();
												  scriptTit->EnableWindow(false);
												  scriptFile->EnableWindow(false);
												  scriptBrowse->EnableWindow(false);
											    }
											  }
											  break;
	case  IDC_ALFFSCRPTBROWSE:    if (notifyCode == BN_CLICKED)
											 {
											  openScpTitle = new char[STRINGMSGLEN];
											  pMsgs->LoadString(IDS_ALFFSCRIPTFILE,scriptFileName,STRINGMSGLEN);
											  pMsgs->LoadString(IDS_ALFFSCRIPTFILEEXT,scriptFileExt,STRINGMSGLEN);
											  TOpenSaveDialog::TData
											  fileData(OFN_HIDEREADONLY  | OFN_NOCHANGEDIR |
														  OFN_FILEMUSTEXIST | OFN_SHOWHELP,
														  scriptFileName,
														  0,0,
														  scriptFileExt);
											  pMsgs->LoadString(IDS_ALFFSESSSCPTTITLE,
																	  openScpTitle,STRINGMSGLEN-1);
											  if (TFileOpenDialog(this, fileData,0,
														  openScpTitle).Execute() == IDOK)
												  {
													if (fileData.FileName[0])
													 {
													  /* Script File Supplied */
													  strcpy(connData->scriptFile,fileData.FileName);
													  scriptFile->Clear();
													  scriptFile->Insert(connData->scriptFile);
													 }
												  }
                                   delete [] openScpTitle;
                                   openScpTitle = NULL;
											 }
											break;
	default             : char msgString[STRINGMSGLEN];
								 char msgError[STRINGMSGLEN];
								 pMsgs->LoadString(IDS_SESSUNKNOWCOMMAND,msgString,STRINGMSGLEN);
								 sprintf(msgError,msgString,controlId, notifyCode);
								 pMsgs->StrMessage(msgError,IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
								 break;
  }

 return 1L;
}

///////////////////////////////////////////////////////////
// ALFFRemotePrinterDlg
// ====================
// Implementation Source
//
ALFFRemotePrinterDlg::ALFFRemotePrinterDlg (TWindow* parent,
											 ALFFConnData* cnnData):
											 ALFFDialog(parent, IDD_ALFFSESSREMPRT)
{
 /* Save Connection Data Address */
 connData  =  cnnData;
 clParent  =  parent;
 pMsgs  = new ALFFMsgs(this);

 /* Printer Options Objects */
 printerNetName = new TEdit(this,IDC_ALFFSESSRPRTNETNAME,9);
 printerInact   = new TCheckBox(this,IDC_ALFFSESSRPRTINACT);
 printerAssociated  = new TCheckBox(this,IDC_ALFFSESSRPRTASSOCIA);
 printerOnly    = new TCheckBox(this,IDC_ALFFSESSRPRTONLY);
 printerOnColor = new TCheckBox(this,IDC_ALFFSESSRPRTCOLOR);
 printerDimen = new TCheckBox(this,IDC_ALFFSESSRPRTDIMEN);
 printerIgnoreFF = new TCheckBox(this,IDC_ALFFSESSRPRTIGNOREFF);
 printerBreakLine = new TCheckBox(this,IDC_ALFFSESSRPRTBREAKLINE);
 printerTabWidth = new TEdit(this,IDC_ALFFSESSRPRTTABWIDTH,4);
 printerTabWidth->SetValidator(new TFilterValidator("0-9"));
 printerCharPerInch = new TComboBox(this,IDC_ALFFSESSRPRTCHARPERINCH);
 printerLinePerInch = new TComboBox(this,IDC_ALFFSESSRPRTLINEPERINCH);

 printerCharPerLine = new TEdit(this,IDC_ALFFSESSRPRTCHARPERLINE,4);
 printerCharPerLine->SetValidator(new TFilterValidator("0-9"));

 printerLinePerPage = new TEdit(this,IDC_ALFFSESSRPRTLINEPERPAGE,4);
 printerLinePerPage->SetValidator(new TFilterValidator("0-9"));

 printerTimeInact = new TEdit(this,IDC_ALFFSESSRPRTTIMEINACT,6);
 printerTimeInact->SetValidator(new TFilterValidator("0-9"));

 printerTimeConcat = new TEdit(this,IDC_ALFFSESSRPRTTIMECONCAT,6);
 printerTimeConcat->SetValidator(new TFilterValidator("0-9"));

 printerTimeEnd = new TEdit(this,IDC_ALFFSESSRPRTTIMEEND,6);
 printerTimeEnd->SetValidator(new TFilterValidator("0-9"));
 
 printerNullLine = new TCheckBox(this,IDC_ALFFSESSRPRTNULLINE);
 printerNullAsSpace = new TCheckBox(this,IDC_ALFFSESSRPRTNULLASSPACE);
 printerIgnoreAttr = new TCheckBox(this,IDC_ALFFSESSRPRTIGNOREATTR);
 printerFFAsSpace = new TCheckBox(this,IDC_ALFFSESSRPRTFFASSPACE);
 printerFFAnyPos = new TCheckBox(this,IDC_ALFFSESSRPRTFFANYPOS);
 printerEndLineNL = new TCheckBox(this,IDC_ALFFSESSRPRTENDLINENL);
 printerEndLineCR = new TCheckBox(this,IDC_ALFFSESSRPRTENDLINECR);
 printerSCSErr = new TCheckBox(this,IDC_ALFFSESSRPRTSCSERR);
 printerInheritParm = new TCheckBox(this,IDC_ALFFSESSRPRTHERITPARM);

 /* Temporarily Fields to save options and updating or not connData */
 tempPrinterNetName = new char[9];
 if (connData->printerNetName != NULL)
   strcpy(tempPrinterNetName, connData->printerNetName);
 else tempPrinterNetName[0] = NULL;

 tempPrinterInact = connData->printerInact;
 tempPrinterAssociated = connData->printerAssociated;
 tempPrinterOnly   = connData->printerOnly;
 tempPrinterOnColor = connData->printerOnColor;
 tempPrinterDimen = connData->printerDimen;
 tempPrinterIgnoreFF = connData->printerIgnoreFF;
 tempPrinterBreakLine = connData->printerBreakLine;
 tempPrinterTabWidth = connData->printerTabWidth;
 tempPrinterCharPerInch = connData->printerCharPerInch;
 tempPrinterLinePerInch = connData->printerLinePerInch;
 tempPrinterCharPerLine = connData->printerCharPerLine;
 tempPrinterLinePerPage = connData->printerLinePerPage;
 tempPrinterTimeInact = connData->printerTimeInact;
 tempPrinterTimeConcat = connData->printerTimeConcat;
 tempPrinterTimeEnd = connData->printerTimeEnd;
 tempPrinterNullLine = connData->printerNullLine;
 tempPrinterNullAsSpace = connData->printerNullAsSpace;
 tempPrinterIgnoreAttr = connData->printerIgnoreAttr;
 tempPrinterFFAsSpace = connData->printerFFAsSpace;
 tempPrinterFFAnyPos = connData->printerFFAnyPos;
 tempPrinterEndLineNL = connData->printerEndLineNL;
 tempPrinterEndLineCR = connData->printerEndLineCR;
 tempPrinterSCSErr = connData->printerSCSErr;
 tempprinterInheritParm = connData->printerInheritParm;
}

ALFFRemotePrinterDlg::~ALFFRemotePrinterDlg()
{
 delete pMsgs;
 delete [] tempPrinterNetName;

 /* Destroying Control Objects */
 delete printerNetName;
 delete printerInact;
 delete printerAssociated;
 delete printerOnly;
 delete printerOnColor;
 delete printerDimen;
 delete printerIgnoreFF;
 delete printerBreakLine;
 delete printerTabWidth;
 delete printerCharPerInch;
 delete printerLinePerInch;
 delete printerCharPerLine;
 delete printerLinePerPage;
 delete printerTimeInact;
 delete printerTimeConcat;
 delete printerTimeEnd;
 delete printerNullLine;
 delete printerNullAsSpace;
 delete printerIgnoreAttr;
 delete printerFFAsSpace;
 delete printerFFAnyPos;
 delete printerEndLineNL;
 delete printerEndLineCR;
 delete printerSCSErr;
 delete printerInheritParm;
}

void
ALFFRemotePrinterDlg::SetupWindow()
{
 /* Call Base Class Setup Window */
 ALFFDialog::SetupWindow();

 if (tempPrinterNetName != NULL)
   printerNetName->SetText(tempPrinterNetName);

if (tempPrinterInact)
   printerInact->Check();
 else printerInact->Uncheck();

 if (tempPrinterAssociated)
  {
   tempPrinterOnly = false;
   printerAssociated->Check();
   printerOnly->Uncheck();
  }
 else printerAssociated->Uncheck();

 if (tempPrinterOnly)
  {
   tempPrinterAssociated = false;
   printerAssociated->Uncheck();
   printerOnly->Check();
  }
 else printerOnly->Uncheck();


 if (tempPrinterOnColor)
   printerOnColor->Check();
 else printerOnColor->Uncheck();

 if (tempPrinterDimen)
   printerDimen->Check();
 else printerDimen->Uncheck();

 if (tempPrinterIgnoreFF)
   printerIgnoreFF->Check();
 else printerIgnoreFF->Uncheck();

 if (tempPrinterBreakLine)
   printerBreakLine->Check();
 else printerBreakLine->Uncheck();

 char temp[8];
 itoa(tempPrinterTabWidth, temp, 10);
 printerTabWidth->SetText(temp);

 itoa(tempPrinterCharPerInch, temp, 10);
 printerCharPerInch->ClearList();
printerCharPerInch->AddString("0");
 printerCharPerInch->AddString("10");
 printerCharPerInch->AddString("12");
 printerCharPerInch->AddString("17");
 printerCharPerInch->SetSelString(temp, 1);

 itoa(tempPrinterLinePerInch, temp, 10);
 printerLinePerInch->ClearList();
 printerLinePerInch->AddString("0");
 printerLinePerInch->AddString("2");
 printerLinePerInch->AddString("3");
 printerLinePerInch->AddString("4");
 printerLinePerInch->AddString("6");
 printerLinePerInch->AddString("8");
 printerLinePerInch->SetSelString(temp, 1);

 itoa(tempPrinterCharPerLine, temp, 10);
 printerCharPerLine->SetText(temp);

 itoa(tempPrinterLinePerPage, temp, 10);
 printerLinePerPage->SetText(temp);

 itoa(tempPrinterTimeInact, temp, 10);
 printerTimeInact->SetText(temp);

 itoa(tempPrinterTimeConcat, temp, 10);
 printerTimeConcat->SetText(temp);

 itoa(tempPrinterTimeEnd, temp, 10);
 printerTimeEnd->SetText(temp);

 printerNullLine->Uncheck();

 if (tempPrinterNullAsSpace)
   printerNullAsSpace->Check();
 else printerNullAsSpace->Uncheck();

 if (tempPrinterIgnoreAttr)
   printerIgnoreAttr->Check();
 else printerIgnoreAttr->Uncheck();

 if (tempPrinterFFAsSpace)
   printerFFAsSpace->Check();
 else printerFFAsSpace->Uncheck();

 if (tempPrinterFFAnyPos)
   printerFFAnyPos->Check();
 else printerFFAnyPos->Uncheck();

 if (tempPrinterEndLineNL)
   printerEndLineNL->Check();
 else printerEndLineNL->Uncheck();

 if (tempPrinterEndLineCR)
   printerEndLineCR->Check();
 else printerEndLineCR->Uncheck();

 if (tempPrinterSCSErr)
   printerSCSErr->Check();
 else printerSCSErr->Uncheck();

 if (tempprinterInheritParm)
   printerInheritParm->Check();
 else printerInheritParm->Uncheck();

 printerInact->EnableWindow(true);

 /* Enable or Not Printer Session Info depending upon Inact option */
 SetInact();
}

void
ALFFRemotePrinterDlg::SetInact()
{
 /* Enable or Not Printer Session Info depending upon Inact option */
 if (tempPrinterInact)
  {
 	printerNetName->EnableWindow(false);
   printerAssociated->EnableWindow(false);
   printerOnly->EnableWindow(false);
 	printerOnColor->EnableWindow(false);
 	printerDimen->EnableWindow(false);
 	printerIgnoreFF->EnableWindow(false);
 	printerBreakLine->EnableWindow(false);
 	printerTabWidth->EnableWindow(false);
 	printerCharPerInch->EnableWindow(false);
 	printerLinePerInch->EnableWindow(false);
 	printerCharPerLine->EnableWindow(false);
 	printerLinePerPage->EnableWindow(false);
 	printerTimeInact->EnableWindow(false);
 	printerTimeConcat->EnableWindow(false);
 	printerTimeEnd->EnableWindow(false);
 	printerNullLine->EnableWindow(false);
 	printerNullAsSpace->EnableWindow(false);
 	printerIgnoreAttr->EnableWindow(false);
 	printerFFAsSpace->EnableWindow(false);
 	printerFFAnyPos->EnableWindow(false);
 	printerEndLineNL->EnableWindow(false);
 	printerEndLineCR->EnableWindow(false);
 	printerSCSErr->EnableWindow(false);
 	printerInheritParm->EnableWindow(false);
  }
 else
  {
   if (tempPrinterAssociated)
     printerNetName->EnableWindow(false);
   else printerNetName->EnableWindow(true);
   printerAssociated->EnableWindow(true);
   printerOnly->EnableWindow(true);
   printerAssociated->EnableWindow(true);
   printerOnly->EnableWindow(true);
 	printerOnColor->EnableWindow(true);
 	printerDimen->EnableWindow(true);
 	printerIgnoreFF->EnableWindow(true);
 	printerBreakLine->EnableWindow(true);
 	printerTabWidth->EnableWindow(true);
 	printerCharPerInch->EnableWindow(true);
 	printerLinePerInch->EnableWindow(true);
 	printerCharPerLine->EnableWindow(true);
 	printerLinePerPage->EnableWindow(true);
 	printerTimeInact->EnableWindow(true);
 	printerTimeConcat->EnableWindow(true);
 	printerTimeEnd->EnableWindow(true);
 	printerNullLine->EnableWindow(false);
 	printerNullAsSpace->EnableWindow(true);
 	printerIgnoreAttr->EnableWindow(true);
 	printerFFAsSpace->EnableWindow(true);
 	printerFFAnyPos->EnableWindow(true);
 	printerEndLineNL->EnableWindow(true);
 	printerEndLineCR->EnableWindow(true);
 	printerSCSErr->EnableWindow(true);
 	printerInheritParm->EnableWindow(true);
  }
}

void
ALFFRemotePrinterDlg::CmOk()
{
 strcpy(connData->printerNetName, tempPrinterNetName);
 connData->printerAssociated = tempPrinterAssociated;
 connData->printerOnly   = tempPrinterOnly;
 connData->printerInact = tempPrinterInact;
 connData->printerOnColor = tempPrinterOnColor;
 connData->printerDimen = tempPrinterDimen;
 connData->printerIgnoreFF = tempPrinterIgnoreFF;
 connData->printerBreakLine = tempPrinterBreakLine;
 connData->printerTabWidth = tempPrinterTabWidth;
 connData->printerCharPerInch = tempPrinterCharPerInch;
 connData->printerLinePerInch = tempPrinterLinePerInch;
 connData->printerCharPerLine = tempPrinterCharPerLine;
 connData->printerLinePerPage = tempPrinterLinePerPage;
 connData->printerTimeInact = tempPrinterTimeInact;
 connData->printerTimeConcat = tempPrinterTimeConcat;
 connData->printerTimeEnd = tempPrinterTimeEnd;
 connData->printerNullLine = tempPrinterNullLine;
 connData->printerNullAsSpace = tempPrinterNullAsSpace;
 connData->printerIgnoreAttr = tempPrinterIgnoreAttr;
 connData->printerFFAsSpace = tempPrinterFFAsSpace;
 connData->printerFFAnyPos = tempPrinterFFAnyPos;
 connData->printerEndLineNL = tempPrinterEndLineNL;
 connData->printerEndLineCR = tempPrinterEndLineCR;
 connData->printerSCSErr = tempPrinterSCSErr;
 connData->printerInheritParm = tempprinterInheritParm;

 ALFFDialog::CmOk();
}

void
ALFFRemotePrinterDlg::CmHelp()
{
 /* Get the Application IniFile Pointer  */
 Tec3270App *theApp = TYPESAFE_DOWNCAST(GetApplication(),Tec3270App);
 ALFFHelp* helpFile = theApp->GetHelpFile();

 HWND helpWin = helpFile->ShowHelp(HH_HELP_CONTEXT, IDH_HELP_CONFIG_REMPRT, IDH_POPUP_WINDOW);
 if (!helpWin)
   pMsgs->Message(IDS_ALFFHELPNOTAVAIL, IDS_TEC3270_HELP_ERR);

}


LRESULT
ALFFRemotePrinterDlg::EvCommand(uint controlId, HWND , uint notifyCode)
{
 /*
  * controlId is the control identifier that is related to some
  * option on Connect Dialog.
  */
 int  selIndex;
 char tempChar[9];
 
 switch (controlId)
  {
	/* Connect to PushButton Pressed */
	case			        IDOK: CmOk();
									  break;

	/* Cancel Connect Operation PushButton Pressed */
	case		       IDCANCEL: ALFFDialog::CmCancel();
									  break;


	/* Help to this Dialog Fields */
	case            IDHELP: CmHelp();
									break;

	/* Change Standard Default Colors */
   case IDC_ALFFSESSRPRTNETNAME: if (notifyCode == EN_KILLFOCUS)
												printerNetName->GetText(tempPrinterNetName,9);
											break;

   case   IDC_ALFFSESSRPRTINACT: if (tempPrinterInact)
											   {
											    printerInact->Uncheck();
											    tempPrinterInact = false;
											   }
											else
											   {
											    printerInact->Check();
											    tempPrinterInact = true;
											   }

                                 SetInact();
                                 break;

   case IDC_ALFFSESSRPRTASSOCIA: if (tempPrinterAssociated)
											   {
											    printerAssociated->Uncheck();
											    tempPrinterAssociated = false;
                                     printerNetName->EnableWindow(true);
											   }
											  else
											   {
												 printerAssociated->Check();
												 tempPrinterAssociated = true;
                                     printerOnly->Uncheck();
                                     tempPrinterOnly = false;
                                     printerNetName->EnableWindow(false);
											   }
                                 break;

   case    IDC_ALFFSESSRPRTONLY: if (tempPrinterOnly)
											   {
											    printerOnly->Uncheck();
											    tempPrinterOnly = false;
											   }
                                 else
											   {
												 printerAssociated->Uncheck();
												 tempPrinterAssociated = false;
                                     printerOnly->Check();
                                     tempPrinterOnly = true;
                                     printerNetName->EnableWindow(true);
											   }
                                 break;

   case IDC_ALFFSESSRPRTCOLOR     :  if (tempPrinterOnColor)
											     {
											      printerOnColor->Uncheck();
											      tempPrinterOnColor = false;
											     }
											    else
											     {
											      printerOnColor->Check();
											      tempPrinterOnColor = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTDIMEN      : if (tempPrinterDimen)
											     {
											      printerDimen->Uncheck();
											      tempPrinterDimen = false;
											     }
											    else
											     {
											      printerDimen->Check();
											      tempPrinterDimen = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTIGNOREFF   : if (tempPrinterIgnoreFF)
											     {
											      printerIgnoreFF->Uncheck();
											      tempPrinterIgnoreFF = false;
											     }
											    else
											     {
											      printerIgnoreFF->Check();
											      tempPrinterIgnoreFF = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTBREAKLINE  : if (tempPrinterBreakLine)
											     {
											      printerBreakLine->Uncheck();
											      tempPrinterBreakLine = false;
											     }
											    else
											     {
											      printerBreakLine->Check();
											      tempPrinterBreakLine = true;
											     }
                                     break;

   case IDC_ALFFSESSRPRTTABWIDTH   : if (notifyCode == EN_KILLFOCUS)
                                      {
												   printerTabWidth->GetText(tempChar,4);
                                       tempPrinterTabWidth = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTCHARPERINCH: if (notifyCode == CBN_SELCHANGE)
                                      {
                                       selIndex = printerCharPerInch->GetSelIndex();
                                       printerCharPerInch->GetString(tempChar,selIndex);
                                       tempPrinterCharPerInch = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTLINEPERINCH: if (notifyCode == CBN_SELCHANGE)
                                      {
                                       selIndex = printerLinePerInch->GetSelIndex();
                                       printerLinePerInch->GetString(tempChar,selIndex);
                                       tempPrinterLinePerInch = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTCHARPERLINE: if (notifyCode == EN_KILLFOCUS)
                                      {
												    printerCharPerLine->GetText(tempChar,4);
                                        tempPrinterCharPerLine = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTLINEPERPAGE: if (notifyCode == EN_KILLFOCUS)
												  {
                                       printerLinePerPage->GetText(tempChar,4);
                                       tempPrinterLinePerPage= atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTTIMEINACT  : if (notifyCode == EN_KILLFOCUS)
												  {
                                       printerTimeInact->GetText(tempChar,5);
                                       tempPrinterTimeInact = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTTIMECONCAT : if (notifyCode == EN_KILLFOCUS)
												  {
                                       printerTimeConcat->GetText(tempChar,5);
                                       tempPrinterTimeConcat = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTTIMEEND    : if (notifyCode == EN_KILLFOCUS)
												  {
                                       printerTimeEnd->GetText(tempChar,5);
                                       tempPrinterTimeEnd = atoi(tempChar);
                                      }
                                     break;

   case IDC_ALFFSESSRPRTNULLINE    : if (tempPrinterNullLine)
											     {
											      printerNullLine->Uncheck();
											      tempPrinterNullLine = false;
											     }
											    else
											     {
											      printerNullLine->Check();
											      tempPrinterNullLine = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTNULLASSPACE: if (tempPrinterNullAsSpace)
											     {
											      printerNullAsSpace->Uncheck();
											      tempPrinterNullAsSpace = false;
											     }
											    else
											     {
											      printerNullAsSpace->Check();
											      tempPrinterNullAsSpace = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTIGNOREATTR : if (tempPrinterIgnoreAttr)
											     {
											      printerIgnoreAttr->Uncheck();
											      tempPrinterIgnoreAttr = false;
											     }
											    else
											     {
											      printerIgnoreAttr->Check();
											      tempPrinterIgnoreAttr = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTFFASSPACE  : if (tempPrinterFFAsSpace)
											     {
											      printerFFAsSpace->Uncheck();
											      tempPrinterFFAsSpace = false;
											     }
											    else
											     {
											      printerFFAsSpace->Check();
											      tempPrinterFFAsSpace = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTFFANYPOS   : if (tempPrinterFFAnyPos)
											     {
											      printerFFAnyPos->Uncheck();
											      tempPrinterFFAnyPos = false;
											     }
											    else
											     {
											      printerFFAnyPos->Check();
											      tempPrinterFFAnyPos = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTENDLINENL  : if (tempPrinterEndLineNL)
											     {
											      printerEndLineNL->Uncheck();
											      tempPrinterEndLineNL = false;
											     }
											    else
											     {
											      printerEndLineNL->Check();
											      tempPrinterEndLineNL = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTENDLINECR  : if (tempPrinterEndLineCR)
											     {
											      printerEndLineCR->Uncheck();
											      tempPrinterEndLineCR = false;
											     }
											    else
											     {
											      printerEndLineCR->Check();
											      tempPrinterEndLineCR = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTSCSERR     : if (tempPrinterSCSErr)
											     {
											      printerSCSErr->Uncheck();
											      tempPrinterSCSErr = false;
											     }
											    else
											     {
											      printerSCSErr->Check();
											      tempPrinterSCSErr = true;
											     }
                                     break;
   case IDC_ALFFSESSRPRTHERITPARM  : if (tempprinterInheritParm)
											     {
											      printerBreakLine->Uncheck();
											      tempPrinterBreakLine = false;
											     }
											    else
											     {
											      printerBreakLine->Check();
											      tempPrinterBreakLine = true;
											     }
                                     break;

	default      : pMsgs->Message( IDS_SESSDLGERROR,IDS_ALFFSESSTITLE);
						break;
  }

 return 1L;
}
