home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 19 Printer
/
19-Printer.zip
/
LAPRINT.ZIP
/
LAPRINT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-23
|
67KB
|
1,515 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
#include "LAPRINT.h"
/***************************************************************************/
/* */
/* Presentation Manager Program Main Body */
/* */
/* The following routine is the Presentation Manager program Main Body. */
/* The Main Body of a PM program is concerned with associating the */
/* application with the Presentation Manager system, creating its */
/* message queue, registering and displaying its main window, servicing */
/* its message queue during the time that the application is active, */
/* and disassociating the application from PM when the user is finished */
/* with the application. The remaining parts of this source module that */
/* are concerned with the Presentation Manager are the application's */
/* window procedures (main window procedure, child window procedures, */
/* and dialog window procedures) that process the messages associated */
/* with the application's various windows. */
/* */
/***************************************************************************/
SHORT cdecl main(argc, argv)
int argc;
char *argv[];
{
static CHAR szCRI_Copyright[]="(c) Cray Research, Inc., 1991.";
QMSG qmsg; /* MSG structure to store your messages */
PID pid; /* Process identifier for adding name to switch list */
TID tid; /* Thread identifier */
static CHAR szTitle[13];
/* The WinInitialize routine initializes the Presentation Manager */
/* facilities for use by this application and returns a handle to the */
/* anchor block assigned to the application by PM. */
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
/* The WinCreateMsgQueue call creates a message queue for this application*/
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
/* The following function registers the classes of all application windows*/
if(!cwRegisterClass())
return(FALSE);
/* If the application's Initialization Panel is not already shown, display*/
/* it on the desktop window before any other application window is shown. */
if(!WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP)INITIALMsgProc, 0,
IDLG_INITIAL, (PBYTE)HWND_DESKTOP))
DosExit(0, 1);
/**************************************************************************/
/* IPF Initialization Structure */
/**************************************************************************/
hiLAPRINTHelp.cb = sizeof(HELPINIT); /* size of init structure */
hiLAPRINTHelp.ulReturnCode = 0;
hiLAPRINTHelp.pszTutorialName = 0; /* no tutorial */
hiLAPRINTHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_LAPRINT);
hiLAPRINTHelp.hmodAccelActionBarModule = 0;
hiLAPRINTHelp.idAccelTable = 0;
hiLAPRINTHelp.idActionBar = 0;
hiLAPRINTHelp.pszHelpWindowTitle = "LAPRINT";
hiLAPRINTHelp.hmodHelpTableModule = 0;
hiLAPRINTHelp.usShowPanelId = 0;
hiLAPRINTHelp.pszHelpLibraryName = "LAPRINT.HLP";
/**************************************************************************/
/* Create Instance of IPF */
/**************************************************************************/
hWndLAPRINTHelp = WinCreateHelpInstance(hAB, &hiLAPRINTHelp);
if(!hWndLAPRINTHelp || hiLAPRINTHelp.ulReturnCode)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ)"No help is available.",
(PSZ) szAppName,
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndLAPRINTHelp);
}
/* The CreateWindow function creates a frame window for this application's*/
/* top window, and set the window's size and location as appropriate. */
WinLoadString(hAB, 0, IDS_TITLE, 13, szTitle);
hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
FCF_TITLEBAR |
FCF_SYSMENU |
FCF_MINBUTTON |
FCF_MAXBUTTON |
FCF_SIZEBORDER |
FCF_MENU |
FCF_ICON |
FCF_SHELLPOSITION,
szAppName,
szTitle,
ID_LAPRINT,
0, 0,
0, 0,
&hWndClient,
0L, SWP_SHOW);
if(hWndFrame == 0)
return(FALSE);
/**************************************************************************/
/* Associate Instance of IPF */
/**************************************************************************/
if(hWndLAPRINTHelp)
WinAssociateHelpInstance(hWndLAPRINTHelp, hWndFrame);
/* The following inline routine fills out the application's switch control*/
/* structure with the appropriate information to add the application's */
/* name to the OS/2 Task Manager List, a list of the jobs currently */
/* running on the computer. */
WinQueryWindowProcess(hWndFrame, &pid, &tid);
Swctl.hwnd = hWndFrame; /* Frame window handle */
Swctl.idProcess = pid; /* Process identifier */
Swctl.uchVisibility = SWL_VISIBLE; /* visibility */
Swctl.fbJump = SWL_JUMPABLE; /* Jump indicator */
strcpy(Swctl.szSwtitle, szTitle); /* Frame window title */
hSwitch = WinAddSwitchEntry(&Swctl);
BgmConfigNeedsSaving = FALSE;
cwEnableMenuItem(hWndFrame,
IDM_F_QUERYREMOTEPRINTER,
FALSE);
/* The following is the message loop for the application. */
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
/* Perform clean up before exiting application. */
/**************************************************************************/
/* Destroy Instance of IPF */
/**************************************************************************/
if(hWndLAPRINTHelp)
WinDestroyHelpInstance(hWndLAPRINTHelp);
/* The following routine destroys the application's frame window (which */
/* also destroys its child windows), destroys its message queue, and */
/* disassociates the application from the Presentation Manager system. */
WinDestroyWindow(hWndFrame); /* Destroy the frame window */
WinDestroyMsgQueue(hMQ); /* Destroy this application's message queue */
WinTerminate(hAB); /* Terminate this application's use of the */
/* Presentation Manager resources */
} /* end of main */
/* The following Dialog box calls are generated for the dialog boxes that */
/* have been selected as "Unlinked" dialog boxes. To use these calls, */
/* simply copy them to the appropriate location in the application. */
#if 0
hWndQUERYPRT = WinLoadDlg(HWND_DESKTOP, hWnd, (PFNWP)QUERYPRTMsgProc,
0, IDLG_QUERYPRT, (PBYTE)hWnd);
#endif
/***************************************************************************/
/* */
/* Main Window Procedure */
/* */
/* This procedure provides service routines for the general PM events */
/* (messages) that PM sends to the window, as well as the user */
/* initiated events (messages) that are generated when the user selects */
/* the action bar and pulldown menu controls or the corresponding */
/* keyboard accelerators. */
/* */
/* The SWITCH statement shown below distributes the window messages to */
/* the respective message service routines, which are set apart by the */
/* CASE statements. The window procedures must provide an appropriate */
/* service routine for its end user initiated messages, as well as the */
/* general PM messages (like the WM_CLOSE message). If a message is */
/* sent to this procedure for which there is no programmed CASE clause */
/* (i.e., no service routine), the message is defaulted to the */
/* WinDefWindowProc function, where it is disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{ /* Beginning of message processor */
HPS hPS; /* Handle for the Presentation Space */
RECTL rClient; /* Handle to rectangle formed by client area */
USHORT rc; /* common return code value */
INT i;
switch(message)
{
case WM_COMMAND:
/* The PM messages for action bar and pulldown menu items are */
/* processed in this routine. */
switch(SHORT1FROMMP(mp1))
{
case IDM_F_NEW:
/* Place User Code to respond to the */
/* Menu Item Named "~New" here. */
BgmNew(hWndClient,
TRUE, /* CFGOPENStruct reset */
TRUE, /* CFGSAVEStruct reset */
TRUE, /* FSELECTStruct reset */
TRUE, /* SELSERVStruct reset */
TRUE, /* PRTERADDStruct reset */
TRUE, /* PRTERDELStruct reset */
TRUE, /* PRTCHANGStruct reset */
TRUE, /* SELPRTERStruct reset */
TRUE, /* ADDSERVStruct reset */
TRUE, /* DELSERVStruct reset */
TRUE, /* CHNGSERVStruct reset */
TRUE); /* QUERYPRTStruct reset */
break;
case IDM_F_OPEN:
/* This makes a call to the dialog box named */
/* "CFGOPEN" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CFGOPENMsgProc,
0, IDLG_CFGOPEN, (PBYTE)hWnd);
break;
case IDM_F_SAVE:
/* Place User Code to respond to the */
/* Menu Item Named "~Save" here. */
{
CFGSAVEStruct FAR *Cfgsave;
Cfgsave = (CFGSAVEStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_CFGSAVE);
if(Cfgsave->szConfig_Directory[0] == NULL ||
Cfgsave->szConfig_Filename[0] ==NULL)
{
WinPostMsg(hWnd,
WM_COMMAND,
MPFROMSHORT(IDM_F_SAVEAS),
0L);
break;
}
BgmWriteConfigFile(hWnd,
TRUE);
}
break;
case IDM_F_SAVEAS:
/* This makes a call to the dialog box named */
/* "CFGSAVE" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CFGSAVEMsgProc,
0, IDLG_CFGSAVE, (PBYTE)hWnd);
break;
case IDM_F_PRINT:
{
FSELECTStruct FAR *Fselect;
Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWndClient,
OFFSET_FSELECT);
/****************************************************
* *
* This section insures we have a file to print. *
* If we don't then we need to query the user *
* for one via the File section to print dialog. *
* *
****************************************************/
if(Fselect->szSelected_Filename[0] == NULL ||
isspace((int)Fselect->szSelected_Filename[0]) != 0)
{
WinPostMsg(hWnd,
WM_COMMAND,
MPFROMSHORT(IDM_F_SELECTFILETOPRINT),
0L);
break;
}
}
if (!WinIsWindow(hAB, hWndFPRINTObject))
{
/* if the window is not a valid window, allocate memory */
/* for the thread's stack */
DosAllocSeg(4096, &FPRINTObjSel, SEG_NONSHARED);
FPRINTObjStack = (CHAR *)MAKEP(FPRINTObjSel, 0);
_beginthread((void FAR *)FPRINTObjFunction, FPRINTObjStack, 4096, 0);
}
break;
case IDM_F_SELECTFILETOPRINT:
/* This makes a call to the dialog box named */
/* "FSELECT" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)FSELECTMsgProc,
0, IDLG_FSELECT, (PBYTE)hWnd);
break;
case IDM_F_QUERYREMOTEPRINTER:
if (!WinIsWindow(hAB, hWndFQUERYREMOTEPRINTERObject))
{
/* if the window is not a valid window, allocate memory */
/* for the thread's stack */
DosAllocSeg(4096, &FQUERYREMOTEPRINTERObjSel, SEG_NONSHARED);
FQUERYREMOTEPRINTERObjStack = (CHAR *)MAKEP(FQUERYREMOTEPRINTERObjSel, 0);
_beginthread((void FAR *)FQUERYREMOTEPRINTERObjFunction, FQUERYREMOTEPRINTERObjStack, 4096, 0);
}
break;
case IDM_F_EXIT:
/* Place User Code to respond to the */
/* Menu Item Named "E~xit" here. */
WinPostMsg(hWnd,
WM_CLOSE,
0L,
0L);
break;
case IDM_O_SELECTPRINTER:
/* This makes a call to the dialog box named */
/* "SELPRTER" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)SELPRTERMsgProc,
0, IDLG_SELPRTER, (PBYTE)hWnd);
break;
case IDM_P_ADDPRINTER:
/* This makes a call to the dialog box named */
/* "PRTERADD" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTERADDMsgProc,
0, IDLG_PRTERADD, (PBYTE)hWnd);
break;
case IDM_P_DELETEPRINTER:
/* This makes a call to the dialog box named */
/* "PRTERDEL" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTERDELMsgProc,
0, IDLG_PRTERDEL, (PBYTE)hWnd);
break;
case IDM_P_CHANGEPRINTER:
/* This makes a call to the dialog box named */
/* "PRTCHANG" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTCHANGMsgProc,
0, IDLG_PRTCHANG, (PBYTE)hWnd);
break;
case IDM_S_SELECTSERVER:
/* This makes a call to the dialog box named */
/* "SELSERV" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)SELSERVMsgProc,
0, IDLG_SELSERV, (PBYTE)hWnd);
break;
case IDM_O_ADDSERVER:
/* This makes a call to the dialog box named */
/* "ADDSERV" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)ADDSERVMsgProc,
0, IDLG_ADDSERV, (PBYTE)hWnd);
break;
case IDM_S_DELETESERVER:
/* This makes a call to the dialog box named */
/* "DELSERV" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)DELSERVMsgProc,
0, IDLG_DELSERV, (PBYTE)hWnd);
break;
case IDM_S_CHANGESERVER:
/* This makes a call to the dialog box named */
/* "CHNGSERV" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CHNGSERVMsgProc,
0, IDLG_CHNGSERV, (PBYTE)hWnd);
break;
case IDM_O_NOLPRMESSAGES:
/* Place User Code to respond to the */
/* Menu Item Named "~No lpr messages" here. */
cwCheckPulldown(hWndFrame, IDM_O_NOLPRMESSAGES);
break;
case IDM_O_UNIXFORMAT:
/* Place User Code to respond to the */
/* Menu Item Named "~Unix format" here. */
cwCheckPulldown(hWndFrame, IDM_O_UNIXFORMAT);
break;
case IDM_H_HELPFORHELP:
if(hWndLAPRINTHelp)
WinSendMsg(hWndLAPRINTHelp, HM_DISPLAY_HELP, 0L, 0L);
break;
case IDM_H_ABOUT:
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)BGMABOUTMsgProc,
0, IDLG_BGMABOUT, (PBYTE)hWnd);
break;
default:
break; /* End of default case for switch(mp1) */
}
break; /* End of WM_COMMAND */
case HM_QUERY_KEYS_HELP:
/* If the user requests Keys Help from the help pulldown, */
/* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
/* which should return the panel id of the Keys Help panel */
return((MRESULT)999);
break;
case HM_ERROR:
/* If an IPF error occurs, an HM_ERROR message will be sent to */
/* the application. */
if(hWndLAPRINTHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndLAPRINTHelp);
}
else
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Error Occurred",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
break;
case WM_CREATE:
/* The WM_CREATE message is sent to a window when an application*/
/* requests that the window be created. The window procedure */
/* for the new window receives this message after the window is */
/* created, but before the window becomes visible. */
/* */
cwSetInitDlgStatus(hWnd);
break; /* End of WM_CREATE */
case WM_MOUSEMOVE:
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break;
case WM_SIZE: /* code for sizing client area */
break; /* End of WM_SIZE */
case WM_PAINT: /* code for the window's client area */
/* Obtain a handle to a cache presentation space */
hPS = WinBeginPaint(hWnd, 0, 0);
/* Determine the size of the client area */
WinQueryWindowRect(hWnd, &rClient);
/* Fill the background with the default background color */
WinFillRect(hPS, &rClient, CLR_BACKGROUND);
/* return presentation space to state before WinBeginPaint */
WinEndPaint(hPS);
break; /* End of WM_PAINT */
case WM_CLOSE: /* close the window */
if(BgmConfigNeedsSaving != FALSE)
{
i = WinMessageBox(HWND_DESKTOP,
hWnd,
(PSZ) "Current configuration not saved. Do you wish to exit without saving? (No = Save and then exit)",
(PSZ) szAppName,
0,
MB_YESNOCANCEL|MB_ICONEXCLAMATION);
/***********************************************************
* *
* This section processes an user Cancel on the above *
* message box by cancelling the close request. *
* *
***********************************************************/
if(i == MBID_CANCEL)
{
return(0L);
}
/***********************************************************
* *
* This section processes an user No on the above *
* message box by calling the Save configuration file *
* routine. *
* *
* We fall out of the BgmConfigNeedsSaving test when *
* the user's response is to say yes exit anyway. *
* *
***********************************************************/
if(i == MBID_NO)
{
WinPostMsg(hWnd,
WM_COMMAND,
MPFROMSHORT(IDM_F_SAVE),
0L);
BgmConfigNeedsSaving = BGM_SAVE_THEN_EXIT;
return(0L);
}
}
if(hWnd != hWndClient)
break;
cwFreeDlgMemory(hWnd);
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of WM_CLOSE */
case WM_FREE_MEM: /* Free memory allocated for separate threads */
DosFreeSeg((SEL)PVOIDFROMMP(mp1));
break;
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of WndProc */
/***************************************************************************/
/* */
/* 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 BGMABOUTMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Enter" */
WinDismissDlg(hWndDlg, TRUE);
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 BGMABOUTMsgProc */
/***************************************************************************/
/* */
/* 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 INITIALMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static INT iLogoTime;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
iLogoTime = WinQueryProfileInt(hAB, "PM_ControlPanel",
"LogoDisplayTime", -1);
if(iLogoTime == 0)
{
WinDismissDlg(hWndDlg, TRUE);
break;
}
if(iLogoTime == -1)
break;
WinStartTimer(hAB, hWndDlg, ID_LOGO_TIMER, iLogoTime);
break; /* End of WM_INITDLG */
case WM_TIMER:
WinStopTimer(hAB, hWndDlg, ID_LOGO_TIMER);
WinDismissDlg(hWndDlg, TRUE);
break;
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Enter" */
WinDismissDlg(hWndDlg, TRUE);
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 INITIALMsgProc */
MRESULT EXPENTRY FPRINTObjWndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
QMSG qmsg; /* MSG structure to store your messages */
switch(message)
{
case WM_USER_DEFINED_CODE:
/* Copy the following two lines of code throughout your */
/* threaded user defined code to enable your application to */
/* kill this thread when the user requests so. Modifications */
/* may wish to be made to enable clean up of thread operations. */
/* */
/* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
/* return(0L); */
/* */
BgmPrint(hWnd,
TRUE);
if(hWndFSELECT != 0)
{
WinEnableWindow((WinWindowFromID(hWndFSELECT,
DID_PRINT)),
TRUE);
}
/* After processing user defined code, post a WM_QUIT message */
/* to terminate the thread */
WinPostMsg(hWndFPRINTObject, WM_QUIT, 0L, 0L);
break;
case WM_CREATE:
/* Post a message to start user defined code after startup */
WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
break; /* End of WM_CREATE */
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of FPRINTObjWndProc */
MRESULT EXPENTRY FSELECTDID_PRINTObjWndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
QMSG qmsg; /* MSG structure to store your messages */
switch(message)
{
case WM_USER_DEFINED_CODE:
/* Copy the following two lines of code throughout your */
/* threaded user defined code to enable your application to */
/* kill this thread when the user requests so. Modifications */
/* may wish to be made to enable clean up of thread operations. */
/* */
/* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
/* return(0L); */
/* */
BgmPrint(hWndFSELECT,
FALSE);
/* After processing user defined code, post a WM_QUIT message */
/* to terminate the thread */
WinPostMsg(hWndFSELECTDID_PRINTObject, WM_QUIT, 0L, 0L);
break;
case WM_CREATE:
/* Post a message to start user defined code after startup */
WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
break; /* End of WM_CREATE */
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of FSELECTDID_PRINTObjWndProc */
MRESULT EXPENTRY FQUERYREMOTEPRINTERObjWndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
QMSG qmsg; /* MSG structure to store your messages */
switch(message)
{
case WM_USER_DEFINED_CODE:
/* Copy the following two lines of code throughout your */
/* threaded user defined code to enable your application to */
/* kill this thread when the user requests so. Modifications */
/* may wish to be made to enable clean up of thread operations. */
/* */
/* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
/* return(0L); */
/* */
/* Query remote printer pulldown - rexec server lpq -Pprinter command */
/* After processing user defined code, post a WM_QUIT message */
/* to terminate the thread */
WinPostMsg(hWndFQUERYREMOTEPRINTERObject, WM_QUIT, 0L, 0L);
break;
case WM_CREATE:
/* Post a message to start user defined code after startup */
WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
break; /* End of WM_CREATE */
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of FQUERYREMOTEPRINTERObjWndProc */
/***************************************************************************/
/* */
/* cwRegisterClass Function */
/* */
/* The following function registers all the classes of all the windows */
/* associated with this application. The function returns TRUE if it is */
/* successful, otherwise it returns FALSE. */
/* */
/***************************************************************************/
INT cwRegisterClass()
{
CLASSINFO ci;
INT rc;
strcpy(szAppName, "LAPRINT");
rc = WinRegisterClass(hAB, /* Anchor block handle */
(PCH)szAppName, /* Name of class being registered */
(PFNWP)WndProc, /* Window procedure for class */
CS_SIZEREDRAW ,
12*sizeof(char FAR *));
if (rc == FALSE)
return(FALSE);
WinQueryClassInfo(hAB, WC_ENTRYFIELD, (PCLASSINFO)&ci);
pfnEditWndProc = ci.pfnWindowProc;
rc = WinRegisterClass(hAB, "UDAlpha", UDCharWndProc, CS_SIZEREDRAW,
ci.cbWindowData + sizeof(PVOID));
if (rc == FALSE)
return(FALSE);
return(TRUE);
} /* End of cwRegisterClass */
/***************************************************************************/
/* */
/* cwCreateWindow Function */
/* */
/* The following function is used to create a window (the main window, */
/* a child window, an icon window, etc.) and set it's initial size and */
/* position. It returns the handle to the frame window. */
/* */
/***************************************************************************/
HWND cwCreateWindow(
HWND hWndParent, /* Handle to the parent of the window to be created */
ULONG ctldata, /* Frame control flags for the window */
PCH appname, /* Class name of the window */
PCH title, /* Title of the window */
USHORT ResID, /* Resource id value */
INT x, /* Initial horizontal and vertical location */
INT y,
INT cx, /* Initial width and height of the window */
INT cy,
PHWND hWndClient, /* Handle to the client area of the window */
ULONG lfStyle, /* Frame window style */
USHORT uSizeStyle) /* User defined size and location flags */
{
USHORT rc; /* accepts return codes from function calls */
HWND hWndFrame; /* local handle to created window frame */
USHORT SizeStyle; /* local window positioning options */
CHAR MsgBuffer[80]; /* buffer for error messages */
HPS hPS; /* handle to a presentation space */
int xmod, ymod; /* modifiers for sizing */
#define DLGXMOD 4 /* Dialog units X modulo */
#define DLGYMOD 8 /* Dialog units Y modulo */
FONTMETRICS fm; /* structure for determing modifiers */
/* Create the frame window */
hWndFrame = WinCreateStdWindow(hWndParent, /* parent of window */
lfStyle, /* frame window style */
&ctldata, /* frame flags */
appname, /* class name */
title, /* window title */
0L, /* client window style */
0, /* module for resources */
ResID, /* resource id */
(HWND FAR *)hWndClient); /* client handle*/
/* if hWndFrame is NULL, an error occured when opening the window, */
/* notify the user and exit this function */
if(hWndFrame == 0)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* set up size options */
SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
/* if the height, width, intial x or initial y values are non-zero, */
/* then we will need to set up the modifiers for size and location */
if((cx > 0) || (cy > 0) ||
(x > 0) || (y > 0))
{
hPS = WinGetPS(HWND_DESKTOP);
GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
xmod = (INT)fm.lAveCharWidth;
ymod = (INT)fm.lMaxBaselineExt;
WinReleasePS(hPS);
}
/* if either the width or the height are non-zero, then the size of the */
/* created window will be changed, set SizeStyle accordingly */
if((cx > 0) || (cy > 0))
SizeStyle |= SWP_SIZE;
/* set the size and position of the window and activate it */
rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
(USHORT)(cx * xmod)/DLGXMOD,
(USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
/* if the either the intial x or y position of the window is non-zero, */
/* set the window to its new position */
if((x > 0) || (y > 0))
rc = WinSetWindowPos(hWndFrame, HWND_TOP,
(USHORT)(x * xmod)/DLGXMOD,
(USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
/* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
/* and exit this function */
if(!rc)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* return the handle to the frame window */
return(hWndFrame);
} /* End of cwCreateWindow */
VOID FAR FPRINTObjFunction()
{
QMSG lqmsg; /* MSG structure to store your messages */
HAB lhAB; /* Handle to the Anchor Block */
HMQ lhMQ; /* Handle to the Message Queue */
/* Initialize the Presentation Manager facilities for use by this */
/* application, return the handle to our anchor block */
lhAB = WinInitialize(0);
/* Create a message queue for this application */
lhMQ = WinCreateMsgQueue(lhAB, 0);
strcpy(szFPRINTObjAppName, "FPRINT");
WinRegisterClass(hAB, (PCH)szFPRINTObjAppName,
(PFNWP)FPRINTObjWndProc,
0L, 0);
hWndFPRINTObject = WinCreateWindow(HWND_OBJECT, szFPRINTObjAppName,
0, 0L, 0, 0, 0, 0, 0,
HWND_TOP, 0, 0, 0);
cwEnableMenuItem(hWndFrame, IDM_F_PRINT, FALSE);
while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
cwEnableMenuItem(hWndFrame, IDM_F_PRINT, TRUE);
/* Perform clean up before exiting application */
WinDestroyWindow(hWndFPRINTObject); /* Destroy the frame window */
WinDestroyMsgQueue(lhMQ); /* Destroy this application's message queue */
DosEnterCritSec();
WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FPRINTObjSel), 0L);
WinTerminate(lhAB); /* Terminate this thread's use of the */
/* Presentation Manager resources */
_endthread();
}
VOID FAR FSELECTDID_PRINTObjFunction()
{
QMSG lqmsg; /* MSG structure to store your messages */
HAB lhAB; /* Handle to the Anchor Block */
HMQ lhMQ; /* Handle to the Message Queue */
/* Initialize the Presentation Manager facilities for use by this */
/* application, return the handle to our anchor block */
lhAB = WinInitialize(0);
/* Create a message queue for this application */
lhMQ = WinCreateMsgQueue(lhAB, 0);
strcpy(szFSELECTDID_PRINTObjAppName, "FSELECTDID_PRINT");
WinRegisterClass(hAB, (PCH)szFSELECTDID_PRINTObjAppName,
(PFNWP)FSELECTDID_PRINTObjWndProc,
0L, 0);
hWndFSELECTDID_PRINTObject = WinCreateWindow(HWND_OBJECT, szFSELECTDID_PRINTObjAppName,
0, 0L, 0, 0, 0, 0, 0,
HWND_TOP, 0, 0, 0);
cwEnableMenuItem(hWndFrame, IDM_F_PRINT, FALSE);
while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
cwEnableMenuItem(hWndFrame, IDM_F_PRINT, TRUE);
/* Perform clean up before exiting application */
WinDestroyWindow(hWndFSELECTDID_PRINTObject); /* Destroy the frame window */
WinDestroyMsgQueue(lhMQ); /* Destroy this application's message queue */
DosEnterCritSec();
WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FSELECTDID_PRINTObjSel), 0L);
WinTerminate(lhAB); /* Terminate this thread's use of the */
/* Presentation Manager resources */
_endthread();
}
VOID FAR FQUERYREMOTEPRINTERObjFunction()
{
QMSG lqmsg; /* MSG structure to store your messages */
HAB lhAB; /* Handle to the Anchor Block */
HMQ lhMQ; /* Handle to the Message Queue */
/* Initialize the Presentation Manager facilities for use by this */
/* application, return the handle to our anchor block */
lhAB = WinInitialize(0);
/* Create a message queue for this application */
lhMQ = WinCreateMsgQueue(lhAB, 0);
strcpy(szFQUERYREMOTEPRINTERObjAppName, "FQUERYREMOTEPRINTER");
WinRegisterClass(hAB, (PCH)szFQUERYREMOTEPRINTERObjAppName,
(PFNWP)FQUERYREMOTEPRINTERObjWndProc,
0L, 0);
hWndFQUERYREMOTEPRINTERObject = WinCreateWindow(HWND_OBJECT, szFQUERYREMOTEPRINTERObjAppName,
0, 0L, 0, 0, 0, 0, 0,
HWND_TOP, 0, 0, 0);
cwEnableMenuItem(hWndFrame, IDM_F_QUERYREMOTEPRINTER, FALSE);
while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
cwEnableMenuItem(hWndFrame, IDM_F_QUERYREMOTEPRINTER, TRUE);
/* Perform clean up before exiting application */
WinDestroyWindow(hWndFQUERYREMOTEPRINTERObject); /* Destroy the frame window */
WinDestroyMsgQueue(lhMQ); /* Destroy this application's message queue */
DosEnterCritSec();
WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FQUERYREMOTEPRINTERObjSel), 0L);
WinTerminate(lhAB); /* Terminate this thread's use of the */
/* Presentation Manager resources */
_endthread();
}
/* cwCheckPulldown accepts as input a handle to a frame window that a */
/* pulldown belongs to and the id value of this pulldown item. It */
/* determines whether this item is checked or unchecked; if it is */
/* unchecked the pulldown item is checked and TRUE is returned, if it */
/* is checked the pulldown item is unchecked and FALSE is returned. */
USHORT cwCheckPulldown(hWnd, item)
HWND hWnd; /* handle to the frame window */
USHORT item; /* id value of the item to be checked/unchecked */
{
MENUITEM Menu; /* structure to store attributes of menu item */
/* query the system for the attributes of this particular menu item */
WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
MM_QUERYITEM,
MPFROM2SHORT(item, TRUE),
MPFROMP((PMENUITEM)&Menu));
/* if this menu item's MIA_CHECKED bit is on, uncheck the menu item, */
/* else, check the menu item */
Menu.afAttribute = ~Menu.afAttribute;
WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
MM_SETITEMATTR, MPFROM2SHORT(item, TRUE),
MPFROM2SHORT(MIA_CHECKED, Menu.afAttribute));
return(Menu.afAttribute & MIA_CHECKED);
} /* End of cwCheckPulldown function */
INT cwFillFileListBox(hWnd, szFileSpec, ListID)
HWND hWnd;
PSZ szFileSpec;
INT ListID;
{
FILEFINDBUF findbuf ;
HDIR hDir = 1 ;
USHORT usSearchCount = 1 ;
WinSendDlgItemMsg(hWnd, ListID, LM_DELETEALL, 0, 0) ;
DosFindFirst(szFileSpec, &hDir, 0x0007, &findbuf, sizeof(findbuf),
&usSearchCount, 0L) ;
while(usSearchCount)
{
WinSendDlgItemMsg(hWnd, ListID, LM_INSERTITEM,
MPFROM2SHORT(LIT_SORTASCENDING, 0),
MPFROMP(findbuf.achName));
DosFindNext(hDir, &findbuf, sizeof(findbuf), &usSearchCount) ;
}
return(1);
}
/***************************************************************************/
/* cwAlphaValidate Function */
/* */
/* Returns TRUE if the string is acceptable, otherwise returns FALSE */
/* */
/***************************************************************************/
INT cwAlphaValidate(string)
CHAR *string;
{
int count;
for(count = 0; count <= strlen(string)-1; count++)
if(!isalnum((int)string[count]))
if(!isspace((int)string[count]))
return(FALSE);
return(TRUE);
}
/***************************************************************************/
/* UDCharWndProc */
/* */
/* Is used on subclassing edit fields for character validation */
/* */
/***************************************************************************/
MRESULT EXPENTRY UDCharWndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static CHAR key;
switch(message)
{
case WM_CHAR:
if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
{
key = ((CHAR)SHORT1FROMMP(mp2));
if((int)key == 0x20)
{
WinAlarm(HWND_DESKTOP,
WA_ERROR);
return((MRESULT)TRUE);
}
break;
}
if(SHORT1FROMMP(mp1) & KC_CHAR)
{
key = (CHAR)SHORT1FROMMP(mp2);
if(isalnum((int)key))
return(pfnEditWndProc(hWnd, message, mp1, mp2));
else
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
return((MRESULT)TRUE);
}
}
break;
case WM_TRANSLATEACCEL:
return((MRESULT)FALSE);
break;
}
return(pfnEditWndProc(hWnd, message, mp1, mp2));
} /* End of UDCharWndProc */
/***************************************************************************/
/* cwCenter Function */
/* */
/* Centers a dialog box on the client area of the caller */
/* */
/***************************************************************************/
INT cwCenter(hWnd, hWndParent)
HWND hWnd; /* handle of the window to be centered */
HWND hWndParent; /* handle of the window to center on */
{
ULONG SrcX, SrcY; /* Center of parent */
INT ix, iy; /* Destination points */
SWP DlgSwp, ParentSwp; /* Set window position structures */
ULONG ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP */
POINTL pt; /* Point */
/* Determine the width and height of the DESKTOP so the dialog box */
/* will not be positioned to a point off of the screen. */
ScreenWidth = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
/* Query width and depth of dialog box */
WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
/* Query width and depth of caller */
WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
/* Map the point parent points to the Desktop */
pt.x = ParentSwp.x;
pt.y = ParentSwp.y;
/* Convert the point from having our window as the origin to having */
/* the DESKTOP as the origin */
WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
SrcX = pt.x + (ParentSwp.cx / 2);
SrcY = pt.y + (ParentSwp.cy / 2);
/* Determine the point to move the dialog box to */
ix = (INT)(SrcX - (DlgSwp.cx / 2));
iy = (INT)(SrcY - (DlgSwp.cy / 2));
/* if either point is less than zero, then set that point to zero */
/* so the dialog box will not be positoned off of the window */
ix = (ix < 0) ? 0 : ix;
iy = (iy < 0) ? 0 : iy;
/* if either point plus the height or width of the dialog box is */
/* greater than the height or width of the screen adjust point */
if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
ix = (INT)(ScreenWidth - DlgSwp.cx);
if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
iy = (INT)(ScreenHeight - DlgSwp.cy);
/* move the dialog box */
return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
}
INT cwEnableMenuItem(hWnd, idval, bool)
HWND hWnd;
INT idval;
INT bool;
{
INT rc;
rc = (INT)WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
MM_SETITEMATTR, MPFROM2SHORT(idval, TRUE),
MPFROM2SHORT(MIA_DISABLED,
bool ? ~MIA_DISABLED : MIA_DISABLED));
return(rc);
}
INT cwFillDirListBox(hWndDlg, id, targetid)
HWND hWndDlg;
USHORT id;
USHORT targetid;
{
static CHAR buffer[10];
FILEFINDBUF findbuf;
HDIR hDir = 1;
SHORT sDrive;
USHORT usDriveNum, usSearchCount = 1;
ULONG ulDriveMap;
SHORT rc;
CHAR szBuffer[128];
USHORT usPathLen;
WinSendDlgItemMsg(hWndDlg, id, LM_DELETEALL, 0, 0) ;
rc = DosFindFirst("*.*", &hDir, 0x0017, &findbuf,
sizeof(findbuf), &usSearchCount, 0L);
if(rc!=0)
return( -1 );
while(usSearchCount)
{
if(findbuf.attrFile & 0x0010 &&
(findbuf.achName [0] != '.' || findbuf.achName [1]))
WinSendDlgItemMsg(hWndDlg, id, LM_INSERTITEM,
MPFROM2SHORT(LIT_SORTASCENDING, 0),
MPFROMP(findbuf.achName));
DosFindNext(hDir, &findbuf, sizeof findbuf, &usSearchCount) ;
}
rc = DosQCurDisk(&usDriveNum, &ulDriveMap);
for(sDrive = 0; sDrive < 26; sDrive++)
if(ulDriveMap & 1L << sDrive)
{
sprintf(buffer,"[%c:]", (CHAR)sDrive + 'A');
WinSendDlgItemMsg(hWndDlg, id, LM_INSERTITEM,
MPFROM2SHORT(LIT_END, 0),
MPFROMP(buffer)) ;
}
usPathLen = sizeof(szBuffer);
DosQCurDir(usDriveNum, &szBuffer[3], &usPathLen);
szBuffer[0] = '@' + usDriveNum;
szBuffer[1] = ':';
szBuffer[2] = '\\';
WinSetDlgItemText(hWndDlg, targetid, szBuffer);
}
/* This function initializes the states of all dialog box radio buttons */
/* and check boxes that have had their initial status set to true */
INT cwSetInitDlgStatus(hWnd)
HWND hWnd;
{
CFGOPENStruct FAR *Cfgopen;
CFGSAVEStruct FAR *Cfgsave;
FSELECTStruct FAR *Fselect;
SELPRTERStruct FAR *Selprter;
PRTERADDStruct FAR *Prteradd;
PRTERDELStruct FAR *Prterdel;
PRTCHANGStruct FAR *Prtchang;
SELSERVStruct FAR *Selserv;
ADDSERVStruct FAR *Addserv;
DELSERVStruct FAR *Delserv;
CHNGSERVStruct FAR *Chngserv;
QUERYPRTStruct FAR *Queryprt;
OFFSETOF(Cfgopen) = 0;
DosAllocSeg(sizeof(CFGOPENStruct), (PSEL)&SELECTOROF(Cfgopen), 0);
lmemset(Cfgopen, 0x00, sizeof(CFGOPENStruct));
WinSetWindowULong(hWnd, OFFSET_CFGOPEN, (ULONG)Cfgopen);
OFFSETOF(Cfgsave) = 0;
DosAllocSeg(sizeof(CFGSAVEStruct), (PSEL)&SELECTOROF(Cfgsave), 0);
lmemset(Cfgsave, 0x00, sizeof(CFGSAVEStruct));
WinSetWindowULong(hWnd, OFFSET_CFGSAVE, (ULONG)Cfgsave);
OFFSETOF(Fselect) = 0;
DosAllocSeg(sizeof(FSELECTStruct), (PSEL)&SELECTOROF(Fselect), 0);
lmemset(Fselect, 0x00, sizeof(FSELECTStruct));
WinSetWindowULong(hWnd, OFFSET_FSELECT, (ULONG)Fselect);
OFFSETOF(Selprter) = 0;
DosAllocSeg(sizeof(SELPRTERStruct), (PSEL)&SELECTOROF(Selprter), 0);
lmemset(Selprter, 0x00, sizeof(SELPRTERStruct));
WinSetWindowULong(hWnd, OFFSET_SELPRTER, (ULONG)Selprter);
OFFSETOF(Prteradd) = 0;
DosAllocSeg(sizeof(PRTERADDStruct), (PSEL)&SELECTOROF(Prteradd), 0);
lmemset(Prteradd, 0x00, sizeof(PRTERADDStruct));
WinSetWindowULong(hWnd, OFFSET_PRTERADD, (ULONG)Prteradd);
OFFSETOF(Prterdel) = 0;
DosAllocSeg(sizeof(PRTERDELStruct), (PSEL)&SELECTOROF(Prterdel), 0);
lmemset(Prterdel, 0x00, sizeof(PRTERDELStruct));
WinSetWindowULong(hWnd, OFFSET_PRTERDEL, (ULONG)Prterdel);
OFFSETOF(Prtchang) = 0;
DosAllocSeg(sizeof(PRTCHANGStruct), (PSEL)&SELECTOROF(Prtchang), 0);
lmemset(Prtchang, 0x00, sizeof(PRTCHANGStruct));
WinSetWindowULong(hWnd, OFFSET_PRTCHANG, (ULONG)Prtchang);
OFFSETOF(Selserv) = 0;
DosAllocSeg(sizeof(SELSERVStruct), (PSEL)&SELECTOROF(Selserv), 0);
lmemset(Selserv, 0x00, sizeof(SELSERVStruct));
WinSetWindowULong(hWnd, OFFSET_SELSERV, (ULONG)Selserv);
Selserv->ckSelected_UNIX_Format = FALSE;
OFFSETOF(Addserv) = 0;
DosAllocSeg(sizeof(ADDSERVStruct), (PSEL)&SELECTOROF(Addserv), 0);
lmemset(Addserv, 0x00, sizeof(ADDSERVStruct));
WinSetWindowULong(hWnd, OFFSET_ADDSERV, (ULONG)Addserv);
OFFSETOF(Delserv) = 0;
DosAllocSeg(sizeof(DELSERVStruct), (PSEL)&SELECTOROF(Delserv), 0);
lmemset(Delserv, 0x00, sizeof(DELSERVStruct));
WinSetWindowULong(hWnd, OFFSET_DELSERV, (ULONG)Delserv);
OFFSETOF(Chngserv) = 0;
DosAllocSeg(sizeof(CHNGSERVStruct), (PSEL)&SELECTOROF(Chngserv), 0);
lmemset(Chngserv, 0x00, sizeof(CHNGSERVStruct));
WinSetWindowULong(hWnd, OFFSET_CHNGSERV, (ULONG)Chngserv);
OFFSETOF(Queryprt) = 0;
DosAllocSeg(sizeof(QUERYPRTStruct), (PSEL)&SELECTOROF(Queryprt), 0);
lmemset(Queryprt, 0x00, sizeof(QUERYPRTStruct));
WinSetWindowULong(hWnd, OFFSET_QUERYPRT, (ULONG)Queryprt);
}
INT cwFreeDlgMemory(hWnd)
HWND hWnd;
{
CFGOPENStruct FAR *Cfgopen;
CFGSAVEStruct FAR *Cfgsave;
FSELECTStruct FAR *Fselect;
SELPRTERStruct FAR *Selprter;
PRTERADDStruct FAR *Prteradd;
PRTERDELStruct FAR *Prterdel;
PRTCHANGStruct FAR *Prtchang;
SELSERVStruct FAR *Selserv;
ADDSERVStruct FAR *Addserv;
DELSERVStruct FAR *Delserv;
CHNGSERVStruct FAR *Chngserv;
QUERYPRTStruct FAR *Queryprt;
Cfgopen = (CFGOPENStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CFGOPEN);
DosFreeSeg(SELECTOROF(Cfgopen));
Cfgsave = (CFGSAVEStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CFGSAVE);
DosFreeSeg(SELECTOROF(Cfgsave));
Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_FSELECT);
DosFreeSeg(SELECTOROF(Fselect));
Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SELPRTER);
DosFreeSeg(SELECTOROF(Selprter));
Prteradd = (PRTERADDStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTERADD);
DosFreeSeg(SELECTOROF(Prteradd));
Prterdel = (PRTERDELStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTERDEL);
DosFreeSeg(SELECTOROF(Prterdel));
Prtchang = (PRTCHANGStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTCHANG);
DosFreeSeg(SELECTOROF(Prtchang));
Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SELSERV);
DosFreeSeg(SELECTOROF(Selserv));
Addserv = (ADDSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_ADDSERV);
DosFreeSeg(SELECTOROF(Addserv));
Delserv = (DELSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_DELSERV);
DosFreeSeg(SELECTOROF(Delserv));
Chngserv = (CHNGSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CHNGSERV);
DosFreeSeg(SELECTOROF(Chngserv));
Queryprt = (QUERYPRTStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_QUERYPRT);
DosFreeSeg(SELECTOROF(Queryprt));
}
void lmemset(memptr, value, size)
void FAR *memptr;
char value;
int size;
{
char FAR *chrptr = memptr;
while (size--)
*chrptr++ = value;
}
/* LONGSTRCPY - is a functional equivalent to the C library routine */
/* strcpy, with the exception that it takes far pointers to */
/* to character strings as it's parameters. */
PSZ longstrcpy(target, source)
PSZ target;
PSZ source;
{
PSZ z = target;
while(*target++ = *source++);
return(z);
}