home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 19 Printer
/
19-Printer.zip
/
LAPRINT.ZIP
/
LAPRINT0.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-23
|
148KB
|
3,004 lines
/************************************************************************
* *
* (c) Cray Research, Inc., 1991. All rights reserved. *
* *
* This program and/or module and all modifications made by Cray *
* Research, Inc., are the sole property of Cray Research, Inc., and *
* shall not be made available to or used by any person or persons *
* without the prior written permission of Cray Research, Inc. *
* *
* Programs and/or modules which are deemed in the public domain or *
* whose copyright is held by another legal entity other than Cray *
* Research, Inc., shall be deemed excluded from the above named *
* restrictions and protections. *
* *
* All changes made by Cray Research Inc which represent original *
* work, modifications, descriptions or ideas to the above excluded *
* programs and/or modules shall not be made available to or used by *
* any person or persons without the prior written permission of *
* Cray Research, Inc. *
* *
************************************************************************/
#define EXTERN extern
#include "LAPRINT.h"
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY CFGOPENMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static CHAR szCRI_Copyright[]="(c) Cray Research, Inc., 1991.";
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
CFGOPENStruct FAR *Cfgopen;
switch(message)
{
case WM_INITDLG:
Cfgopen = (CFGOPENStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CFGOPEN);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize entry field control: szConfig_Directory */
WinSendDlgItemMsg(hWndDlg, DID_CURRENT_DIR, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
if(Cfgopen->szConfig_Directory[0])
WinSetDlgItemText(hWndDlg, DID_CURRENT_DIR, Cfgopen->szConfig_Directory);
/* Initialize entry field control: szConfig_Filename */
WinSendDlgItemMsg(hWndDlg, DID_CONFIG_FN, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
if(Cfgopen->szConfig_Filename[0])
WinSetDlgItemText(hWndDlg, DID_CONFIG_FN, Cfgopen->szConfig_Filename);
/* Initialize list box control: */
cwFillDirListBox(hWndDlg, DID_DIRECTORY, DID_CURRENT_DIR);
/* Initialize list box control: */
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_CURRENT_DIR)),
FALSE);
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_CONFIG_FN)),
FALSE);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_CURRENT_DIR: /* Entry field variable: "szConfig_Directory" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_CONFIG_FN: /* Entry field variable: "szConfig_Filename" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_DIRECTORY: /* List box */
{
USHORT sSelect; /* index to selected listbox item */
USHORT CurDisk; /* number of the current disk */
ULONG DriveMap; /* logical drive map */
CHAR szBuffer[100];
/* If the user has not pressed enter or double clicked */
/* the mouse on an item, then break out of this case */
if(SHORT2FROMMP(mp1) != LN_ENTER)
break;
/* Determine the index to the selected item */
sSelect = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1),
LM_QUERYSELECTION,
0L, 0L);
/* Query the text of the selected item */
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1),
LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelect, sizeof(szBuffer)),
MPFROMP(szBuffer));
/* Is the selected item a drive or directory */
if(szBuffer[0] == '[' &&
szBuffer[2] == ':' &&
szBuffer[3] == ']')
{
/* Save current drive in case of error */
DosQCurDisk(&CurDisk, &DriveMap);
/* Log to new drive, on error restore to previous */
if(DosSelectDisk(szBuffer[1] - '@') != 0)
DosSelectDisk(CurDisk);
/* Fill the listbox with new directory information */
/* if an error occurs, restore to previous drive */
if(cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR) == -1)
{
WinLoadString(hAB, 0, IDS_DISK_ERR,
sizeof(szBuffer), szBuffer);
WinMessageBox(HWND_DESKTOP, hWndDlg,
szBuffer, szAppName,
0, MB_OK | MB_INFORMATION);
DosSelectDisk(CurDisk);
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR);
}
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
}
else /* A directory was selected */
{
/* Change to new directory */
DosChDir(szBuffer, 0L);
/* Fill the listbox with new directory information */
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR);
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
}
}
break;
case DID_FILES: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
WinSetDlgItemText(hWndDlg, DID_CONFIG_FN, szSelectText);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Open" */
Cfgopen = (CFGOPENStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CFGOPEN);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CURRENT_DIR,
sizeof(Cfgopen->szConfig_Directory),
Cfgopen->szConfig_Directory);
if(Cfgopen->szConfig_Directory[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Directory field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CURRENT_DIR));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CONFIG_FN,
sizeof(Cfgopen->szConfig_Filename),
Cfgopen->szConfig_Filename);
if(Cfgopen->szConfig_Filename[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Configuration filename field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CONFIG_FN));
break;
}
if(BgmReadConfigFile(hWndDlg) == TRUE)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of CFGOPENMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY CFGSAVEMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
CFGSAVEStruct FAR *Cfgsave;
switch(message)
{
case WM_INITDLG:
Cfgsave = (CFGSAVEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CFGSAVE);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize entry field control: szConfig_Directory */
WinSendDlgItemMsg(hWndDlg, DID_CURRENT_DIR, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
if(Cfgsave->szConfig_Directory[0])
WinSetDlgItemText(hWndDlg, DID_CURRENT_DIR, Cfgsave->szConfig_Directory);
/* Initialize entry field control: szConfig_Filename */
WinSendDlgItemMsg(hWndDlg, DID_CONFIG_FN, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
if(Cfgsave->szConfig_Filename[0])
WinSetDlgItemText(hWndDlg, DID_CONFIG_FN, Cfgsave->szConfig_Filename);
/* Initialize list box control: */
cwFillDirListBox(hWndDlg, DID_DIRECTORY, DID_CURRENT_DIR);
/* Initialize list box control: */
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_CURRENT_DIR)),
FALSE);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_CURRENT_DIR: /* Entry field variable: "szConfig_Directory" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_CONFIG_FN: /* Entry field variable: "szConfig_Filename" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_DIRECTORY: /* List box */
{
USHORT sSelect; /* index to selected listbox item */
USHORT CurDisk; /* number of the current disk */
ULONG DriveMap; /* logical drive map */
CHAR szBuffer[100];
/* If the user has not pressed enter or double clicked */
/* the mouse on an item, then break out of this case */
if(SHORT2FROMMP(mp1) != LN_ENTER)
break;
/* Determine the index to the selected item */
sSelect = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1),
LM_QUERYSELECTION,
0L, 0L);
/* Query the text of the selected item */
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1),
LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelect, sizeof(szBuffer)),
MPFROMP(szBuffer));
/* Is the selected item a drive or directory */
if(szBuffer[0] == '[' &&
szBuffer[2] == ':' &&
szBuffer[3] == ']')
{
/* Save current drive in case of error */
DosQCurDisk(&CurDisk, &DriveMap);
/* Log to new drive, on error restore to previous */
if(DosSelectDisk(szBuffer[1] - '@') != 0)
DosSelectDisk(CurDisk);
/* Fill the listbox with new directory information */
/* if an error occurs, restore to previous drive */
if(cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR) == -1)
{
WinLoadString(hAB, 0, IDS_DISK_ERR,
sizeof(szBuffer), szBuffer);
WinMessageBox(HWND_DESKTOP, hWndDlg,
szBuffer, szAppName,
0, MB_OK | MB_INFORMATION);
DosSelectDisk(CurDisk);
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR);
}
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
}
else /* A directory was selected */
{
/* Change to new directory */
DosChDir(szBuffer, 0L);
/* Fill the listbox with new directory information */
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_CURRENT_DIR);
cwFillFileListBox(hWndDlg, "*.ini", DID_FILES);
}
}
break;
case DID_FILES: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
WinSetDlgItemText(hWndDlg, DID_CONFIG_FN, szSelectText);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Save" */
Cfgsave = (CFGSAVEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CFGSAVE);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CURRENT_DIR,
sizeof(Cfgsave->szConfig_Directory),
Cfgsave->szConfig_Directory);
if(Cfgsave->szConfig_Directory[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Directory field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CURRENT_DIR));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CONFIG_FN,
sizeof(Cfgsave->szConfig_Filename),
Cfgsave->szConfig_Filename);
if(Cfgsave->szConfig_Filename[0] == 0 ||
isspace((int)Cfgsave->szConfig_Filename[0]) != 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Configuration filename field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CONFIG_FN));
break;
}
if(BgmWriteConfigFile(hWndDlg,
FALSE)
== TRUE)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of CFGSAVEMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY FSELECTMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
FSELECTStruct FAR *Fselect;
switch(message)
{
case WM_INITDLG:
Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_FSELECT);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize entry field control: szSelected_Directory */
WinSendDlgItemMsg(hWndDlg, DID_SELECTED_DIR, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
if(Fselect->szSelected_Directory[0])
WinSetDlgItemText(hWndDlg, DID_SELECTED_DIR, Fselect->szSelected_Directory);
/* Initialize entry field control: szSelected_Filename */
WinSendDlgItemMsg(hWndDlg, DID_SELECTED_FN, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
/* Initialize list box control: */
cwFillDirListBox(hWndDlg, DID_DIRECTORY, DID_SELECTED_DIR);
/* Initialize list box control: */
cwFillFileListBox(hWndDlg, "*.*", DID_FILES);
if(BgmPrintActive == TRUE)
{
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_PRINT)),
FALSE);
}
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_SELECTED_DIR)),
FALSE);
WinEnableWindow((WinWindowFromID(hWndDlg,
DID_SELECTED_FN)),
FALSE);
hWndFSELECT = hWndDlg;
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_SELECTED_DIR: /* Entry field variable: "szSelected_Directory" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_SELECTED_FN: /* Entry field variable: "szSelected_Filename" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_DIRECTORY: /* List box */
{
USHORT sSelect; /* index to selected listbox item */
USHORT CurDisk; /* number of the current disk */
ULONG DriveMap; /* logical drive map */
CHAR szBuffer[100];
/* If the user has not pressed enter or double clicked */
/* the mouse on an item, then break out of this case */
if(SHORT2FROMMP(mp1) != LN_ENTER)
break;
/* Determine the index to the selected item */
sSelect = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1),
LM_QUERYSELECTION,
0L, 0L);
/* Query the text of the selected item */
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1),
LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelect, sizeof(szBuffer)),
MPFROMP(szBuffer));
/* Is the selected item a drive or directory */
if(szBuffer[0] == '[' &&
szBuffer[2] == ':' &&
szBuffer[3] == ']')
{
/* Save current drive in case of error */
DosQCurDisk(&CurDisk, &DriveMap);
/* Log to new drive, on error restore to previous */
if(DosSelectDisk(szBuffer[1] - '@') != 0)
DosSelectDisk(CurDisk);
/* Fill the listbox with new directory information */
/* if an error occurs, restore to previous drive */
if(cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_SELECTED_DIR) == -1)
{
WinLoadString(hAB, 0, IDS_DISK_ERR,
sizeof(szBuffer), szBuffer);
WinMessageBox(HWND_DESKTOP, hWndDlg,
szBuffer, szAppName,
0, MB_OK | MB_INFORMATION);
DosSelectDisk(CurDisk);
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_SELECTED_DIR);
}
cwFillFileListBox(hWndDlg, "*.*", DID_FILES);
}
else /* A directory was selected */
{
/* Change to new directory */
DosChDir(szBuffer, 0L);
/* Fill the listbox with new directory information */
cwFillDirListBox(hWndDlg, SHORT1FROMMP(mp1), DID_SELECTED_DIR);
cwFillFileListBox(hWndDlg, "*.*", DID_FILES);
}
}
break;
case DID_FILES: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
WinSetDlgItemText(hWndDlg, DID_SELECTED_FN, szSelectText);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Enter" */
Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_FSELECT);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_DIR,
sizeof(Fselect->szSelected_Directory),
Fselect->szSelected_Directory);
if(Fselect->szSelected_Directory[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Directory field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_DIR));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_FN,
sizeof(Fselect->szSelected_Filename),
Fselect->szSelected_Filename);
if(Fselect->szSelected_Filename[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Filename field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_FN));
break;
}
hWndFSELECT = 0;
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_PRINT: /* Button text: "Print" */
Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_FSELECT);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_DIR,
sizeof(Fselect->szSelected_Directory),
Fselect->szSelected_Directory);
if(Fselect->szSelected_Directory[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Directory field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_DIR));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_FN,
sizeof(Fselect->szSelected_Filename),
Fselect->szSelected_Filename);
if(Fselect->szSelected_Filename[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Filename field not completed");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_FN));
break;
}
if (!WinIsWindow(hAB, hWndFSELECTDID_PRINTObject))
{
/* if the window is not a valid window, allocate memory */
/* for the thread's stack */
DosAllocSeg(4096, &FSELECTDID_PRINTObjSel, SEG_NONSHARED);
FSELECTDID_PRINTObjStack = (CHAR *)MAKEP(FSELECTDID_PRINTObjSel, 0);
_beginthread((void FAR *)FSELECTDID_PRINTObjFunction, FSELECTDID_PRINTObjStack, 4096, 0);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
hWndFSELECT = 0;
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of FSELECTMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY SELPRTERMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
SELPRTERStruct FAR *Selprter;
CHAR *result;
switch(message)
{
case WM_INITDLG:
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SELPRTER);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize entry field control: szSelected_Printer_Name */
WinSendDlgItemMsg(hWndDlg, DID_SELECTED_PRINTER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
for (i=0; i < 128; i++)
if (Selprter->szPrinter_List[i][0])
WinSendDlgItemMsg(hWndDlg, DID_PRINTER_LIST, LM_INSERTITEM,
MPFROM2SHORT(LIT_SORTASCENDING, 0),
MPFROMP(Selprter->szPrinter_List[i]));
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_SELECTED_PRINTER_NAME: /* Entry field variable: "szSelected_Printer_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_SELECTED_PRINTER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_PRINTER_LIST: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
/*****************************************************
* *
* This section separates the printer name from *
* its description and then loads just the name. *
* *
*****************************************************/
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg, DID_SELECTED_PRINTER_NAME, szSelectText);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Select" */
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SELPRTER);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_PRINTER_NAME,
sizeof(Selprter->szSelected_Printer_Name),
Selprter->szSelected_Printer_Name);
if(Selprter->szSelected_Printer_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Printer name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_PRINTER_NAME));
break;
}
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of SELPRTERMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY PRTERADDMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
PRTERADDStruct FAR *Prteradd;
static INT free_entry; /* Number of first free entry in the printer table. */
SELPRTERStruct FAR *Selprter;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELPRTER);
switch(message)
{
case WM_INITDLG:
Prteradd = (PRTERADDStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTERADD);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_PRINTER_LIST,
Selprter->szPrinter_List,
"Printer list is full. You will need to remove a printer in order to add one.",
TRUE);
if((free_entry = Return_Values->free_entry) == -1)
{
break;
}
/* Initialize entry field control: szAdd_Printer_Name */
WinSendDlgItemMsg(hWndDlg, DID_ADD_PRINTER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
/* Initialize entry field control: szAdd_Printer_Desc */
WinSendDlgItemMsg(hWndDlg, DID_ADD_PRINTER_DESC, EM_SETTEXTLIMIT, MPFROMSHORT(103), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_ADD_PRINTER_NAME: /* Entry field variable: "szAdd_Printer_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_ADD_PRINTER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_ADD_PRINTER_DESC: /* Entry field variable: "szAdd_Printer_Desc" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_PRINTER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the printer list the *
* entry pointed to by the end-user. We break it *
* into its two components (name and description).*
* We then load these components into their *
* respective fields. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT sSelectIndex;
CHAR szSelectText[129];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_ADD_PRINTER_NAME,
(PSZ) result);
result = strchr(szSelectText,'\0');
*result++;
WinSetDlgItemText(hWndDlg,
DID_ADD_PRINTER_DESC,
result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Add" */
Prteradd = (PRTERADDStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTERADD);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_ADD_PRINTER_NAME,
sizeof(Prteradd->szAdd_Printer_Name),
Prteradd->szAdd_Printer_Name);
if(Prteradd->szAdd_Printer_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Printer name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_ADD_PRINTER_NAME));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_ADD_PRINTER_DESC,
sizeof(Prteradd->szAdd_Printer_Desc),
Prteradd->szAdd_Printer_Desc);
if(BgmAddPrtSrv(hWndDlg,
DID_ADD_PRINTER_NAME,
free_entry,
Selprter->szPrinter_List,
Prteradd->szAdd_Printer_Name,
Prteradd->szAdd_Printer_Desc,
"Printer name duplication. Push retry to change printer name or push cancel to abort.")
== TRUE)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of PRTERADDMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY PRTERDELMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
PRTERDELStruct FAR *Prterdel;
static INT last_entry; /* Number of last acrive entry in the printer table. */
SELPRTERStruct FAR *Selprter;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELPRTER);
switch(message)
{
case WM_INITDLG:
Prterdel = (PRTERDELStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTERDEL);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_PRINTER_LIST,
Selprter->szPrinter_List,
"A printer does not exist to delete. The printer list is empty.",
FALSE);
if((last_entry = Return_Values->last_entry) == -1)
{
break;
}
/* Initialize entry field control: szDelete_Printer_Name */
WinSendDlgItemMsg(hWndDlg, DID_DELETE_PRINTER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_DELETE_PRINTER_NAME: /* Entry field variable: "szDelete_Printer_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_DELETE_PRINTER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_PRINTER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the printer list the *
* entry pointed to by the end-user. We breakout *
* of its the name component and then load the *
* name into its field. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT sSelectIndex;
CHAR szSelectText[25];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_DELETE_PRINTER_NAME,
(PSZ) result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Delete" */
Prterdel = (PRTERDELStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTERDEL);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_DELETE_PRINTER_NAME,
sizeof(Prterdel->szDelete_Printer_Name),
Prterdel->szDelete_Printer_Name);
if(Prterdel->szDelete_Printer_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Printer name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_DELETE_PRINTER_NAME));
break;
}
if(BgmDeletePrtSrv(hWndDlg,
DID_DELETE_PRINTER_NAME,
last_entry,
Selprter->szPrinter_List,
Prterdel->szDelete_Printer_Name,
"Printer name not found. Push retry to change printer name or push cancel to abort.")
== TRUE)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of PRTERDELMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY PRTCHANGMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
PRTCHANGStruct FAR *Prtchang;
static INT Selected_Entry_Number;
SELPRTERStruct FAR *Selprter;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELPRTER);
switch(message)
{
case WM_INITDLG:
Prtchang = (PRTCHANGStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTCHANG);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Selected_Entry_Number = -1;
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_PRINTER_LIST,
Selprter->szPrinter_List,
"A printer does not exist to change. The printer list is empty.",
FALSE);
if (Return_Values->last_entry == -1)
{
break;
}
/* Initialize entry field control: szChange_Printer_Name */
WinSendDlgItemMsg(hWndDlg, DID_CHANGE_PRINTER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
/* Initialize entry field control: szChange_Printer_Desc */
WinSendDlgItemMsg(hWndDlg, DID_CHANGE_PRINTER_DESC, EM_SETTEXTLIMIT, MPFROMSHORT(103), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_CHANGE_PRINTER_NAME: /* Entry field variable: "szChange_Printer_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_CHANGE_PRINTER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_CHANGE_PRINTER_DESC: /* Entry field variable: "szChange_Printer_Desc" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_PRINTER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the printer list the *
* entry pointed to by the end-user. We break it *
* into its two components (name and description).*
* We then load these components into their *
* respective fields. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT sSelectIndex;
CHAR szSelectText[129];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
/*****************************************************
* *
* This section finds the printer entry the user *
* just selected. The change key (DID_OK) code *
* uses this number to indicate which entry the *
* user is changing. This approach permits the *
* end-user to change both the name and *
* description instead of just the name. *
* *
*****************************************************/
for(i=0; i < 128; i++)
{
if (Selprter->szPrinter_List[i][0])
{
if(strnicmp(Selprter->szPrinter_List[i],
szSelectText,
strlen(szSelectText)) == 0)
{
Selected_Entry_Number = i;
break;
}
}
}
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_CHANGE_PRINTER_NAME,
(PSZ) result);
result = strchr(szSelectText,'\0');
*result++;
WinSetDlgItemText(hWndDlg,
DID_CHANGE_PRINTER_DESC,
result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Change" */
Prtchang = (PRTCHANGStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_PRTCHANG);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CHANGE_PRINTER_NAME,
sizeof(Prtchang->szChange_Printer_Name),
Prtchang->szChange_Printer_Name);
if(Prtchang->szChange_Printer_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Printer name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CHANGE_PRINTER_NAME));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CHANGE_PRINTER_DESC,
sizeof(Prtchang->szChange_Printer_Desc),
Prtchang->szChange_Printer_Desc);
if(BgmChangePrtSrv(hWndDlg,
DID_CHANGE_PRINTER_NAME,
Selected_Entry_Number,
Selprter->szPrinter_List,
Prtchang->szChange_Printer_Name,
Prtchang->szChange_Printer_Desc,
"Printer name not found. Push retry to change printer name or push cancel to abort.")
!= -1)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of PRTCHANGMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY SELSERVMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
SELSERVStruct FAR *Selserv;
CHAR *result;
switch(message)
{
case WM_INITDLG:
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SELSERV);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize entry field control: szSelected_Server_Name */
WinSendDlgItemMsg(hWndDlg, DID_SELECTED_SERVER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
for (i=0; i < 128; i++)
if (Selserv->szServer_List[i][0])
WinSendDlgItemMsg(hWndDlg, DID_SERVER_LIST, LM_INSERTITEM,
MPFROM2SHORT(LIT_SORTASCENDING, 0),
MPFROMP(Selserv->szServer_List[i]));
/* Initialize check box control: ckSelected_UNIX_Format */
WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT, BM_SETCHECK,
MPFROMSHORT(Selserv->ckSelected_UNIX_Format), 0L);
/***************************************************************
* *
* This section insures the UNIX format checks are the *
* same both in this dialog and on the pulldown. The *
* pulldown is the master control except when processing *
* this dialog's DID_OK (Select button) message. *
* *
***************************************************************/
if ((SHORT) WinSendMsg(WinWindowFromID(hWndFrame, FID_MENU),
MM_QUERYITEMATTR,
MPFROM2SHORT(IDM_O_UNIXFORMAT, TRUE),
MPFROMSHORT(MIA_CHECKED))
== MIA_CHECKED)
{
Selserv->ckSelected_UNIX_Format = TRUE;
}
else
{
Selserv->ckSelected_UNIX_Format = FALSE;
}
WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT, BM_SETCHECK,
MPFROMSHORT(Selserv->ckSelected_UNIX_Format), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_UNIX_FORMAT: /* Checkbox text: "Use UNIX format" */
{
USHORT checked;
/* Query check box control for current state */
/* on return checked is set to: */
/* 1 if check box is in unchecked state */
/* 0 if check box is in checked state */
checked = !WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT,
BM_QUERYCHECK, 0L, 0L );
/* Set checkbox control state */
WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT,
BM_SETCHECK, MPFROMSHORT(checked), 0L);
}
break;
case DID_SELECTED_SERVER_NAME: /* Entry field variable: "szSelected_Server_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_SELECTED_SERVER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_SERVER_LIST: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
USHORT checked;
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELSERV);
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
/*****************************************************
* *
* This section sets the UNIX format check box *
* based upon the entry selected by the end-user. *
* We need to scan through the server list to *
* find the selected entry and then use the *
* server UNIX format array to set the box. *
* *
*****************************************************/
for(i=0; i < 128; i++)
{
if (Selserv->szServer_List[i][0])
{
if(strnicmp(Selserv->szServer_List[i],
szSelectText,
strlen(szSelectText)) == 0)
{
checked = (USHORT) Selserv->ckServer_UNIX_Format[i];
WinSendDlgItemMsg(hWndDlg,
DID_UNIX_FORMAT,
BM_SETCHECK,
MPFROMSHORT(checked),
0L);
break;
}
}
}
/*****************************************************
* *
* This section separates the server name from *
* its description and then loads just the name. *
* *
*****************************************************/
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg, DID_SELECTED_SERVER_NAME, szSelectText);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Select" */
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SELSERV);
/* Query the check box control for its current state, */
/* and set the dialog structure variable */
Selserv->ckSelected_UNIX_Format =
(INT)(WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT,
BM_QUERYCHECK, 0L, 0L));
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_SELECTED_SERVER_NAME,
sizeof(Selserv->szSelected_Server_Name),
Selserv->szSelected_Server_Name);
if(Selserv->szSelected_Server_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Server name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_SELECTED_SERVER_NAME));
break;
}
/*******************************************************
* *
* This section sets the UNIX format pulldown check *
* value based upon the selected server's value. *
* *
*******************************************************/
if(Selserv->ckSelected_UNIX_Format == TRUE)
{
i = MIA_CHECKED;
}
else
{
i = FALSE;
}
WinSendMsg(WinWindowFromID(hWndFrame, FID_MENU),
MM_SETITEMATTR,
MPFROM2SHORT(IDM_O_UNIXFORMAT, TRUE),
MPFROM2SHORT(MIA_CHECKED, i));
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of SELSERVMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY ADDSERVMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
ADDSERVStruct FAR *Addserv;
static INT free_entry; /* Number of first free entry in the server table. */
SELSERVStruct FAR *Selserv;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELSERV);
switch(message)
{
case WM_INITDLG:
Addserv = (ADDSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_ADDSERV);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_SERVER_LIST,
Selserv->szServer_List,
"Server list is full. You will need to remove a server in order to add one.",
TRUE);
if((free_entry = Return_Values->free_entry) == -1)
{
break;
}
/* Initialize entry field control: szAdd_Server_Name */
WinSendDlgItemMsg(hWndDlg, DID_ADD_SERVER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
/* Initialize entry field control: szAdd_Server_Desc */
WinSendDlgItemMsg(hWndDlg, DID_ADD_SERVER_DESC, EM_SETTEXTLIMIT, MPFROMSHORT(103), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_UNIX_FORMAT: /* Checkbox text: "Use UNIX format" */
{
USHORT checked;
/* Query check box control for current state */
/* on return checked is set to: */
/* 1 if check box is in unchecked state */
/* 0 if check box is in checked state */
checked = !WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT,
BM_QUERYCHECK, 0L, 0L );
/* Set checkbox control state */
WinSendDlgItemMsg(hWndDlg, DID_UNIX_FORMAT,
BM_SETCHECK, MPFROMSHORT(checked), 0L);
}
break;
case DID_ADD_SERVER_NAME: /* Entry field variable: "szAdd_Server_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_ADD_SERVER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_ADD_SERVER_DESC: /* Entry field variable: "szAdd_Server_Desc" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_SERVER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the server list the *
* entry pointed to by the end-user. We break it *
* into its two components (name and description).*
* We then load these components into their *
* respective fields. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT checked;
USHORT sSelectIndex;
CHAR szSelectText[129];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
/*****************************************************
* *
* This section sets the UNIX format check box *
* based upon the entry selected by the end-user. *
* We need to scan through the server list to *
* find the selected entry and then use the *
* server UNIX format array to set the box. *
* *
*****************************************************/
for(i=0; i < 128; i++)
{
if (Selserv->szServer_List[i][0])
{
if(strnicmp(Selserv->szServer_List[i],
szSelectText,
strlen(szSelectText)) == 0)
{
checked = (USHORT) Selserv->ckServer_UNIX_Format[i];
WinSendDlgItemMsg(hWndDlg,
DID_UNIX_FORMAT,
BM_SETCHECK,
MPFROMSHORT(checked),
0L);
break;
}
}
}
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_ADD_SERVER_NAME,
(PSZ) result);
result = strchr(szSelectText,'\0');
*result++;
WinSetDlgItemText(hWndDlg,
DID_ADD_SERVER_DESC,
result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Add" */
Addserv = (ADDSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_ADDSERV);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_ADD_SERVER_NAME,
sizeof(Addserv->szAdd_Server_Name),
Addserv->szAdd_Server_Name);
if(Addserv->szAdd_Server_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Server name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_ADD_SERVER_NAME));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_ADD_SERVER_DESC,
sizeof(Addserv->szAdd_Server_Desc),
Addserv->szAdd_Server_Desc);
if(BgmAddPrtSrv(hWndDlg,
DID_ADD_SERVER_NAME,
free_entry,
Selserv->szServer_List,
Addserv->szAdd_Server_Name,
Addserv->szAdd_Server_Desc,
"Server name duplication. Push retry to change server name or push cancel to abort.")
== TRUE)
{
Selserv->ckServer_UNIX_Format[free_entry] =
(INT)(WinSendDlgItemMsg(hWndDlg,
DID_UNIX_FORMAT,
BM_QUERYCHECK,
0L,
0L));
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of ADDSERVMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY DELSERVMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
DELSERVStruct FAR *Delserv;
static INT last_entry; /* Number of first free entry in the server table. */
SELSERVStruct FAR *Selserv;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELSERV);
switch(message)
{
case WM_INITDLG:
Delserv = (DELSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_DELSERV);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_SERVER_LIST,
Selserv->szServer_List,
"A server does not exist to delete. The server list is empty.",
FALSE);
if((last_entry = Return_Values->last_entry) == -1)
{
break;
}
/* Initialize entry field control: szDelete_Server_Name */
WinSendDlgItemMsg(hWndDlg, DID_DELETE_SERVER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_DELETE_SERVER_NAME: /* Entry field variable: "szDelete_Server_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_DELETE_SERVER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_SERVER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the server list the *
* entry pointed to by the end-user. We break it *
* into its two components (name and description).*
* We then load these components into their *
* respective fields. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT sSelectIndex;
CHAR szSelectText[129];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_DELETE_SERVER_NAME,
(PSZ) result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Delete" */
Delserv = (DELSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_DELSERV);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_DELETE_SERVER_NAME,
sizeof(Delserv->szDelete_Server_Name),
Delserv->szDelete_Server_Name);
if(Delserv->szDelete_Server_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Server name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_DELETE_SERVER_NAME));
break;
}
if(BgmDeletePrtSrv(hWndDlg,
DID_DELETE_SERVER_NAME,
last_entry,
Selserv->szServer_List,
Delserv->szDelete_Server_Name,
"Server name not found. Push retry to change server name or push cancel to abort.")
== TRUE)
{
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of DELSERVMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY CHNGSERVMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[90];
static HWND hWndParent;
CHNGSERVStruct FAR *Chngserv;
static INT Selected_Entry_Number;
SELSERVStruct FAR *Selserv;
CHAR *result;
LOADRETURNStruct FAR *Return_Values;
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_SELSERV);
switch(message)
{
case WM_INITDLG:
Chngserv = (CHNGSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CHNGSERV);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
Selected_Entry_Number = -1;
Return_Values = (LOADRETURNStruct FAR *)
BgmLoadListBox(hWndDlg,
DID_SERVER_LIST,
Selserv->szServer_List,
"A server does not exist to change. The server list is empty.",
FALSE);
if (Return_Values->last_entry == -1)
{
break;
}
/* Initialize entry field control: szChange_Server_Name */
WinSendDlgItemMsg(hWndDlg, DID_CHANGE_SERVER_NAME, EM_SETTEXTLIMIT, MPFROMSHORT(24), 0L);
/* Initialize entry field control: szChange_Server_Desc */
WinSendDlgItemMsg(hWndDlg, DID_CHANGE_SERVER_DESC, EM_SETTEXTLIMIT, MPFROMSHORT(103), 0L);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_CHANGE_UNIX_FORMAT: /* Checkbox text: "Use UNIX format" */
{
USHORT checked;
/* Query check box control for current state */
/* on return checked is set to: */
/* 1 if check box is in unchecked state */
/* 0 if check box is in checked state */
checked = !WinSendDlgItemMsg(hWndDlg, DID_CHANGE_UNIX_FORMAT,
BM_QUERYCHECK, 0L, 0L );
/* Set checkbox control state */
WinSendDlgItemMsg(hWndDlg, DID_CHANGE_UNIX_FORMAT,
BM_SETCHECK, MPFROMSHORT(checked), 0L);
}
break;
case DID_CHANGE_SERVER_NAME: /* Entry field variable: "szChange_Server_Name" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[24];
WinQueryDlgItemText(hWndDlg, DID_CHANGE_SERVER_NAME,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwAlphaValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_CHANGE_SERVER_DESC: /* Entry field variable: "szChange_Server_Desc" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case DID_SERVER_LIST: /* List box */
{
/*****************************************************
* *
* This section obtains from the server list the *
* entry pointed to by the end-user. We break it *
* into its two components (name and description).*
* We then load these components into their *
* respective fields. *
* *
* One example of when an user might point to an *
* entry is when he want to save some typing. *
* *
*****************************************************/
USHORT checked;
USHORT sSelectIndex;
CHAR szSelectText[129];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
/*****************************************************
* *
* This section performs two functions: *
* *
* 1) Sets the UNIX format check box based upon *
* the entry selected by the end-user. *
* We need to scan through the server list to *
* find the selected entry and then use the *
* server UNIX format array to set the box. *
* *
* 2) Finds the server entry the user just *
* selected. The change key (DID_OK) code *
* uses this number to indicate which entry *
* the user is changing. This approach *
* permits the end-user to change both the *
* name and description instead of just the *
* name. *
* *
*****************************************************/
for(i=0; i < 128; i++)
{
if (Selserv->szServer_List[i][0])
{
if(strnicmp(Selserv->szServer_List[i],
szSelectText,
strlen(szSelectText)) == 0)
{
Selected_Entry_Number = i;
checked = (USHORT) Selserv->ckServer_UNIX_Format[i];
WinSendDlgItemMsg(hWndDlg,
DID_UNIX_FORMAT,
BM_SETCHECK,
MPFROMSHORT(checked),
0L);
break;
}
}
}
result = strtok(szSelectText," ");
WinSetDlgItemText(hWndDlg,
DID_CHANGE_SERVER_NAME,
(PSZ) result);
result = strchr(szSelectText,'\0');
*result++;
WinSetDlgItemText(hWndDlg,
DID_CHANGE_SERVER_DESC,
result);
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Change" */
Chngserv = (CHNGSERVStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CHNGSERV);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CHANGE_SERVER_NAME,
sizeof(Chngserv->szChange_Server_Name),
Chngserv->szChange_Server_Name);
if(Chngserv->szChange_Server_Name[0] == 0)
{
/* If required field is not completed inform user and */
/* query what he wants to do about it by presenting a */
/* message box with the push buttons "Retry" and */
/* "Cancel" */
strcpy(szWorkBuf, "Server name required. Push retry to supply one or cancel to abort dialog.");
i = WinMessageBox(HWND_DESKTOP, hWndDlg, szWorkBuf,
szAppName, 0, MB_RETRYCANCEL|MB_ICONEXCLAMATION);
/* If the user presses "Cancel", post a message to the */
/* DID_CANCEL case and break out of this case */
if(i == MBID_CANCEL)
{
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break;
}
/* If the user presses "Retry", set focus to the */
/* control that needs to be completed and break out */
/* of this case */
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, DID_CHANGE_SERVER_NAME));
break;
}
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, DID_CHANGE_SERVER_DESC,
sizeof(Chngserv->szChange_Server_Desc),
Chngserv->szChange_Server_Desc);
if((i = BgmChangePrtSrv(hWndDlg,
DID_CHANGE_SERVER_NAME,
Selected_Entry_Number,
Selserv->szServer_List,
Chngserv->szChange_Server_Name,
Chngserv->szChange_Server_Desc,
"Server name not found. Push retry to change server name or push cancel to abort."))
!= -1)
{
Selserv->ckServer_UNIX_Format[i] =
(INT)(WinSendDlgItemMsg(hWndDlg,
DID_UNIX_FORMAT,
BM_QUERYCHECK,
0L,
0L));
WinDismissDlg(hWndDlg, TRUE);
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case DID_HELP: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of CHNGSERVMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY QUERYPRTMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
QUERYPRTStruct FAR *Queryprt;
switch(message)
{
case WM_INITDLG:
Queryprt = (QUERYPRTStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_QUERYPRT);
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
for (i=0; i < 128; i++)
if (Queryprt->szQuery_Remote_Printer_List[i][0])
WinSendDlgItemMsg(hWndDlg, DID_Q_R_P_LIST_BOX, LM_INSERTITEM,
MPFROM2SHORT(LIT_SORTASCENDING, 0),
MPFROMP(Queryprt->szQuery_Remote_Printer_List[i]));
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case DID_Q_R_P_LIST_BOX: /* List box */
{
USHORT sSelectIndex;
CHAR szSelectText[80];
if (SHORT2FROMMP(mp1) != LN_SELECT)
break;
sSelectIndex = (USHORT)WinSendDlgItemMsg(hWndDlg,
SHORT1FROMMP(mp1), LM_QUERYSELECTION, 0L, 0L);
WinSendDlgItemMsg(hWndDlg, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
MPFROM2SHORT(sSelectIndex, sizeof(szSelectText)),
MPFROMP(szSelectText));
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Continue" */
Queryprt = (QUERYPRTStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_QUERYPRT);
WinDestroyWindow(hWndDlg);
hWndQUERYPRT = 0;
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of QUERYPRTMsgProc */