home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 19 Printer / 19-Printer.zip / LAPRINT.ZIP / LAPRINT.C < prev    next >
C/C++ Source or Header  |  1991-01-23  |  67KB  |  1,515 lines

  1.  
  2. /************************************************************************
  3. *                                                                       *
  4. *  (c) Cray Research, Inc., 1991.  All rights reserved.                 *
  5. *                                                                       *
  6. *     This program and/or module and all modifications made by Cray     *
  7. *  Research, Inc., are the sole property of Cray Research, Inc., and    *
  8. *  shall not be made available to or used by any person or persons      *
  9. *  without the prior written permission of Cray Research, Inc.          *
  10. *                                                                       *
  11. *     Programs and/or modules which are deemed in the public domain or  *
  12. *  whose copyright is held by another legal entity other than Cray      *
  13. *  Research, Inc., shall be deemed excluded from the above named        *
  14. *  restrictions and protections.                                        *
  15. *                                                                       *
  16. *     All changes made by Cray Research Inc which represent original    *
  17. *  work, modifications, descriptions or ideas to the above excluded     *
  18. *  programs and/or modules shall not be made available to or used by    *
  19. *  any person or persons without the prior written permission of        *
  20. *  Cray Research, Inc.                                                  *
  21. *                                                                       *
  22. ************************************************************************/
  23.  
  24. #define EXTERN
  25. #include "LAPRINT.h"
  26.  
  27. /***************************************************************************/
  28. /*                                                                         */
  29. /* Presentation Manager Program Main Body                                  */
  30. /*                                                                         */
  31. /* The following routine is the Presentation Manager program Main Body.    */
  32. /* The Main Body of a PM program is concerned with associating the         */
  33. /* application with the Presentation Manager system, creating its          */
  34. /* message queue, registering and displaying its main window, servicing    */
  35. /* its message queue during the time that the application is active,       */
  36. /* and disassociating the application from PM when the user is finished    */
  37. /* with the application. The remaining parts of this source module that    */
  38. /* are concerned with the Presentation Manager are the application's       */
  39. /* window procedures (main window procedure, child window procedures,      */
  40. /* and dialog window procedures) that process the messages associated      */
  41. /* with the application's various windows.                                 */
  42. /*                                                                         */
  43. /***************************************************************************/
  44.  
  45. SHORT cdecl main(argc, argv)
  46. int argc;
  47. char *argv[];
  48. {
  49.  
  50.  static CHAR szCRI_Copyright[]="(c) Cray Research, Inc., 1991.";
  51.  
  52.  QMSG qmsg;  /* MSG structure to store your messages                       */
  53.  PID  pid;   /* Process identifier for adding name to switch list          */
  54.  TID  tid;   /* Thread identifier                                          */
  55.  static CHAR szTitle[13];
  56.  
  57.  /* The WinInitialize routine initializes the Presentation Manager         */
  58.  /* facilities for use by this application and returns a handle to the     */
  59.  /* anchor block assigned to the application by PM.                        */
  60.  
  61.  if((hAB = WinInitialize(0)) == 0)
  62.     return(FALSE);
  63.   
  64.  /* The WinCreateMsgQueue call creates a message queue for this application*/
  65.  
  66.  if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
  67.     return(FALSE);
  68.  
  69.  /* The following function registers the classes of all application windows*/
  70.  if(!cwRegisterClass())
  71.     return(FALSE);
  72.  
  73.  /* If the application's Initialization Panel is not already shown, display*/
  74.  /* it on the desktop window before any other application window is shown. */
  75.  if(!WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP)INITIALMsgProc, 0, 
  76.     IDLG_INITIAL, (PBYTE)HWND_DESKTOP))
  77.     DosExit(0, 1);
  78.  
  79.  /**************************************************************************/
  80.  /* IPF Initialization Structure                                           */
  81.  /**************************************************************************/
  82.  
  83.  hiLAPRINTHelp.cb = sizeof(HELPINIT);  /* size of init structure      */
  84.  hiLAPRINTHelp.ulReturnCode = 0;
  85.  hiLAPRINTHelp.pszTutorialName = 0; /* no tutorial                         */
  86.  hiLAPRINTHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_LAPRINT);
  87.  hiLAPRINTHelp.hmodAccelActionBarModule = 0;
  88.  hiLAPRINTHelp.idAccelTable = 0;
  89.  hiLAPRINTHelp.idActionBar = 0;
  90.  hiLAPRINTHelp.pszHelpWindowTitle = "LAPRINT";
  91.  hiLAPRINTHelp.hmodHelpTableModule = 0;
  92.  hiLAPRINTHelp.usShowPanelId = 0;
  93.  hiLAPRINTHelp.pszHelpLibraryName = "LAPRINT.HLP";
  94.  
  95.  /**************************************************************************/
  96.  /* Create Instance of IPF                                                 */
  97.  /**************************************************************************/
  98.  
  99.  hWndLAPRINTHelp = WinCreateHelpInstance(hAB, &hiLAPRINTHelp);
  100.  if(!hWndLAPRINTHelp || hiLAPRINTHelp.ulReturnCode)
  101.    {
  102.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  103.                   (PSZ)"No help is available.",
  104.                   (PSZ) szAppName,
  105.                   1,
  106.                   MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  107.     WinDestroyHelpInstance(hWndLAPRINTHelp);
  108.    }
  109.  
  110.  /* The CreateWindow function creates a frame window for this application's*/
  111.  /* top window, and set the window's size and location as appropriate.     */
  112.  
  113.  WinLoadString(hAB, 0, IDS_TITLE, 13, szTitle);
  114.  hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
  115.           FCF_TITLEBAR     |
  116.           FCF_SYSMENU      |
  117.           FCF_MINBUTTON    |
  118.           FCF_MAXBUTTON    |
  119.           FCF_SIZEBORDER   |
  120.           FCF_MENU         |
  121.           FCF_ICON         |
  122.           FCF_SHELLPOSITION,
  123.           szAppName,
  124.           szTitle,
  125.           ID_LAPRINT,
  126.           0, 0,
  127.           0, 0,
  128.           &hWndClient,
  129.           0L, SWP_SHOW);
  130.  
  131.  if(hWndFrame == 0)
  132.     return(FALSE);
  133.  
  134.  /**************************************************************************/
  135.  /* Associate Instance of IPF                                              */
  136.  /**************************************************************************/
  137.  if(hWndLAPRINTHelp)
  138.    WinAssociateHelpInstance(hWndLAPRINTHelp, hWndFrame);
  139.  /* The following inline routine fills out the application's switch control*/
  140.  /* structure with the appropriate information to add the application's    */
  141.  /* name to the OS/2 Task Manager List, a list of the jobs currently       */
  142.  /* running on the computer.                                               */
  143.  
  144.  WinQueryWindowProcess(hWndFrame, &pid, &tid);
  145.  Swctl.hwnd = hWndFrame;                         /* Frame window handle    */
  146.  Swctl.idProcess = pid;                          /* Process identifier     */
  147.  Swctl.uchVisibility = SWL_VISIBLE;              /* visibility             */
  148.  Swctl.fbJump = SWL_JUMPABLE;                    /* Jump indicator         */
  149.  strcpy(Swctl.szSwtitle, szTitle);               /* Frame window title     */
  150.  hSwitch = WinAddSwitchEntry(&Swctl);
  151.    
  152.  BgmConfigNeedsSaving = FALSE;
  153.  cwEnableMenuItem(hWndFrame,
  154.                  IDM_F_QUERYREMOTEPRINTER,
  155.                  FALSE);
  156.  
  157.  /* The following is the message loop for the application.                 */
  158.  
  159.  while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
  160.        WinDispatchMsg(hAB,(PQMSG)&qmsg);
  161.  
  162.  /* Perform clean up before exiting application.                           */
  163.  /**************************************************************************/
  164.  /* Destroy Instance of IPF                                                */
  165.  /**************************************************************************/
  166.  if(hWndLAPRINTHelp)
  167.     WinDestroyHelpInstance(hWndLAPRINTHelp);
  168.  /* The following routine destroys the application's frame window (which   */
  169.  /* also destroys its child windows), destroys its message queue, and      */
  170.  /* disassociates the application from the Presentation Manager system.    */
  171.  
  172.  WinDestroyWindow(hWndFrame); /* Destroy the frame window                  */
  173.  WinDestroyMsgQueue(hMQ);     /* Destroy this application's message queue  */
  174.  WinTerminate(hAB);           /* Terminate this application's use of the   */
  175.                               /* Presentation Manager resources            */
  176. } /* end of main */
  177.  
  178.  
  179. /* The following Dialog box calls are generated for the dialog boxes that  */
  180. /* have been selected as "Unlinked" dialog boxes.  To use these calls,     */
  181. /* simply copy them to the appropriate location in the application.        */
  182.  
  183. #if 0
  184.  
  185.    hWndQUERYPRT = WinLoadDlg(HWND_DESKTOP, hWnd, (PFNWP)QUERYPRTMsgProc,
  186.                           0, IDLG_QUERYPRT, (PBYTE)hWnd);
  187.  
  188. #endif
  189.  
  190. /***************************************************************************/
  191. /*                                                                         */   
  192. /* Main Window Procedure                                                   */
  193. /*                                                                         */
  194. /* This procedure provides service routines for the general PM events      */
  195. /* (messages) that PM sends to the window, as well as the user             */
  196. /* initiated events (messages) that are generated when the user selects    */
  197. /* the action bar and pulldown menu controls or the corresponding          */
  198. /* keyboard accelerators.                                                  */
  199. /*                                                                         */
  200. /* The SWITCH statement shown below distributes the window messages to     */
  201. /* the respective message service routines, which are set apart by the     */
  202. /* CASE statements. The window procedures must provide an appropriate      */
  203. /* service routine for its end user initiated messages, as well as the     */
  204. /* general PM messages (like the WM_CLOSE message). If a message is        */
  205. /* sent to this procedure for which there is no programmed CASE clause     */
  206. /* (i.e., no service routine), the message is defaulted to the             */
  207. /* WinDefWindowProc function, where it is disposed of by PM.               */
  208. /*                                                                         */
  209. /***************************************************************************/
  210.  
  211. MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
  212. HWND hWnd;
  213. USHORT message;
  214. MPARAM mp1;
  215. MPARAM mp2;
  216. {                        /* Beginning of message processor                 */
  217.    HPS hPS;              /* Handle for the Presentation Space              */
  218.    RECTL rClient;        /* Handle to rectangle formed by client area      */
  219.    USHORT rc;            /* common return code value                       */
  220.    INT i;
  221.  
  222.    switch(message)
  223.      {
  224.       case WM_COMMAND:
  225.         /* The PM messages for action bar and pulldown menu items are      */
  226.         /* processed in this routine.                                      */
  227.   
  228.            switch(SHORT1FROMMP(mp1))
  229.             {
  230.              case IDM_F_NEW:
  231.                   /* Place User Code to respond to the                     */
  232.                   /* Menu Item Named "~New" here.                          */
  233.  
  234.                   BgmNew(hWndClient,
  235.                          TRUE,      /* CFGOPENStruct  reset       */
  236.                          TRUE,      /* CFGSAVEStruct  reset       */
  237.                          TRUE,      /* FSELECTStruct  reset       */
  238.                          TRUE,      /* SELSERVStruct  reset       */
  239.                          TRUE,      /* PRTERADDStruct reset       */
  240.                          TRUE,      /* PRTERDELStruct reset       */
  241.                          TRUE,      /* PRTCHANGStruct reset       */
  242.                          TRUE,      /* SELPRTERStruct reset       */
  243.                          TRUE,      /* ADDSERVStruct  reset       */
  244.                          TRUE,      /* DELSERVStruct  reset       */
  245.                          TRUE,      /* CHNGSERVStruct reset       */
  246.                          TRUE);     /* QUERYPRTStruct reset       */
  247.  
  248.                   break;
  249.  
  250.              case IDM_F_OPEN:
  251.                   /* This makes a call to the dialog box named             */
  252.                   /* "CFGOPEN" rc will receive the return code             */
  253.                   /* sent when the dialog box is closed                    */
  254.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CFGOPENMsgProc,
  255.                                  0, IDLG_CFGOPEN, (PBYTE)hWnd);
  256.                   break;
  257.  
  258.              case IDM_F_SAVE:
  259.                   /* Place User Code to respond to the                     */
  260.                   /* Menu Item Named "~Save" here.                         */
  261.                   {
  262.  
  263.                     CFGSAVEStruct  FAR *Cfgsave;
  264.  
  265.                     Cfgsave = (CFGSAVEStruct  FAR *)WinQueryWindowULong(hWndClient,
  266.                                                                         OFFSET_CFGSAVE);
  267.                     if(Cfgsave->szConfig_Directory[0] == NULL ||
  268.                        Cfgsave->szConfig_Filename[0] ==NULL)
  269.                     {
  270.                       WinPostMsg(hWnd,
  271.                                  WM_COMMAND,
  272.                                  MPFROMSHORT(IDM_F_SAVEAS),
  273.                                  0L);
  274.                       break;
  275.                     }
  276.  
  277.                     BgmWriteConfigFile(hWnd,
  278.                                        TRUE);
  279.  
  280.                   }
  281.                   break;
  282.  
  283.              case IDM_F_SAVEAS:
  284.                   /* This makes a call to the dialog box named             */
  285.                   /* "CFGSAVE" rc will receive the return code             */
  286.                   /* sent when the dialog box is closed                    */
  287.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CFGSAVEMsgProc,
  288.                                  0, IDLG_CFGSAVE, (PBYTE)hWnd);
  289.                   break;
  290.  
  291.              case IDM_F_PRINT:
  292.  
  293.                   {
  294.  
  295.                     FSELECTStruct  FAR *Fselect;
  296.  
  297.                     Fselect  = (FSELECTStruct  FAR *)WinQueryWindowULong(hWndClient,
  298.                                                                          OFFSET_FSELECT);
  299.  
  300.                     /****************************************************
  301.                     *                                                   *
  302.                     *     This section insures we have a file to print. *
  303.                     *     If we don't then we need to query the user    *
  304.                     *     for one via the File section to print dialog. *
  305.                     *                                                   *
  306.                     ****************************************************/
  307.                     if(Fselect->szSelected_Filename[0] == NULL ||
  308.                        isspace((int)Fselect->szSelected_Filename[0]) != 0)
  309.                     {
  310.                       WinPostMsg(hWnd,
  311.                                  WM_COMMAND,
  312.                                  MPFROMSHORT(IDM_F_SELECTFILETOPRINT),
  313.                                  0L);
  314.                       break;
  315.                     }
  316.  
  317.                   }
  318.  
  319.                   if (!WinIsWindow(hAB, hWndFPRINTObject))
  320.                     {
  321.                      /* if the window is not a valid window, allocate memory */
  322.                      /* for the thread's stack                               */
  323.                      DosAllocSeg(4096, &FPRINTObjSel, SEG_NONSHARED);
  324.                      FPRINTObjStack = (CHAR *)MAKEP(FPRINTObjSel, 0);  
  325.                      _beginthread((void FAR *)FPRINTObjFunction, FPRINTObjStack, 4096, 0);
  326.                     }
  327.                   break;
  328.  
  329.              case IDM_F_SELECTFILETOPRINT:
  330.                   /* This makes a call to the dialog box named             */
  331.                   /* "FSELECT" rc will receive the return code             */
  332.                   /* sent when the dialog box is closed                    */
  333.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)FSELECTMsgProc,
  334.                                  0, IDLG_FSELECT, (PBYTE)hWnd);
  335.                   break;
  336.  
  337.              case IDM_F_QUERYREMOTEPRINTER:
  338.                   if (!WinIsWindow(hAB, hWndFQUERYREMOTEPRINTERObject))
  339.                     {
  340.                      /* if the window is not a valid window, allocate memory */
  341.                      /* for the thread's stack                               */
  342.                      DosAllocSeg(4096, &FQUERYREMOTEPRINTERObjSel, SEG_NONSHARED);
  343.                      FQUERYREMOTEPRINTERObjStack = (CHAR *)MAKEP(FQUERYREMOTEPRINTERObjSel, 0);  
  344.                      _beginthread((void FAR *)FQUERYREMOTEPRINTERObjFunction, FQUERYREMOTEPRINTERObjStack, 4096, 0);
  345.                     }
  346.                   break;
  347.  
  348.              case IDM_F_EXIT:
  349.                   /* Place User Code to respond to the                     */
  350.                   /* Menu Item Named "E~xit" here.                         */
  351.  
  352.                   WinPostMsg(hWnd,
  353.                              WM_CLOSE,
  354.                              0L,
  355.                              0L);
  356.  
  357.                   break;
  358.  
  359.              case IDM_O_SELECTPRINTER:
  360.                   /* This makes a call to the dialog box named             */
  361.                   /* "SELPRTER" rc will receive the return code            */
  362.                   /* sent when the dialog box is closed                    */
  363.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)SELPRTERMsgProc,
  364.                                  0, IDLG_SELPRTER, (PBYTE)hWnd);
  365.                   break;
  366.  
  367.              case IDM_P_ADDPRINTER:
  368.                   /* This makes a call to the dialog box named             */
  369.                   /* "PRTERADD" rc will receive the return code            */
  370.                   /* sent when the dialog box is closed                    */
  371.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTERADDMsgProc,
  372.                                  0, IDLG_PRTERADD, (PBYTE)hWnd);
  373.                   break;
  374.  
  375.              case IDM_P_DELETEPRINTER:
  376.                   /* This makes a call to the dialog box named             */
  377.                   /* "PRTERDEL" rc will receive the return code            */
  378.                   /* sent when the dialog box is closed                    */
  379.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTERDELMsgProc,
  380.                                  0, IDLG_PRTERDEL, (PBYTE)hWnd);
  381.                   break;
  382.  
  383.              case IDM_P_CHANGEPRINTER:
  384.                   /* This makes a call to the dialog box named             */
  385.                   /* "PRTCHANG" rc will receive the return code            */
  386.                   /* sent when the dialog box is closed                    */
  387.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)PRTCHANGMsgProc,
  388.                                  0, IDLG_PRTCHANG, (PBYTE)hWnd);
  389.                   break;
  390.  
  391.              case IDM_S_SELECTSERVER:
  392.                   /* This makes a call to the dialog box named             */
  393.                   /* "SELSERV" rc will receive the return code             */
  394.                   /* sent when the dialog box is closed                    */
  395.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)SELSERVMsgProc,
  396.                                  0, IDLG_SELSERV, (PBYTE)hWnd);
  397.                   break;
  398.  
  399.              case IDM_O_ADDSERVER:
  400.                   /* This makes a call to the dialog box named             */
  401.                   /* "ADDSERV" rc will receive the return code             */
  402.                   /* sent when the dialog box is closed                    */
  403.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)ADDSERVMsgProc,
  404.                                  0, IDLG_ADDSERV, (PBYTE)hWnd);
  405.                   break;
  406.  
  407.              case IDM_S_DELETESERVER:
  408.                   /* This makes a call to the dialog box named             */
  409.                   /* "DELSERV" rc will receive the return code             */
  410.                   /* sent when the dialog box is closed                    */
  411.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)DELSERVMsgProc,
  412.                                  0, IDLG_DELSERV, (PBYTE)hWnd);
  413.                   break;
  414.  
  415.              case IDM_S_CHANGESERVER:
  416.                   /* This makes a call to the dialog box named             */
  417.                   /* "CHNGSERV" rc will receive the return code            */
  418.                   /* sent when the dialog box is closed                    */
  419.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CHNGSERVMsgProc,
  420.                                  0, IDLG_CHNGSERV, (PBYTE)hWnd);
  421.                   break;
  422.  
  423.              case IDM_O_NOLPRMESSAGES:
  424.                   /* Place User Code to respond to the                     */
  425.                   /* Menu Item Named "~No lpr messages" here.              */
  426.                   cwCheckPulldown(hWndFrame, IDM_O_NOLPRMESSAGES);
  427.                   break;
  428.  
  429.              case IDM_O_UNIXFORMAT:
  430.                   /* Place User Code to respond to the                     */
  431.                   /* Menu Item Named "~Unix format" here.                  */
  432.                   cwCheckPulldown(hWndFrame, IDM_O_UNIXFORMAT);
  433.                   break;
  434.  
  435.  
  436.             case IDM_H_HELPFORHELP:
  437.                  if(hWndLAPRINTHelp)
  438.                     WinSendMsg(hWndLAPRINTHelp, HM_DISPLAY_HELP, 0L, 0L);
  439.                  break;
  440.  
  441.              case IDM_H_ABOUT:
  442.                   rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)BGMABOUTMsgProc,
  443.                                  0, IDLG_BGMABOUT, (PBYTE)hWnd);
  444.                   break;
  445.  
  446.              default:
  447.                   break; /* End of default case for switch(mp1) */
  448.             }
  449.            break; /* End of WM_COMMAND */
  450.  
  451.  
  452.       case HM_QUERY_KEYS_HELP:
  453.            /* If the user requests Keys Help from the help pulldown,       */
  454.            /* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
  455.            /* which should return the panel id of the Keys Help panel      */
  456.            return((MRESULT)999);
  457.            break;
  458.  
  459.       case HM_ERROR:
  460.            /* If an IPF error occurs, an HM_ERROR message will be sent to  */
  461.            /* the application.                                             */
  462.            if(hWndLAPRINTHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
  463.              {
  464.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  465.                             (PSZ) "Help Terminated Due to Error",
  466.                             (PSZ) "Help Error",
  467.                             1,
  468.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  469.               WinDestroyHelpInstance(hWndLAPRINTHelp);
  470.              }
  471.             else
  472.              {
  473.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  474.                             (PSZ) "Help Error Occurred",
  475.                             (PSZ) "Help Error",
  476.                             1,
  477.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  478.              }
  479.            break;
  480.  
  481.       case WM_CREATE:
  482.            /* The WM_CREATE message is sent to a window when an application*/
  483.            /* requests that the window be created.  The window procedure   */
  484.            /* for the new window receives this message after the window is */
  485.            /* created, but before the window becomes visible.              */
  486.            /*                                                              */
  487.            cwSetInitDlgStatus(hWnd);
  488.            break; /* End of WM_CREATE */
  489.  
  490.       case WM_MOUSEMOVE:
  491.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  492.            break;
  493.  
  494.       case WM_SIZE:     /* code for sizing client area                     */
  495.            break;       /* End of WM_SIZE                                  */
  496.     
  497.       case WM_PAINT:    /* code for the window's client area               */
  498.            /* Obtain a handle to a cache presentation space                */
  499.            hPS = WinBeginPaint(hWnd, 0, 0);
  500.  
  501.            /* Determine the size of the client area                        */
  502.            WinQueryWindowRect(hWnd, &rClient);
  503.  
  504.            /* Fill the background with the default background color        */
  505.            WinFillRect(hPS, &rClient, CLR_BACKGROUND);
  506.  
  507.            /* return presentation space to state before WinBeginPaint      */
  508.            WinEndPaint(hPS);
  509.            break; /* End of WM_PAINT */
  510.  
  511.  
  512.       case WM_CLOSE:  /* close the window                                  */
  513.  
  514.            if(BgmConfigNeedsSaving != FALSE)
  515.            {
  516.  
  517.              i = WinMessageBox(HWND_DESKTOP,
  518.                                hWnd,
  519.                                (PSZ) "Current configuration not saved.  Do you wish to exit without saving? (No = Save and then exit)",
  520.                                (PSZ) szAppName,
  521.                                0,
  522.                                MB_YESNOCANCEL|MB_ICONEXCLAMATION);
  523.  
  524.              /***********************************************************
  525.              *                                                          *
  526.              *     This section processes an user Cancel on the above   *
  527.              *     message box by cancelling the close request.         *
  528.              *                                                          *
  529.              ***********************************************************/
  530.              if(i == MBID_CANCEL)
  531.              {
  532.                return(0L);
  533.              }
  534.  
  535.              /***********************************************************
  536.              *                                                          *
  537.              *     This section processes an user No on the above       *
  538.              *     message box by calling the Save configuration file   *
  539.              *     routine.                                             *
  540.              *                                                          *
  541.              *     We fall out of the BgmConfigNeedsSaving test when    *
  542.              *     the user's response is to say yes exit anyway.       *
  543.              *                                                          *
  544.              ***********************************************************/
  545.              if(i == MBID_NO)
  546.              {
  547.                WinPostMsg(hWnd,
  548.                           WM_COMMAND,
  549.                           MPFROMSHORT(IDM_F_SAVE),
  550.                           0L);
  551.                BgmConfigNeedsSaving = BGM_SAVE_THEN_EXIT;
  552.                return(0L);
  553.              }
  554.            }
  555.  
  556.            if(hWnd != hWndClient)
  557.              break;
  558.            cwFreeDlgMemory(hWnd);
  559.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  560.            break; /* End of WM_CLOSE */
  561.  
  562.       case WM_FREE_MEM: /* Free memory allocated for separate threads      */
  563.            DosFreeSeg((SEL)PVOIDFROMMP(mp1));
  564.            break;
  565.      
  566.       default:
  567.            /* For any message for which you don't specifically provide a   */
  568.            /* service routine, you should return the message to PM using   */
  569.            /* the WinDefWindowProc function.                               */
  570.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  571.            break;  /* End of default */
  572.      } 
  573.    return(0L);
  574. } /* End of WndProc */
  575.  
  576. /***************************************************************************/
  577. /*                                                                         */
  578. /* Dialog Window Procedure                                                 */
  579. /*                                                                         */
  580. /* This procedure is associated with the dialog box that is included in    */
  581. /* the function name of the procedure. It provides the service routines    */
  582. /* for the events (messages) that occur because the end user operates      */
  583. /* one of the dialog box's buttons, entry fields, or controls.             */
  584. /*                                                                         */
  585. /* The SWITCH statement in the function distributes the dialog box         */
  586. /* messages to the respective service routines, which are set apart by     */
  587. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  588. /* procedures must provide an appropriate service routine for their end    */
  589. /* user initiated messages as well as for the general PM messages (like    */
  590. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  591. /* which there is no programmed CASE condition (no service routine),       */
  592. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  593. /* disposed of by PM.                                                      */
  594. /*                                                                         */
  595. /***************************************************************************/
  596.  
  597. MRESULT EXPENTRY BGMABOUTMsgProc(hWndDlg, message, mp1, mp2)
  598. HWND hWndDlg;
  599. USHORT message;
  600. MPARAM mp1;
  601. MPARAM mp2;
  602.  static SHORT sfValidate = TRUE;
  603.  INT    i;
  604.  static HWND  hWndParent;
  605.           
  606.  switch(message)
  607.    {
  608.     case WM_INITDLG:
  609.          hWndParent = (HWND)mp2;
  610.          cwCenter(hWndDlg, (HWND)hWndParent);
  611.          break; /* End of WM_INITDLG */
  612.    
  613.     case WM_CONTROL:
  614.          switch(SHORT1FROMMP(mp1))
  615.            {
  616.            }
  617.          break; /* End of WM_CONTROL */
  618.    
  619.     case WM_COMMAND:
  620.          switch(SHORT1FROMMP(mp1))
  621.            {
  622.             case DID_OK: /* Button text: "Enter"                           */
  623.                  WinDismissDlg(hWndDlg, TRUE);
  624.                  break;
  625.  
  626.            }
  627.          break; /* End of WM_COMMAND */
  628.                                
  629.     case WM_CLOSE:
  630.          WinDismissDlg(hWndDlg, FALSE);
  631.          break; /* End of WM_CLOSE */
  632.            
  633.     case WM_FAILEDVALIDATE:
  634.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  635.          sfValidate = FALSE;
  636.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  637.          sfValidate = TRUE;
  638.          return((MRESULT)TRUE);
  639.          break; /* End of WM_FAILEDVALIDATE */
  640.  
  641.     default:
  642.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  643.          break;
  644.    }
  645.  return FALSE;
  646. } /* End of BGMABOUTMsgProc */
  647.  
  648.  
  649. /***************************************************************************/
  650. /*                                                                         */
  651. /* Dialog Window Procedure                                                 */
  652. /*                                                                         */
  653. /* This procedure is associated with the dialog box that is included in    */
  654. /* the function name of the procedure. It provides the service routines    */
  655. /* for the events (messages) that occur because the end user operates      */
  656. /* one of the dialog box's buttons, entry fields, or controls.             */
  657. /*                                                                         */
  658. /* The SWITCH statement in the function distributes the dialog box         */
  659. /* messages to the respective service routines, which are set apart by     */
  660. /* the CASE clauses. Like any other PM window, the Dialog Window           */
  661. /* procedures must provide an appropriate service routine for their end    */
  662. /* user initiated messages as well as for the general PM messages (like    */
  663. /* the WM_CLOSE message). If a message is sent to this procedure for       */
  664. /* which there is no programmed CASE condition (no service routine),       */
  665. /* the message is defaulted to the WinDefDlgProc function, where it is     */
  666. /* disposed of by PM.                                                      */
  667. /*                                                                         */
  668. /***************************************************************************/
  669.  
  670. MRESULT EXPENTRY INITIALMsgProc(hWndDlg, message, mp1, mp2)
  671. HWND hWndDlg;
  672. USHORT message;
  673. MPARAM mp1;
  674. MPARAM mp2;
  675.  static SHORT sfValidate = TRUE;
  676.  INT    i;
  677.  static INT   iLogoTime;
  678.  static HWND  hWndParent;
  679.           
  680.  switch(message)
  681.    {
  682.     case WM_INITDLG:
  683.          hWndParent = (HWND)mp2;
  684.          cwCenter(hWndDlg, (HWND)hWndParent);
  685.          iLogoTime = WinQueryProfileInt(hAB, "PM_ControlPanel",
  686.                                              "LogoDisplayTime", -1);
  687.          if(iLogoTime == 0)
  688.            {
  689.             WinDismissDlg(hWndDlg, TRUE);
  690.             break;
  691.            }
  692.          if(iLogoTime == -1)
  693.            break;
  694.          WinStartTimer(hAB, hWndDlg, ID_LOGO_TIMER, iLogoTime);
  695.          break; /* End of WM_INITDLG */
  696.    
  697.     case WM_TIMER:
  698.          WinStopTimer(hAB, hWndDlg, ID_LOGO_TIMER);
  699.          WinDismissDlg(hWndDlg, TRUE);
  700.          break;
  701.  
  702.     case WM_CONTROL:
  703.          switch(SHORT1FROMMP(mp1))
  704.            {
  705.            }
  706.          break; /* End of WM_CONTROL */
  707.    
  708.     case WM_COMMAND:
  709.          switch(SHORT1FROMMP(mp1))
  710.            {
  711.             case DID_OK: /* Button text: "Enter"                           */
  712.                  WinDismissDlg(hWndDlg, TRUE);
  713.                  break;
  714.  
  715.            }
  716.          break; /* End of WM_COMMAND */
  717.                                
  718.     case WM_CLOSE:
  719.          WinDismissDlg(hWndDlg, FALSE);
  720.          break; /* End of WM_CLOSE */
  721.            
  722.     case WM_FAILEDVALIDATE:
  723.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  724.          sfValidate = FALSE;
  725.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  726.          sfValidate = TRUE;
  727.          return((MRESULT)TRUE);
  728.          break; /* End of WM_FAILEDVALIDATE */
  729.  
  730.     default:
  731.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  732.          break;
  733.    }
  734.  return FALSE;
  735. } /* End of INITIALMsgProc */
  736.  
  737.  
  738. MRESULT EXPENTRY FPRINTObjWndProc(hWnd, message, mp1, mp2)
  739. HWND hWnd;
  740. USHORT message;
  741. MPARAM mp1;
  742. MPARAM mp2;
  743. {                            
  744.  QMSG        qmsg; /* MSG structure to store your messages                 */
  745.  
  746.    switch(message)
  747.      {
  748.       case WM_USER_DEFINED_CODE:
  749.            /* Copy the following two lines of code throughout your         */
  750.            /* threaded user defined code to enable your application to     */
  751.            /* kill this thread when the user requests so.  Modifications   */
  752.            /* may wish to be made to enable clean up of thread operations. */
  753.            /*                                                              */
  754.            /* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
  755.            /*    return(0L);                                               */
  756.            /*                                                              */
  757.  
  758.            BgmPrint(hWnd,
  759.                     TRUE);
  760.  
  761.            if(hWndFSELECT != 0)
  762.            {
  763.              WinEnableWindow((WinWindowFromID(hWndFSELECT,
  764.                                               DID_PRINT)),
  765.                              TRUE);
  766.            }
  767.           
  768.           /* After processing user defined code, post a WM_QUIT message    */
  769.           /* to terminate the thread                                       */
  770.            WinPostMsg(hWndFPRINTObject, WM_QUIT, 0L, 0L);
  771.            break;
  772.  
  773.       case WM_CREATE:
  774.            /* Post a message to start user defined code after startup      */
  775.            WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
  776.            break; /* End of WM_CREATE */
  777.  
  778.       default:
  779.            /* For any message for which you don't specifically provide a   */
  780.            /* service routine, you should return the message to PM using   */
  781.            /* the WinDefWindowProc function.                               */
  782.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  783.            break;  /* End of default */
  784.      } 
  785.    return(0L);
  786. } /* End of FPRINTObjWndProc */
  787.  
  788.  
  789. MRESULT EXPENTRY FSELECTDID_PRINTObjWndProc(hWnd, message, mp1, mp2)
  790. HWND hWnd;
  791. USHORT message;
  792. MPARAM mp1;
  793. MPARAM mp2;
  794. {                            
  795.  QMSG        qmsg; /* MSG structure to store your messages                 */
  796.  
  797.    switch(message)
  798.      {
  799.       case WM_USER_DEFINED_CODE:
  800.            /* Copy the following two lines of code throughout your         */
  801.            /* threaded user defined code to enable your application to     */
  802.            /* kill this thread when the user requests so.  Modifications   */
  803.            /* may wish to be made to enable clean up of thread operations. */
  804.            /*                                                              */
  805.            /* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
  806.            /*    return(0L);                                               */
  807.            /*                                                              */
  808.  
  809.            BgmPrint(hWndFSELECT,
  810.                     FALSE);
  811.           
  812.           /* After processing user defined code, post a WM_QUIT message    */
  813.           /* to terminate the thread                                       */
  814.            WinPostMsg(hWndFSELECTDID_PRINTObject, WM_QUIT, 0L, 0L);
  815.            break;
  816.  
  817.       case WM_CREATE:
  818.            /* Post a message to start user defined code after startup      */
  819.            WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
  820.            break; /* End of WM_CREATE */
  821.  
  822.       default:
  823.            /* For any message for which you don't specifically provide a   */
  824.            /* service routine, you should return the message to PM using   */
  825.            /* the WinDefWindowProc function.                               */
  826.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  827.            break;  /* End of default */
  828.      } 
  829.    return(0L);
  830. } /* End of FSELECTDID_PRINTObjWndProc */
  831.  
  832.  
  833. MRESULT EXPENTRY FQUERYREMOTEPRINTERObjWndProc(hWnd, message, mp1, mp2)
  834. HWND hWnd;
  835. USHORT message;
  836. MPARAM mp1;
  837. MPARAM mp2;
  838. {                            
  839.  QMSG        qmsg; /* MSG structure to store your messages                 */
  840.  
  841.    switch(message)
  842.      {
  843.       case WM_USER_DEFINED_CODE:
  844.            /* Copy the following two lines of code throughout your         */
  845.            /* threaded user defined code to enable your application to     */
  846.            /* kill this thread when the user requests so.  Modifications   */
  847.            /* may wish to be made to enable clean up of thread operations. */
  848.            /*                                                              */
  849.            /* if(WinPeekMsg(hAB, (PQMSG)&qmsg, hWnd, WM_QUIT, WM_QUIT, PM_NOREMOVE)) */
  850.            /*    return(0L);                                               */
  851.            /*                                                              */
  852. /* Query remote printer pulldown - rexec server lpq -Pprinter command */
  853.           
  854.           /* After processing user defined code, post a WM_QUIT message    */
  855.           /* to terminate the thread                                       */
  856.            WinPostMsg(hWndFQUERYREMOTEPRINTERObject, WM_QUIT, 0L, 0L);
  857.            break;
  858.  
  859.       case WM_CREATE:
  860.            /* Post a message to start user defined code after startup      */
  861.            WinPostMsg(hWnd, WM_USER_DEFINED_CODE, 0L, 0L);
  862.            break; /* End of WM_CREATE */
  863.  
  864.       default:
  865.            /* For any message for which you don't specifically provide a   */
  866.            /* service routine, you should return the message to PM using   */
  867.            /* the WinDefWindowProc function.                               */
  868.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  869.            break;  /* End of default */
  870.      } 
  871.    return(0L);
  872. } /* End of FQUERYREMOTEPRINTERObjWndProc */
  873.  
  874.  
  875.  
  876.  
  877. /***************************************************************************/
  878. /*                                                                         */
  879. /* cwRegisterClass Function                                                */
  880. /*                                                                         */
  881. /* The following function registers all the classes of all the windows     */
  882. /* associated with this application. The function returns TRUE if it is    */
  883. /* successful, otherwise it returns FALSE.                                 */
  884. /*                                                                         */
  885. /***************************************************************************/
  886.  
  887. INT cwRegisterClass()
  888. {
  889.  CLASSINFO ci;
  890.  INT rc;
  891.  
  892.  strcpy(szAppName, "LAPRINT");
  893.  rc = WinRegisterClass(hAB,             /* Anchor block handle             */
  894.                       (PCH)szAppName,   /* Name of class being registered  */
  895.                       (PFNWP)WndProc,   /* Window procedure for class      */
  896.                       CS_SIZEREDRAW ,
  897.                       12*sizeof(char FAR *));
  898.  if (rc == FALSE)
  899.    return(FALSE);
  900.  
  901.  WinQueryClassInfo(hAB, WC_ENTRYFIELD, (PCLASSINFO)&ci);
  902.  pfnEditWndProc = ci.pfnWindowProc;
  903.  rc = WinRegisterClass(hAB, "UDAlpha", UDCharWndProc, CS_SIZEREDRAW, 
  904.                         ci.cbWindowData + sizeof(PVOID));
  905.  if (rc == FALSE)
  906.    return(FALSE);
  907.  
  908.  return(TRUE);
  909. } /* End of cwRegisterClass */
  910.  
  911.  
  912.  
  913. /***************************************************************************/
  914. /*                                                                         */
  915. /* cwCreateWindow Function                                                 */
  916. /*                                                                         */
  917. /* The following function is used to create a window (the main window,     */
  918. /* a child window, an icon window, etc.) and set it's initial size and     */
  919. /* position. It returns the handle to the frame window.                    */
  920. /*                                                                         */
  921. /***************************************************************************/
  922.  
  923. HWND cwCreateWindow(
  924.    HWND   hWndParent,  /* Handle to the parent of the window to be created */
  925.    ULONG  ctldata,     /* Frame control flags for the window               */
  926.    PCH    appname,     /* Class name of the window                         */
  927.    PCH    title,       /* Title of the window                              */
  928.    USHORT ResID,       /* Resource id value                                */
  929.    INT    x,           /* Initial horizontal and vertical location         */
  930.    INT    y,
  931.    INT    cx,          /* Initial width and height of the window           */
  932.    INT    cy, 
  933.    PHWND  hWndClient,  /* Handle to the client area of the window          */
  934.    ULONG  lfStyle,     /* Frame window style                               */
  935.    USHORT uSizeStyle)  /* User defined size and location flags             */
  936. {
  937.    USHORT rc;            /* accepts return codes from function calls       */
  938.    HWND   hWndFrame;     /* local handle to created window frame           */
  939.    USHORT SizeStyle;     /* local window positioning options               */
  940.    CHAR   MsgBuffer[80]; /* buffer for error messages                      */
  941.    HPS    hPS;           /* handle to a presentation space                 */
  942.    int    xmod, ymod;    /* modifiers for sizing                           */
  943.    #define DLGXMOD  4    /* Dialog units X modulo */
  944.    #define DLGYMOD  8    /* Dialog units Y modulo */
  945.    FONTMETRICS fm;       /* structure for determing modifiers              */
  946.    /* Create the frame window                                              */
  947.    hWndFrame = WinCreateStdWindow(hWndParent,  /* parent of window         */
  948.                                   lfStyle,     /* frame window style       */
  949.                                   &ctldata,    /* frame flags              */
  950.                                   appname,     /* class name               */
  951.                                   title,       /* window title             */
  952.                                   0L,          /* client window style      */
  953.                                   0,           /* module for resources     */
  954.                                   ResID,       /* resource id              */
  955.                                   (HWND FAR *)hWndClient); /* client handle*/
  956.  
  957.    /* if hWndFrame is NULL, an error occured when opening the window,      */
  958.    /*     notify the user and exit this function                           */
  959.    if(hWndFrame == 0)
  960.      {
  961.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
  962.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  963.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  964.       return((HWND)0);
  965.      }
  966.  
  967.    /* set up size options                                                  */
  968.    SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
  969.  
  970.    /* if the height, width, intial x or initial y values are non-zero,     */
  971.    /*     then we will need to set up the modifiers for size and location  */
  972.    if((cx > 0) || (cy > 0) ||
  973.       (x > 0)  || (y > 0))
  974.      {
  975.       hPS = WinGetPS(HWND_DESKTOP);
  976.       GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
  977.       xmod = (INT)fm.lAveCharWidth;
  978.       ymod = (INT)fm.lMaxBaselineExt;
  979.       WinReleasePS(hPS);
  980.      }
  981.    /* if either the width or the height are non-zero, then the size of the */
  982.    /*     created window will be changed, set SizeStyle accordingly        */
  983.    if((cx > 0) || (cy > 0))
  984.      SizeStyle |= SWP_SIZE;
  985.    /* set the size and position of the window and activate it              */
  986.    rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
  987.                         (USHORT)(cx * xmod)/DLGXMOD,
  988.                         (USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
  989.  
  990.    /* if the either the intial x or y position of the window is non-zero,  */
  991.    /*    set the window to its new position                                */
  992.    if((x > 0) || (y > 0))
  993.      rc = WinSetWindowPos(hWndFrame, HWND_TOP,
  994.                           (USHORT)(x * xmod)/DLGXMOD,
  995.                           (USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
  996.    
  997.    /* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
  998.    /*     and exit this function                                           */
  999.    if(!rc)
  1000.      {
  1001.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
  1002.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  1003.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  1004.       return((HWND)0);
  1005.      }
  1006.  
  1007.    /* return the handle to the frame window                                */
  1008.    return(hWndFrame);
  1009. }  /* End of cwCreateWindow */
  1010.  
  1011.  
  1012. VOID FAR FPRINTObjFunction()
  1013. {
  1014.  QMSG lqmsg;  /* MSG structure to store your messages                      */
  1015.  HAB  lhAB;   /* Handle to the Anchor Block                                */
  1016.  HMQ  lhMQ;   /* Handle to the Message Queue                               */
  1017.  
  1018.  /* Initialize the Presentation Manager facilities for use by this         */
  1019.  /* application, return the handle to our anchor block                     */
  1020.  lhAB = WinInitialize(0);
  1021.  
  1022.  /* Create a message queue for this application                            */
  1023.  lhMQ = WinCreateMsgQueue(lhAB, 0);
  1024.  strcpy(szFPRINTObjAppName, "FPRINT");
  1025.  WinRegisterClass(hAB, (PCH)szFPRINTObjAppName,
  1026.                   (PFNWP)FPRINTObjWndProc,
  1027.                   0L, 0);
  1028.  
  1029.  hWndFPRINTObject = WinCreateWindow(HWND_OBJECT, szFPRINTObjAppName,
  1030.                                 0, 0L, 0, 0, 0, 0, 0,
  1031.                                 HWND_TOP, 0, 0, 0);
  1032.  
  1033.  cwEnableMenuItem(hWndFrame, IDM_F_PRINT, FALSE);
  1034.  
  1035.  while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
  1036.        WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
  1037.  
  1038.  cwEnableMenuItem(hWndFrame, IDM_F_PRINT, TRUE);
  1039.  
  1040.  /* Perform clean up before exiting application                            */
  1041.  WinDestroyWindow(hWndFPRINTObject); /* Destroy the frame window */
  1042.  WinDestroyMsgQueue(lhMQ);      /* Destroy this application's message queue */
  1043.  DosEnterCritSec();
  1044.  WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FPRINTObjSel), 0L);
  1045.  WinTerminate(lhAB);                 /* Terminate this thread's use of the */
  1046.                                      /* Presentation Manager resources     */
  1047.  _endthread();
  1048. }
  1049.  
  1050. VOID FAR FSELECTDID_PRINTObjFunction()
  1051. {
  1052.  QMSG lqmsg;  /* MSG structure to store your messages                      */
  1053.  HAB  lhAB;   /* Handle to the Anchor Block                                */
  1054.  HMQ  lhMQ;   /* Handle to the Message Queue                               */
  1055.  
  1056.  /* Initialize the Presentation Manager facilities for use by this         */
  1057.  /* application, return the handle to our anchor block                     */
  1058.  lhAB = WinInitialize(0);
  1059.  
  1060.  /* Create a message queue for this application                            */
  1061.  lhMQ = WinCreateMsgQueue(lhAB, 0);
  1062.  strcpy(szFSELECTDID_PRINTObjAppName, "FSELECTDID_PRINT");
  1063.  WinRegisterClass(hAB, (PCH)szFSELECTDID_PRINTObjAppName,
  1064.                   (PFNWP)FSELECTDID_PRINTObjWndProc,
  1065.                   0L, 0);
  1066.  
  1067.  hWndFSELECTDID_PRINTObject = WinCreateWindow(HWND_OBJECT, szFSELECTDID_PRINTObjAppName,
  1068.                                 0, 0L, 0, 0, 0, 0, 0,
  1069.                                 HWND_TOP, 0, 0, 0);
  1070.  
  1071.  cwEnableMenuItem(hWndFrame, IDM_F_PRINT, FALSE);
  1072.  
  1073.  while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
  1074.        WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
  1075.  
  1076.  cwEnableMenuItem(hWndFrame, IDM_F_PRINT, TRUE);
  1077.  
  1078.  /* Perform clean up before exiting application                            */
  1079.  WinDestroyWindow(hWndFSELECTDID_PRINTObject); /* Destroy the frame window */
  1080.  WinDestroyMsgQueue(lhMQ);      /* Destroy this application's message queue */
  1081.  DosEnterCritSec();
  1082.  WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FSELECTDID_PRINTObjSel), 0L);
  1083.  WinTerminate(lhAB);                 /* Terminate this thread's use of the */
  1084.                                      /* Presentation Manager resources     */
  1085.  _endthread();
  1086. }
  1087.  
  1088. VOID FAR FQUERYREMOTEPRINTERObjFunction()
  1089. {
  1090.  QMSG lqmsg;  /* MSG structure to store your messages                      */
  1091.  HAB  lhAB;   /* Handle to the Anchor Block                                */
  1092.  HMQ  lhMQ;   /* Handle to the Message Queue                               */
  1093.  
  1094.  /* Initialize the Presentation Manager facilities for use by this         */
  1095.  /* application, return the handle to our anchor block                     */
  1096.  lhAB = WinInitialize(0);
  1097.  
  1098.  /* Create a message queue for this application                            */
  1099.  lhMQ = WinCreateMsgQueue(lhAB, 0);
  1100.  strcpy(szFQUERYREMOTEPRINTERObjAppName, "FQUERYREMOTEPRINTER");
  1101.  WinRegisterClass(hAB, (PCH)szFQUERYREMOTEPRINTERObjAppName,
  1102.                   (PFNWP)FQUERYREMOTEPRINTERObjWndProc,
  1103.                   0L, 0);
  1104.  
  1105.  hWndFQUERYREMOTEPRINTERObject = WinCreateWindow(HWND_OBJECT, szFQUERYREMOTEPRINTERObjAppName,
  1106.                                 0, 0L, 0, 0, 0, 0, 0,
  1107.                                 HWND_TOP, 0, 0, 0);
  1108.  
  1109.  cwEnableMenuItem(hWndFrame, IDM_F_QUERYREMOTEPRINTER, FALSE);
  1110.  
  1111.  while(WinGetMsg(lhAB, (PQMSG)&lqmsg, 0, 0, 0))
  1112.        WinDispatchMsg(lhAB,(PQMSG)&lqmsg);
  1113.  
  1114.  cwEnableMenuItem(hWndFrame, IDM_F_QUERYREMOTEPRINTER, TRUE);
  1115.  
  1116.  /* Perform clean up before exiting application                            */
  1117.  WinDestroyWindow(hWndFQUERYREMOTEPRINTERObject); /* Destroy the frame window */
  1118.  WinDestroyMsgQueue(lhMQ);      /* Destroy this application's message queue */
  1119.  DosEnterCritSec();
  1120.  WinPostMsg(hWndFrame, WM_FREE_MEM, MPFROMP(FQUERYREMOTEPRINTERObjSel), 0L);
  1121.  WinTerminate(lhAB);                 /* Terminate this thread's use of the */
  1122.                                      /* Presentation Manager resources     */
  1123.  _endthread();
  1124. }
  1125.  
  1126.  
  1127. /* cwCheckPulldown accepts as input a handle to a frame window that a      */
  1128. /*    pulldown belongs to and the id value of this pulldown item.  It      */
  1129. /*    determines whether this item is checked or unchecked; if it is       */
  1130. /*    unchecked the pulldown item is checked and TRUE is returned, if it   */
  1131. /*    is checked the pulldown item is unchecked and FALSE is returned.     */
  1132.  
  1133. USHORT cwCheckPulldown(hWnd, item)
  1134. HWND   hWnd;     /* handle to the frame window                             */
  1135. USHORT item;     /* id value of the item to be checked/unchecked           */
  1136. {
  1137.    MENUITEM Menu;  /* structure to store attributes of menu item           */
  1138.  
  1139.    /* query the system for the attributes of this particular menu item     */
  1140.    WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
  1141.               MM_QUERYITEM,
  1142.               MPFROM2SHORT(item, TRUE),
  1143.               MPFROMP((PMENUITEM)&Menu));
  1144.  
  1145.    /* if this menu item's MIA_CHECKED bit is on, uncheck the menu item,    */
  1146.    /*    else, check the menu item                                         */
  1147.    Menu.afAttribute = ~Menu.afAttribute;
  1148.    WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
  1149.              MM_SETITEMATTR, MPFROM2SHORT(item, TRUE),
  1150.              MPFROM2SHORT(MIA_CHECKED, Menu.afAttribute));
  1151.    return(Menu.afAttribute & MIA_CHECKED);
  1152. } /* End of cwCheckPulldown function */
  1153.  
  1154. INT cwFillFileListBox(hWnd, szFileSpec, ListID)
  1155. HWND hWnd;
  1156. PSZ szFileSpec;
  1157. INT  ListID;
  1158. {
  1159.  FILEFINDBUF findbuf ;
  1160.  HDIR        hDir = 1 ;
  1161.  USHORT      usSearchCount = 1 ;
  1162.  
  1163.  WinSendDlgItemMsg(hWnd, ListID, LM_DELETEALL, 0, 0) ;
  1164.  DosFindFirst(szFileSpec, &hDir, 0x0007, &findbuf, sizeof(findbuf),
  1165.                               &usSearchCount, 0L) ;
  1166.  while(usSearchCount)
  1167.    {
  1168.     WinSendDlgItemMsg(hWnd, ListID, LM_INSERTITEM,
  1169.                       MPFROM2SHORT(LIT_SORTASCENDING, 0),
  1170.                       MPFROMP(findbuf.achName));
  1171.  
  1172.     DosFindNext(hDir, &findbuf, sizeof(findbuf), &usSearchCount) ;
  1173.    }
  1174.  return(1);
  1175. }
  1176.  
  1177.  
  1178. /***************************************************************************/
  1179. /*  cwAlphaValidate Function                                               */
  1180. /*                                                                         */
  1181. /*  Returns TRUE if the string is acceptable, otherwise returns FALSE      */
  1182. /*                                                                         */
  1183. /***************************************************************************/
  1184. INT cwAlphaValidate(string)
  1185. CHAR *string;
  1186. {
  1187.  int count;
  1188.  for(count = 0; count <= strlen(string)-1; count++)
  1189.     if(!isalnum((int)string[count]))
  1190.       if(!isspace((int)string[count]))
  1191.          return(FALSE);
  1192.  return(TRUE);
  1193. }
  1194.  
  1195. /***************************************************************************/
  1196. /*  UDCharWndProc                                                          */
  1197. /*                                                                         */
  1198. /*  Is used on subclassing edit fields for character validation            */
  1199. /*                                                                         */
  1200. /***************************************************************************/
  1201. MRESULT EXPENTRY UDCharWndProc(hWnd, message, mp1, mp2)
  1202. HWND hWnd;
  1203. USHORT message;
  1204. MPARAM mp1;
  1205. MPARAM mp2;
  1206.  static CHAR key;
  1207.  switch(message)
  1208.    {
  1209.     case WM_CHAR:
  1210.          if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
  1211.          {
  1212.            key = ((CHAR)SHORT1FROMMP(mp2));
  1213.            if((int)key == 0x20)
  1214.            {
  1215.              WinAlarm(HWND_DESKTOP,
  1216.                       WA_ERROR);
  1217.              return((MRESULT)TRUE);
  1218.            }
  1219.            break;
  1220.          }
  1221.          if(SHORT1FROMMP(mp1) & KC_CHAR)
  1222.            {
  1223.             key = (CHAR)SHORT1FROMMP(mp2);
  1224.             if(isalnum((int)key))
  1225.               return(pfnEditWndProc(hWnd, message, mp1, mp2));
  1226.             else
  1227.              {
  1228.               WinAlarm(HWND_DESKTOP, WA_ERROR);
  1229.               return((MRESULT)TRUE);
  1230.              }
  1231.            }
  1232.          break;
  1233.  
  1234.     case WM_TRANSLATEACCEL:
  1235.          return((MRESULT)FALSE);
  1236.          break;
  1237.    } 
  1238.  return(pfnEditWndProc(hWnd, message, mp1, mp2));
  1239. } /* End of UDCharWndProc */
  1240.  
  1241. /***************************************************************************/
  1242. /*  cwCenter Function                                                      */
  1243. /*                                                                         */
  1244. /*  Centers a dialog box on the client area of the caller                  */
  1245. /*                                                                         */
  1246. /***************************************************************************/
  1247.  
  1248. INT cwCenter(hWnd, hWndParent)                                              
  1249. HWND hWnd;         /* handle of the window to be centered                  */
  1250. HWND hWndParent;   /* handle of the window to center on                    */
  1251. {
  1252.   ULONG  SrcX, SrcY;                /* Center of parent                    */
  1253.   INT    ix, iy;                    /* Destination points                  */
  1254.   SWP    DlgSwp, ParentSwp;         /* Set window position structures      */
  1255.   ULONG  ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP           */
  1256.   POINTL pt;                        /* Point                               */
  1257.  
  1258.   /* Determine the width and height of the DESKTOP so the dialog box       */
  1259.   /* will not be positioned to a point off of the screen.                  */
  1260.   ScreenWidth  = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  1261.   ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  1262.  
  1263.   /* Query width and depth of dialog box                                   */
  1264.   WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
  1265.  
  1266.   /* Query width and depth of caller                                       */
  1267.   WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
  1268.  
  1269.   /* Map the point parent points to the Desktop                            */
  1270.   pt.x = ParentSwp.x;
  1271.   pt.y = ParentSwp.y;
  1272.  
  1273.   /* Convert the point from having our window as the origin to having      */
  1274.   /* the DESKTOP as the origin                                             */
  1275.   WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
  1276.  
  1277.   SrcX = pt.x + (ParentSwp.cx / 2);
  1278.   SrcY = pt.y + (ParentSwp.cy / 2);
  1279.  
  1280.   /* Determine the point to move the dialog box to                         */
  1281.   ix = (INT)(SrcX - (DlgSwp.cx / 2));
  1282.   iy = (INT)(SrcY - (DlgSwp.cy / 2));
  1283.  
  1284.   /* if either point is less than zero, then set that point to zero        */
  1285.   /* so the dialog box will not be positoned off of the window             */
  1286.   ix = (ix < 0) ? 0 : ix;
  1287.   iy = (iy < 0) ? 0 : iy;
  1288.  
  1289.   /* if either point plus the height or width of the dialog box is         */
  1290.   /* greater than the height or width of the screen adjust point           */
  1291.   if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
  1292.     ix = (INT)(ScreenWidth - DlgSwp.cx);
  1293.   if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
  1294.     iy = (INT)(ScreenHeight - DlgSwp.cy);
  1295.  
  1296.   /* move the dialog box                                                   */
  1297.   return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
  1298. }
  1299.  
  1300. INT cwEnableMenuItem(hWnd, idval, bool)
  1301. HWND hWnd;
  1302. INT  idval;
  1303. INT  bool;
  1304. {
  1305.  INT rc;
  1306.  
  1307.  rc = (INT)WinSendMsg(WinWindowFromID(hWnd, FID_MENU),
  1308.                       MM_SETITEMATTR, MPFROM2SHORT(idval, TRUE),
  1309.                       MPFROM2SHORT(MIA_DISABLED,
  1310.                       bool ? ~MIA_DISABLED : MIA_DISABLED));
  1311.  return(rc);
  1312. }
  1313.  
  1314. INT cwFillDirListBox(hWndDlg, id, targetid)
  1315. HWND hWndDlg;
  1316. USHORT id;
  1317. USHORT targetid;
  1318. {
  1319.  static CHAR buffer[10];
  1320.  FILEFINDBUF findbuf;
  1321.  HDIR        hDir = 1;
  1322.  SHORT       sDrive;
  1323.  USHORT      usDriveNum, usSearchCount = 1;
  1324.  ULONG       ulDriveMap;
  1325.  SHORT       rc;
  1326.  CHAR        szBuffer[128];
  1327.  USHORT      usPathLen;
  1328.  
  1329.  WinSendDlgItemMsg(hWndDlg, id, LM_DELETEALL, 0, 0) ;
  1330.  rc = DosFindFirst("*.*", &hDir, 0x0017, &findbuf,
  1331.                    sizeof(findbuf), &usSearchCount, 0L);
  1332.  if(rc!=0)
  1333.    return( -1 );
  1334.       
  1335.  while(usSearchCount)
  1336.     {
  1337.      if(findbuf.attrFile & 0x0010 &&
  1338.         (findbuf.achName [0] != '.' || findbuf.achName [1]))
  1339.                WinSendDlgItemMsg(hWndDlg, id, LM_INSERTITEM,
  1340.                                  MPFROM2SHORT(LIT_SORTASCENDING, 0),
  1341.                                  MPFROMP(findbuf.achName));
  1342.      DosFindNext(hDir, &findbuf, sizeof findbuf, &usSearchCount) ;
  1343.     }
  1344.  
  1345.  rc = DosQCurDisk(&usDriveNum, &ulDriveMap);
  1346.  for(sDrive = 0; sDrive < 26; sDrive++)
  1347.    if(ulDriveMap & 1L << sDrive)
  1348.      {
  1349.       sprintf(buffer,"[%c:]", (CHAR)sDrive + 'A');
  1350.       WinSendDlgItemMsg(hWndDlg, id, LM_INSERTITEM,
  1351.                         MPFROM2SHORT(LIT_END, 0),
  1352.                         MPFROMP(buffer)) ;
  1353.      }
  1354.  usPathLen = sizeof(szBuffer);
  1355.  DosQCurDir(usDriveNum, &szBuffer[3], &usPathLen);
  1356.  szBuffer[0] = '@' + usDriveNum;
  1357.  szBuffer[1] = ':';
  1358.  szBuffer[2] = '\\';
  1359.  WinSetDlgItemText(hWndDlg, targetid, szBuffer);
  1360. }
  1361.  
  1362.  
  1363.  
  1364. /* This function initializes the states of all dialog box radio buttons    */
  1365. /* and check boxes that have had their initial status set to true          */
  1366. INT cwSetInitDlgStatus(hWnd)
  1367. HWND hWnd;
  1368. {
  1369.   CFGOPENStruct FAR *Cfgopen;
  1370.   CFGSAVEStruct FAR *Cfgsave;
  1371.   FSELECTStruct FAR *Fselect;
  1372.   SELPRTERStruct FAR *Selprter;
  1373.   PRTERADDStruct FAR *Prteradd;
  1374.   PRTERDELStruct FAR *Prterdel;
  1375.   PRTCHANGStruct FAR *Prtchang;
  1376.   SELSERVStruct FAR *Selserv;
  1377.   ADDSERVStruct FAR *Addserv;
  1378.   DELSERVStruct FAR *Delserv;
  1379.   CHNGSERVStruct FAR *Chngserv;
  1380.   QUERYPRTStruct FAR *Queryprt;
  1381.  
  1382.   OFFSETOF(Cfgopen) = 0;
  1383.   DosAllocSeg(sizeof(CFGOPENStruct), (PSEL)&SELECTOROF(Cfgopen), 0);
  1384.   lmemset(Cfgopen, 0x00, sizeof(CFGOPENStruct));
  1385.   WinSetWindowULong(hWnd, OFFSET_CFGOPEN, (ULONG)Cfgopen);
  1386.  
  1387.   OFFSETOF(Cfgsave) = 0;
  1388.   DosAllocSeg(sizeof(CFGSAVEStruct), (PSEL)&SELECTOROF(Cfgsave), 0);
  1389.   lmemset(Cfgsave, 0x00, sizeof(CFGSAVEStruct));
  1390.   WinSetWindowULong(hWnd, OFFSET_CFGSAVE, (ULONG)Cfgsave);
  1391.  
  1392.   OFFSETOF(Fselect) = 0;
  1393.   DosAllocSeg(sizeof(FSELECTStruct), (PSEL)&SELECTOROF(Fselect), 0);
  1394.   lmemset(Fselect, 0x00, sizeof(FSELECTStruct));
  1395.   WinSetWindowULong(hWnd, OFFSET_FSELECT, (ULONG)Fselect);
  1396.  
  1397.   OFFSETOF(Selprter) = 0;
  1398.   DosAllocSeg(sizeof(SELPRTERStruct), (PSEL)&SELECTOROF(Selprter), 0);
  1399.   lmemset(Selprter, 0x00, sizeof(SELPRTERStruct));
  1400.   WinSetWindowULong(hWnd, OFFSET_SELPRTER, (ULONG)Selprter);
  1401.  
  1402.   OFFSETOF(Prteradd) = 0;
  1403.   DosAllocSeg(sizeof(PRTERADDStruct), (PSEL)&SELECTOROF(Prteradd), 0);
  1404.   lmemset(Prteradd, 0x00, sizeof(PRTERADDStruct));
  1405.   WinSetWindowULong(hWnd, OFFSET_PRTERADD, (ULONG)Prteradd);
  1406.  
  1407.   OFFSETOF(Prterdel) = 0;
  1408.   DosAllocSeg(sizeof(PRTERDELStruct), (PSEL)&SELECTOROF(Prterdel), 0);
  1409.   lmemset(Prterdel, 0x00, sizeof(PRTERDELStruct));
  1410.   WinSetWindowULong(hWnd, OFFSET_PRTERDEL, (ULONG)Prterdel);
  1411.  
  1412.   OFFSETOF(Prtchang) = 0;
  1413.   DosAllocSeg(sizeof(PRTCHANGStruct), (PSEL)&SELECTOROF(Prtchang), 0);
  1414.   lmemset(Prtchang, 0x00, sizeof(PRTCHANGStruct));
  1415.   WinSetWindowULong(hWnd, OFFSET_PRTCHANG, (ULONG)Prtchang);
  1416.  
  1417.   OFFSETOF(Selserv) = 0;
  1418.   DosAllocSeg(sizeof(SELSERVStruct), (PSEL)&SELECTOROF(Selserv), 0);
  1419.   lmemset(Selserv, 0x00, sizeof(SELSERVStruct));
  1420.   WinSetWindowULong(hWnd, OFFSET_SELSERV, (ULONG)Selserv);
  1421.   Selserv->ckSelected_UNIX_Format = FALSE;
  1422.  
  1423.   OFFSETOF(Addserv) = 0;
  1424.   DosAllocSeg(sizeof(ADDSERVStruct), (PSEL)&SELECTOROF(Addserv), 0);
  1425.   lmemset(Addserv, 0x00, sizeof(ADDSERVStruct));
  1426.   WinSetWindowULong(hWnd, OFFSET_ADDSERV, (ULONG)Addserv);
  1427.  
  1428.   OFFSETOF(Delserv) = 0;
  1429.   DosAllocSeg(sizeof(DELSERVStruct), (PSEL)&SELECTOROF(Delserv), 0);
  1430.   lmemset(Delserv, 0x00, sizeof(DELSERVStruct));
  1431.   WinSetWindowULong(hWnd, OFFSET_DELSERV, (ULONG)Delserv);
  1432.  
  1433.   OFFSETOF(Chngserv) = 0;
  1434.   DosAllocSeg(sizeof(CHNGSERVStruct), (PSEL)&SELECTOROF(Chngserv), 0);
  1435.   lmemset(Chngserv, 0x00, sizeof(CHNGSERVStruct));
  1436.   WinSetWindowULong(hWnd, OFFSET_CHNGSERV, (ULONG)Chngserv);
  1437.  
  1438.   OFFSETOF(Queryprt) = 0;
  1439.   DosAllocSeg(sizeof(QUERYPRTStruct), (PSEL)&SELECTOROF(Queryprt), 0);
  1440.   lmemset(Queryprt, 0x00, sizeof(QUERYPRTStruct));
  1441.   WinSetWindowULong(hWnd, OFFSET_QUERYPRT, (ULONG)Queryprt);
  1442.  
  1443. }
  1444.  
  1445. INT cwFreeDlgMemory(hWnd)
  1446. HWND hWnd;
  1447. {
  1448.   CFGOPENStruct FAR *Cfgopen;
  1449.   CFGSAVEStruct FAR *Cfgsave;
  1450.   FSELECTStruct FAR *Fselect;
  1451.   SELPRTERStruct FAR *Selprter;
  1452.   PRTERADDStruct FAR *Prteradd;
  1453.   PRTERDELStruct FAR *Prterdel;
  1454.   PRTCHANGStruct FAR *Prtchang;
  1455.   SELSERVStruct FAR *Selserv;
  1456.   ADDSERVStruct FAR *Addserv;
  1457.   DELSERVStruct FAR *Delserv;
  1458.   CHNGSERVStruct FAR *Chngserv;
  1459.   QUERYPRTStruct FAR *Queryprt;
  1460.  
  1461.   Cfgopen = (CFGOPENStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CFGOPEN);
  1462.   DosFreeSeg(SELECTOROF(Cfgopen));
  1463.   Cfgsave = (CFGSAVEStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CFGSAVE);
  1464.   DosFreeSeg(SELECTOROF(Cfgsave));
  1465.   Fselect = (FSELECTStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_FSELECT);
  1466.   DosFreeSeg(SELECTOROF(Fselect));
  1467.   Selprter = (SELPRTERStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SELPRTER);
  1468.   DosFreeSeg(SELECTOROF(Selprter));
  1469.   Prteradd = (PRTERADDStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTERADD);
  1470.   DosFreeSeg(SELECTOROF(Prteradd));
  1471.   Prterdel = (PRTERDELStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTERDEL);
  1472.   DosFreeSeg(SELECTOROF(Prterdel));
  1473.   Prtchang = (PRTCHANGStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_PRTCHANG);
  1474.   DosFreeSeg(SELECTOROF(Prtchang));
  1475.   Selserv = (SELSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SELSERV);
  1476.   DosFreeSeg(SELECTOROF(Selserv));
  1477.   Addserv = (ADDSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_ADDSERV);
  1478.   DosFreeSeg(SELECTOROF(Addserv));
  1479.   Delserv = (DELSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_DELSERV);
  1480.   DosFreeSeg(SELECTOROF(Delserv));
  1481.   Chngserv = (CHNGSERVStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CHNGSERV);
  1482.   DosFreeSeg(SELECTOROF(Chngserv));
  1483.   Queryprt = (QUERYPRTStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_QUERYPRT);
  1484.   DosFreeSeg(SELECTOROF(Queryprt));
  1485. }
  1486.  
  1487. void lmemset(memptr, value, size)
  1488. void FAR *memptr;
  1489. char     value;
  1490. int      size;
  1491. {
  1492.    char FAR *chrptr = memptr;
  1493.  
  1494.    while (size--)
  1495.       *chrptr++ = value;
  1496. }
  1497.  
  1498. /* LONGSTRCPY - is a functional equivalent to the C library routine        */
  1499. /*              strcpy, with the exception that it takes far pointers to   */
  1500. /*              to character strings as it's parameters.                   */
  1501. PSZ longstrcpy(target, source)
  1502. PSZ target;
  1503. PSZ source;
  1504. {
  1505.  PSZ z = target;
  1506.  while(*target++ = *source++);
  1507.  return(z);
  1508. }
  1509.  
  1510.  
  1511.  
  1512.