home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / pc2.zip / SOURCE.ZIP / SOURCE / DIALOG.C next >
Text File  |  1993-03-09  |  42KB  |  826 lines

  1. /***********************************************************************\
  2.  *                                PC2.c                                *
  3.  *                 Copyright (C) by Stangl Roman, 1993                 *
  4.  * This Code may be freely distributed, provided the Copyright isn't   *
  5.  * removed, under the conditions indicated in the documentation.       *
  6.  *                                                                     *
  7.  * Dialog.c     Dialog window procedures.                              *
  8.  *                                                                     *
  9. \***********************************************************************/
  10.  
  11. static char RCSID[]="@(#) $Header: Dialog.c Version 1.20 03,1993 $ (LBL)";
  12.  
  13. #define         _FILE_  "PC/2 - Dialog.c V1.20"
  14.  
  15. #include        "PC2.h"                 /* User include files */
  16. #include        "Error.h"
  17.  
  18. /*--------------------------------------------------------------------------------------*\
  19.  * This dialog procedure handles the PC/2 - About dialog.                               *
  20.  * Req: none                                                                            *
  21. \*--------------------------------------------------------------------------------------*/
  22. MRESULT  EXPENTRY AD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  23. {
  24. switch(msg)
  25. {
  26. case WM_INITDLG:
  27.     {
  28.     SWP         swp;
  29.  
  30.     WinQueryWindowPos(                  /* Query position of dialog window */
  31.         hwndDlg,                        /* Handle of dialog window */
  32.         &swp);                          /* Fill with position */
  33.     WinSetWindowPos(                    /* Set dialog window position */
  34.         hwndDlg,                        /* Handle of dialog window */
  35.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  36.         (swpScreen.cx-swp.cx)/2,
  37.         (swpScreen.cy-swp.cy)/2,
  38.         0,
  39.         0,
  40.         SWP_MOVE);
  41.     break;
  42.     }
  43.  
  44. case WM_HELP:                           /* Help pressed */
  45.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  46.         hwndHelp,                       /* Help window */
  47.         HM_DISPLAY_HELP,                /* Display a help panel */
  48.         MPFROMSHORT(ID_ABOUTDIALOG),    /* Panel ID in ressource file */
  49.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  50.     break;
  51.  
  52. case WM_COMMAND:                        /* Button pressed */
  53.     switch(SHORT1FROMMP(mp1))
  54.     {
  55.     case DID_OK:                        /* Enter key pressed */
  56.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  57.         break;
  58.  
  59.     case DID_CANCEL:                    /* Cancel key pressed */
  60.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  61.         break;
  62.  
  63.     default:
  64.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  65.     }
  66.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  67.     break;
  68.  
  69. default:                                /* Default window procedure must be called */
  70.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  71. }
  72. return((MRESULT)FALSE);                 /* We have handled the message */
  73. }
  74.  
  75. /*--------------------------------------------------------------------------------------*\
  76.  * This dialog procedure handles the PC/2 - Program Installation dialog.                *
  77.  * Req:                                                                                 *
  78.  *      StartSession .. a structure of type SESSIONDATA where the information entered   *
  79.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  80.  *                      is used to start the session and set its priority.              *
  81. \*--------------------------------------------------------------------------------------*/
  82. MRESULT  EXPENTRY PI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  83. {
  84. switch(msg)
  85. {
  86. case WM_INITDLG:
  87.     {
  88.     SWP         swp;
  89.     UCHAR       Buffer[4];
  90.  
  91.     WinQueryWindowPos(                  /* Query position of dialog window */
  92.         hwndDlg,                        /* Handle of dialog window */
  93.         &swp);                          /* Fill with position */
  94.     WinSetWindowPos(                    /* Set dialog window position */
  95.         hwndDlg,                        /* Handle of dialog window */
  96.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  97.         (swpScreen.cx-swp.cx)/2,
  98.         (swpScreen.cy-swp.cy)/2,
  99.         0,
  100.         0,
  101.         SWP_MOVE);
  102. /*                                                                                      *\
  103.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  104.  * default number of 63 and load the data from the SESSIONDATA structure SessionData    *
  105.  * into the entryfields.                                                                *
  106. \*                                                                                      */
  107.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  108.         hwndDlg,                        /* Handle of dialog window */
  109.         PIEF_PROGRAMTITLE,              /* Program title entryfield */
  110.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  111.         MPFROMSHORT(EF_SIZE60),
  112.         (MPARAM)NULL);                  /* No additional parameter */
  113.     WinSetDlgItemText(                  /* Load the default text of the entryfield */
  114.         hwndDlg,
  115.         PIEF_PROGRAMTITLE,
  116.         SessionData.PgmTitle);
  117.     WinSendDlgItemMsg(
  118.         hwndDlg,
  119.         PIEF_PATHFILENAME,              /* Path and Filename title entryfield */
  120.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  121.         MPFROMSHORT(EF_SIZE255),
  122.         (MPARAM)NULL);
  123.     WinSetDlgItemText( 
  124.         hwndDlg,
  125.         PIEF_PATHFILENAME,
  126.         SessionData.PgmName);
  127.     WinSendDlgItemMsg(
  128.         hwndDlg,
  129.         PIEF_DIRECTORY,                 /* Working directory entryfield */
  130.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  131.         MPFROMSHORT(EF_SIZE255),
  132.         (MPARAM)NULL);
  133.     WinSetDlgItemText(
  134.         hwndDlg,
  135.         PIEF_DIRECTORY,
  136.         SessionData.PgmDirectory);
  137.     WinSendDlgItemMsg(
  138.         hwndDlg,
  139.         PIEF_PARAMETERS,                /* Program Parameters entryfield */
  140.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  141.         MPFROMSHORT(EF_SIZE255),
  142.         (MPARAM)NULL);
  143.     WinSetDlgItemText(
  144.         hwndDlg,
  145.         PIEF_PARAMETERS,
  146.         SessionData.PgmInputs);
  147.                                         /* Insert DOS Settings. If none exist add the
  148.                                            IDLE_* default settings */
  149.     if(strlen(SessionData.PgmDosSettings)!=0)
  150.         WinSendDlgItemMsg(
  151.             hwndDlg,
  152.             PIEF_DOSSETTINGS,           /* Program DOS Settings entryfield */
  153.             MLM_INSERT,                 /* Insert text */
  154.             MPFROMP(SessionData.PgmDosSettings),
  155.             (MPARAM)NULL);
  156.     else
  157.         WinSendDlgItemMsg(
  158.             hwndDlg,
  159.             PIEF_DOSSETTINGS,           /* Program DOS Settings entryfield */
  160.             MLM_INSERT,                 /* Insert text */
  161.             MPFROMP("IDLE_SECONDS=5\nIDLE_SENSITIVITY=100\n"),
  162.             (MPARAM)NULL);
  163.     if((SessionData.SessionType!=SSF_TYPE_VDM) &&
  164.         (SessionData.SessionType!=SSF_TYPE_WINDOWEDVDM))
  165.         WinSetWindowPos(                /* Hide DOS Settings window until the application
  166.                                            type is DOS Window or DOS Fullscreen */
  167.             WinWindowFromID(hwndDlg, PIEF_DOSSETTINGS), 0, 0, 0, 0, 0,SWP_HIDE);
  168. /*                                                                                      *\
  169.  * Now we preselect the radiobutton in the Program type group to the state indicated by *
  170.  * the SessionData structure.                                                           *
  171. \*                                                                                      */
  172.     switch(SessionData.SessionType)
  173.     {
  174.     case SSF_TYPE_DEFAULT:
  175.         WinSendDlgItemMsg(              /* Send message to Shell radiobutton */
  176.             hwndDlg,                    /* Handle of dialog window */
  177.             PIRB_SHELL,                 /* Program type: Shell radiobutton */
  178.             BM_SETCHECK,                /* Set it to pressed */
  179.             MPFROMSHORT(TRUE),
  180.             (MPARAM)NULL);
  181.         break;
  182.     case SSF_TYPE_FULLSCREEN:
  183.         WinSendDlgItemMsg(
  184.             hwndDlg,
  185.             PIRB_OS2FULLSCREEN,         /* Program type: OS/2 Fullscreen radiobutton */
  186.             BM_SETCHECK,                /* Set it to pressed */
  187.             MPFROMSHORT(TRUE),
  188.             (MPARAM)NULL);
  189.         break;
  190.     case SSF_TYPE_WINDOWABLEVIO:
  191.         WinSendDlgItemMsg(
  192.             hwndDlg,
  193.             PIRB_OS2WINDOW,             /* Program type: OS/2 Window radiobutton */
  194.             BM_SETCHECK,                /* Set it to pressed */
  195.             MPFROMSHORT(TRUE),
  196.             (MPARAM)NULL);
  197.         break;
  198.     case SSF_TYPE_PM:
  199.         WinSendDlgItemMsg(
  200.             hwndDlg,
  201.             PIRB_PM,                    /* Program type: OS/2 PM radiobutton */
  202.             BM_SETCHECK,                /* Set it to pressed */
  203.             MPFROMSHORT(TRUE),
  204.             (MPARAM)NULL);
  205.         break;
  206.     case SSF_TYPE_VDM:
  207.         WinSendDlgItemMsg(
  208.             hwndDlg,
  209.             PIRB_DOSFULLSCREEN,         /* Program type: DOS Fullscreen radiobutton */
  210.             BM_SETCHECK,                /* Set it to pressed */
  211.             MPFROMSHORT(TRUE),
  212.             (MPARAM)NULL);
  213.         break;
  214.     case SSF_TYPE_WINDOWEDVDM:
  215.         WinSendDlgItemMsg(
  216.             hwndDlg,
  217.             PIRB_DOSWINDOW,             /* Program type: DOS Window radiobutton */
  218.             BM_SETCHECK,                /* Set it to pressed */
  219.             MPFROMSHORT(TRUE),
  220.             (MPARAM)NULL);
  221.         break;
  222.     }
  223. /*                                                                                      *\
  224.  * Now we preselect the radiobutton in the Program style group to the state indicated   *
  225.  * by the SessionData structure.                                                        *
  226. \*                                                                                      */
  227.  
  228.     if(!(SessionData.PgmControl & (SSF_CONTROL_MAXIMIZE | SSF_CONTROL_MINIMIZE)))
  229.         WinSendDlgItemMsg(              /* Send message to Default radiobutton */
  230.             hwndDlg,                    /* Handle of dialog window */
  231.             PIRB_DEFAULTSTYLE,          /* Program style: Default radiobutton */
  232.             BM_SETCHECK,                /* Set it to pressed */
  233.             MPFROMSHORT(TRUE),
  234.             (MPARAM)NULL);
  235.     if(SessionData.PgmControl & SSF_CONTROL_MAXIMIZE)
  236.         WinSendDlgItemMsg(
  237.             hwndDlg,
  238.             PIRB_MAXIMIZED,             /* Program style: Maximized radiobutton */
  239.             BM_SETCHECK,                /* Set it to pressed */
  240.             MPFROMSHORT(TRUE),
  241.             (MPARAM)NULL);
  242.     if(SessionData.PgmControl & SSF_CONTROL_MINIMIZE)
  243.         WinSendDlgItemMsg(
  244.             hwndDlg,
  245.             PIRB_MINIMIZED,             /* Program style: Minimized radiobutton */
  246.             BM_SETCHECK,                /* Set it to pressed */
  247.             MPFROMSHORT(TRUE),
  248.             (MPARAM)NULL);
  249.     if(SessionData.PgmControl & SSF_CONTROL_INVISIBLE)
  250.         WinSendDlgItemMsg(
  251.             hwndDlg,
  252.             PIRB_INVISIBLE,             /* Program style: Invisible checkbox */
  253.             BM_SETCHECK,                /* Set it to pressed */
  254.             MPFROMSHORT(TRUE),
  255.             (MPARAM)NULL);
  256.     if(SessionData.PgmControl & SSF_CONTROL_NOAUTOCLOSE)
  257.         WinSendDlgItemMsg(
  258.             hwndDlg,
  259.             PIRB_NOAUTOCLOSE,           /* Program style: NoAutoClose checkbox */
  260.             BM_SETCHECK,                /* Set it to pressed */
  261.             MPFROMSHORT(TRUE),
  262.             (MPARAM)NULL);
  263.     if(SessionData.FgBg & SSF_FGBG_BACK)
  264.         WinSendDlgItemMsg(
  265.             hwndDlg,
  266.             PIRB_BACKGROUND,            /* Program style: Background checkbox */
  267.             BM_SETCHECK,                /* Set it to pressed */
  268.             MPFROMSHORT(TRUE),
  269.             (MPARAM)NULL);
  270. /*                                                                                      *\
  271.  * Now we preselect the radiobutton in the Program priority group to the state          *
  272.  * indicated by the SessionData structure.                                              *
  273. \*                                                                                      */
  274.     switch(SessionData.PriorityClass)
  275.     {
  276.     case PRTYC_NOCHANGE:
  277.         WinSendDlgItemMsg(              /* Send message to Priority NoChange radiobutton */
  278.             hwndDlg,                    /* Handle of dialog window */
  279.             PIRB_NOCHANGE,              /* Program priority: NoChange radiobutton */
  280.             BM_SETCHECK,                /* Set it to pressed */
  281.             MPFROMSHORT(TRUE),
  282.             (MPARAM)NULL);
  283.         break;
  284.     case PRTYC_IDLETIME:
  285.         WinSendDlgItemMsg(
  286.             hwndDlg,
  287.             PIRB_IDLETIME,              /* Program priority: IdleTime radiobutton */
  288.             BM_SETCHECK,                /* Set it to pressed */
  289.             MPFROMSHORT(TRUE),
  290.             (MPARAM)NULL);
  291.         break;
  292.     case PRTYC_REGULAR:
  293.         WinSendDlgItemMsg(
  294.             hwndDlg,
  295.             PIRB_REGULAR,               /* Program priority: Regular radiobutton */
  296.             BM_SETCHECK,                /* Set it to pressed */
  297.             MPFROMSHORT(TRUE),
  298.             (MPARAM)NULL);
  299.         break;
  300.     case PRTYC_TIMECRITICAL:
  301.         WinSendDlgItemMsg(
  302.             hwndDlg,
  303.             PIRB_TIMECRITICAL,          /* Program priority: TimeCritical radiobutton */
  304.             BM_SETCHECK,                /* Set it to pressed */
  305.             MPFROMSHORT(TRUE),
  306.             (MPARAM)NULL);
  307.         break;
  308.     case PRTYC_FOREGROUNDSERVER:
  309.         WinSendDlgItemMsg(
  310.             hwndDlg,
  311.             PIRB_FOREGROUNDSERVER,      /* Program priority: ForegroundServer radiobutton */
  312.             BM_SETCHECK,                /* Set it to pressed */
  313.             MPFROMSHORT(TRUE),
  314.             (MPARAM)NULL);
  315.     }
  316. /*                                                                                      *\
  317.  * Now we preselect the listbox in the Program priority group to the state indicated by *
  318.  * the SessionData structure.                                                           *
  319. \*                                                                                      */
  320.     {
  321.     UCHAR       Buffer[4];
  322.     int         LoopCount;
  323.  
  324.     for(LoopCount=PRTYD_MAXIMUM; LoopCount>=PRTYD_MINIMUM; LoopCount--)
  325.         {
  326.         sprintf(Buffer,"%+2d",LoopCount);
  327.         WinInsertLboxItem(              /* Insert an item to listbos */
  328.                                         /* List box handle */
  329.             WinWindowFromID(hwndDlg, PILB_DELTAPRIORITY),
  330.             LIT_END,                    /* Insert at end */
  331.             Buffer);                    /* Text to be inserted */
  332.         }
  333.     WinSendDlgItemMsg(                  /* Send message to Delta Priority listbox */
  334.         hwndDlg,                        /* Handle of dialog window */
  335.         PILB_DELTAPRIORITY,
  336.         LM_SELECTITEM,                  /* Set selection of an item */
  337.                                         /* Select value from SessionData */
  338.         MPFROMSHORT(PRTYD_MAXIMUM-SessionData.PriorityDelta),
  339.         MPFROMSHORT(TRUE));
  340.     WinSendDlgItemMsg(                  /* Send message to Delta Priority listbox */
  341.         hwndDlg,                        /* Handle of dialog window */
  342.         PILB_DELTAPRIORITY,
  343.         LM_SETTOPINDEX,                 /* Set default selection to top of the list box */
  344.         MPFROMSHORT(PRTYD_MAXIMUM-SessionData.PriorityDelta),
  345.         (MPARAM)NULL);
  346.     }
  347. /*                                                                                      *\
  348.  * The 4 entryfields for the Size&Position are a bit more complicated to handle.        *
  349.  * First we set the entryfields to a size of 4 and the default values are read from the *
  350.  * SessionData structure. Only if Size&Position is selected, this 4 entryfields are not *
  351.  * readonly.                                                                            *
  352. \*                                                                                      */
  353.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  354.         hwndDlg,                        /* Handle of dialog window */
  355.         PIEF_X,                         /* Program size: X entryfield */
  356.         EM_SETTEXTLIMIT,                /* Set text limit to 4 */
  357.         MPFROMSHORT(4),
  358.         (MPARAM)NULL);                  /* No additional parameter */
  359.     WinSetDlgItemText(                  /* Set a text string in a dialog item */
  360.         hwndDlg,
  361.         PIEF_X,
  362.         (UCHAR *)_itoa(SessionData.InitXPos, Buffer, 10));
  363.     WinSendDlgItemMsg(
  364.         hwndDlg,
  365.         PIEF_Y,                         /* Program size: Y entryfield */
  366.         EM_SETTEXTLIMIT,                /* Set text limit to 4 */
  367.         MPFROMSHORT(4),
  368.         (MPARAM)NULL);                  /* No additional parameter */
  369.     WinSetDlgItemText(                  /* Set a text string in a dialog item */
  370.         hwndDlg,
  371.         PIEF_Y,
  372.         (UCHAR *)_itoa(SessionData.InitYPos, Buffer, 10));
  373.     WinSendDlgItemMsg(
  374.         hwndDlg,
  375.         PIEF_XSIZE,                     /* Program Size: Size X entryfield */
  376.         EM_SETTEXTLIMIT,                /* Set text limit to 4 */
  377.         MPFROMSHORT(4),
  378.         (MPARAM)NULL);                  /* No additional parameter */
  379.     WinSetDlgItemText(                  /* Set a text string in a dialog item */
  380.         hwndDlg,
  381.         PIEF_XSIZE,
  382.         (UCHAR *)_itoa(SessionData.InitXSize, Buffer, 10));
  383.     WinSendDlgItemMsg(
  384.         hwndDlg,
  385.         PIEF_YSIZE,                     /* Program size: Size Y entryfield */
  386.         EM_SETTEXTLIMIT,                /* Set text limit to 4 */
  387.         MPFROMSHORT(4),
  388.         (MPARAM)NULL);                  /* No additional parameter */
  389.     WinSetDlgItemText(                  /* Set a text string in a dialog item */
  390.         hwndDlg,
  391.         PIEF_YSIZE,
  392.         (UCHAR *)_itoa(SessionData.InitYSize, Buffer, 10));
  393.     if(!(SessionData.PgmControl & SSF_CONTROL_SETPOS))
  394.         {
  395.         WinSendDlgItemMsg(              /* Send message to X entryfield */
  396.             hwndDlg,
  397.             PIEF_X,                     /* Program size: X entryfield */
  398.             EM_SETREADONLY,             /* Set to enable readonly */
  399.             MPFROMSHORT(TRUE),
  400.             (MPARAM)NULL);
  401.         WinSendDlgItemMsg(              /* Send message to Y entryfield */
  402.             hwndDlg,
  403.             PIEF_Y,                     /* Program size: Y entryfield */
  404.             EM_SETREADONLY,             /* Set to enable readonly */
  405.             MPFROMSHORT(TRUE),
  406.             (MPARAM)NULL);
  407.         WinSendDlgItemMsg(              /* Send message to Size X entryfield */
  408.             hwndDlg,
  409.             PIEF_XSIZE,                 /* Program size: Size X entryfield */
  410.             EM_SETREADONLY,             /* Set to enable readonly */
  411.             MPFROMSHORT(TRUE),
  412.         (MPARAM)NULL);
  413.         WinSendDlgItemMsg(              /* Send message to Size Y entryfield */
  414.             hwndDlg,
  415.             PIEF_YSIZE,                 /* Program size: Size Y entryfield */
  416.             EM_SETREADONLY,             /* Set to enable readonly */
  417.             MPFROMSHORT(TRUE),
  418.             (MPARAM)NULL);
  419.         }
  420.     else
  421.         WinSendDlgItemMsg(
  422.             hwndDlg,
  423.             PIRB_SIZEPOSITION,          /* Program style: Size&Position checkbox */
  424.             BM_SETCHECK,                /* Set it to pressed */
  425.             MPFROMSHORT(TRUE),
  426.             (MPARAM)NULL);
  427.     break;
  428.     }
  429.  
  430. case WM_HELP:                           /* Help pressed */
  431.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  432.         hwndHelp,                       /* Help window */
  433.         HM_DISPLAY_HELP,                /* Display a help panel */
  434.                                         /* Panel ID in ressource file */
  435.         MPFROMSHORT(PIID_PROGRAMDIALOG),
  436.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  437.     break;
  438.  
  439. case WM_CONTROL:                        /* Test for autoradio button pressed */
  440.  
  441. /*                                                                                      *\
  442.  * The Size & Position radiobutton must be checked every time it is selected, because   *
  443.  * only if it is selected, the user may have write access to X, Y, Size X and Size Y    *
  444.  * entryfields, otherwise they are read only. The DOS Setting MLE is only visible if a  *
  445.  * DOS window or fullscreen application type is selected.                               *
  446. \*                                                                                      */
  447.     if(SHORT2FROMMP(mp1)==BN_CLICKED)   /* Was autoradio button clicked */
  448.         switch(SHORT1FROMMP(mp1))
  449.         {
  450.         case PIRB_SIZEPOSITION:         /* Program type: User defined size & position */
  451.             if((BOOL)WinSendDlgItemMsg( /* Send message to Size & Position radiobutton */
  452.                 hwndDlg,                /* Handle of dialog window */
  453.                 PIRB_SIZEPOSITION,      /* Program size: Size & Position radiobutton */
  454.                 BM_QUERYCHECK,          /* Query the state */
  455.                 (MPARAM)NULL,
  456.                 (MPARAM)NULL)==TRUE)
  457.             {
  458.                 SessionData.PgmControl|=SSF_CONTROL_SETPOS;
  459.                 WinSendDlgItemMsg(      /* Send message to X entryfield */
  460.                     hwndDlg,            /* Handle of dialog window */
  461.                     PIEF_X,             /* Program size: X entryfield */
  462.                     EM_SETREADONLY,     /* Set to disable readonly */
  463.                     MPFROMSHORT(FALSE),
  464.                     (MPARAM)NULL);
  465.                 WinSendDlgItemMsg(      /* Send message to Y entryfield */
  466.                     hwndDlg,            /* Handle of dialog window */
  467.                     PIEF_Y,             /* Program size: Y entryfield */
  468.                     EM_SETREADONLY,     /* Set to disable readonly */
  469.                     MPFROMSHORT(FALSE),
  470.                     (MPARAM)NULL);
  471.                 WinSendDlgItemMsg(      /* Send message to Size X entryfield */
  472.                     hwndDlg,            /* Handle of dialog window */
  473.                     PIEF_XSIZE,         /* Program size: Size X entryfield */
  474.                     EM_SETREADONLY,     /* Set to disable readonly */
  475.                     MPFROMSHORT(FALSE),
  476.                     (MPARAM)NULL);
  477.                 WinSendDlgItemMsg(      /* Send message to Size Y entryfield */
  478.                     hwndDlg,            /* Handle of dialog window */
  479.                     PIEF_YSIZE,         /* Program size: Size Y entryfield */
  480.                     EM_SETREADONLY,     /* Set to disable readonly */
  481.                     MPFROMSHORT(FALSE),
  482.                     (MPARAM)NULL);
  483.             }
  484.             else
  485.             {
  486.                 WinSendDlgItemMsg(      /* Send message to X entryfield */
  487.                     hwndDlg,            /* Handle of dialog window */
  488.                     PIEF_X,             /* Program size: X entryfield */
  489.                     EM_SETREADONLY,     /* Set to enable readonly */
  490.                     MPFROMSHORT(TRUE),
  491.                     (MPARAM)NULL);
  492.                 WinSendDlgItemMsg(      /* Send message to Y entryfield */
  493.                     hwndDlg,            /* Handle of dialog window */
  494.                     PIEF_Y,             /* Program size: Y entryfield */
  495.                     EM_SETREADONLY,     /* Set to enable readonly */
  496.                     MPFROMSHORT(TRUE),
  497.                     (MPARAM)NULL);
  498.                 WinSendDlgItemMsg(      /* Send message to Size X entryfield */
  499.                     hwndDlg,            /* Handle of dialog window */
  500.                     PIEF_XSIZE,         /* Program size: Size X entryfield */
  501.                     EM_SETREADONLY,     /* Set to enable readonly */
  502.                     MPFROMSHORT(TRUE),
  503.                     (MPARAM)NULL);
  504.                 WinSendDlgItemMsg(      /* Send message to Size Y entryfield */
  505.                     hwndDlg,            /* Handle of dialog window */
  506.                     PIEF_YSIZE,         /* Program size: Size Y entryfield */
  507.                     EM_SETREADONLY,     /* Set to enable readonly */
  508.                     MPFROMSHORT(TRUE),
  509.                     (MPARAM)NULL);
  510.             }
  511.             break;
  512.  
  513.         case PIRB_DOSFULLSCREEN:
  514.         case PIRB_DOSWINDOW:
  515.             WinSetWindowPos(            /* Show DOS Settings window */
  516.                 WinWindowFromID(hwndDlg, PIEF_DOSSETTINGS), 0, 0, 0, 0, 0,SWP_SHOW);
  517.             break;
  518.  
  519.         case PIRB_SHELL:
  520.         case PIRB_OS2FULLSCREEN:
  521.         case PIRB_OS2WINDOW:
  522.         case PIRB_PM:
  523.             WinSetWindowPos(            /* Hide DOS Settings window until the application
  524.                                            type is DOS Window or DOS Fullscreen */
  525.                 WinWindowFromID(hwndDlg, PIEF_DOSSETTINGS), 0, 0, 0, 0, 0,SWP_HIDE);
  526.             break;
  527.         }
  528.     break;
  529.  
  530. case WM_COMMAND:                        /* Button pressed */
  531.     switch(SHORT1FROMMP(mp1))
  532.     {
  533.     case PIPB_WINFILEDLG:               /* Locate file by standard file dialog */
  534. /*                                                                                      *\
  535.  * The user selected the File Find pushbutton to get the standard file dialog to find   *
  536.  * the program he wants to install.                                                     *
  537. \*                                                                                      */
  538.         {
  539.         FILEDLG fdFileDlg;              /* Standard file dialog control */
  540.         HWND    hwndFileDlg;            /* Handle of standard file dialog */
  541.  
  542.                                         /* Clear out structure */
  543.         memset(&fdFileDlg, 0, sizeof(FILEDLG));
  544.                                         /* Structure size */
  545.         fdFileDlg.cbSize=sizeof(FILEDLG);
  546.                                         /* FDS_* flags */
  547.         fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG | FDS_PRELOAD_VOLINFO;
  548.                                         /* Dialog title string */
  549.         fdFileDlg.pszTitle="PC/2 File Search";
  550.                                         /* Initial path, filename or file filter */
  551.         strcpy(fdFileDlg.szFullFile, "C:\\*");
  552.                                         /* Open the standard file dialog ...*/
  553.         hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwndDlg, &fdFileDlg);
  554.         if(hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
  555.             {                           /* Load the values of the standard file dialog to
  556.                                            the corresponding entryfield in the Program
  557.                                            installation dialog */
  558.             UCHAR       *pucTemp;
  559.  
  560.             WinSetDlgItemText(          /* Get full qualified path */
  561.                 hwndDlg,
  562.                 PIEF_PATHFILENAME,
  563.                 fdFileDlg.szFullFile);
  564.                                         /* Get filename */
  565.             pucTemp=fdFileDlg.szFullFile+strlen(fdFileDlg.szFullFile);
  566.             for( ; (*pucTemp!='\\') && (pucTemp>=fdFileDlg.szFullFile); pucTemp--);
  567.             WinSetDlgItemText(          /* Get filename */
  568.                 hwndDlg,
  569.                 PIEF_PROGRAMTITLE,
  570.                 (pucTemp+1));
  571.             *pucTemp='\0';              /* Get path as working directory */
  572.             WinSetDlgItemText(          /* Get working directory */
  573.                 hwndDlg,
  574.                 PIEF_DIRECTORY,
  575.                 fdFileDlg.szFullFile);
  576.             }
  577.         }
  578.                                         /* Prevent to dismiss program installation dialog
  579.                                            by exiting switch via a break statement */
  580.         return((MRESULT)FALSE);
  581.  
  582.     case DID_OK:                        /* Enter key pressed */
  583. /*                                                                                      *\
  584.  * Query the Program Title, Filename, Parameters and DOS Settings and copy them to the  *
  585.  * corresponding entries in the StartSession structure.                                 *
  586. \*                                                                                      */
  587.         WinQueryWindowText(             /* Query data entered in Program title entry */
  588.             WinWindowFromID(hwndDlg, PIEF_PROGRAMTITLE),
  589.                                         /* into SessionData structure */
  590.             sizeof(SessionData.PgmTitle),
  591.             SessionData.PgmTitle);
  592.         WinQueryWindowText(             /* Query data entered in Path and Filename entry */
  593.             WinWindowFromID(hwndDlg, PIEF_PATHFILENAME),
  594.                                         /* into SessionData structure */
  595.             sizeof(SessionData.PgmName),
  596.             SessionData.PgmName);
  597.         WinQueryWindowText(             /* Query data entered in working Directory entry */
  598.             WinWindowFromID(hwndDlg, PIEF_DIRECTORY),
  599.                                         /* into SessionData structure */
  600.             sizeof(SessionData.PgmDirectory),
  601.             SessionData.PgmDirectory);
  602.         WinQueryWindowText(         /* Query data entered in Parameters entry */
  603.             WinWindowFromID(hwndDlg, PIEF_PARAMETERS),
  604.                                         /* into SessionData structure */
  605.             sizeof(SessionData.PgmInputs),
  606.             SessionData.PgmInputs);
  607.         WinQueryWindowText(             /* Query data entered in DOS Settings MLE */
  608.             WinWindowFromID(hwndDlg, PIEF_DOSSETTINGS),
  609.                                         /* into SessionData structure */
  610.             sizeof(SessionData.PgmDosSettings),
  611.             SessionData.PgmDosSettings);
  612. /*                                                                                      *\
  613.  * Query the Program Type radiobuttons and set the corresponding bit into the           *
  614.  * StartSession structure. No change or the default selection are preselected during    *
  615.  * WM_INITDLG. It must be one of them set, so we don't need else parts for if-else.     *
  616. \*                                                                                      */
  617.                                         /* Program type: WPS default */
  618.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_SHELL))
  619.             SessionData.SessionType=SSF_TYPE_DEFAULT;
  620.                                         /* Program type: OS/2 Fullscreen */
  621.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_OS2FULLSCREEN))
  622.             SessionData.SessionType=SSF_TYPE_FULLSCREEN;
  623.                                         /* Program type: OS/2 Window */
  624.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_OS2WINDOW))
  625.             SessionData.SessionType=SSF_TYPE_WINDOWABLEVIO;
  626.                                         /* Program type: PM */
  627.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_PM))
  628.             SessionData.SessionType=SSF_TYPE_PM;
  629.                                         /* Program type: DOS Fullscreen */
  630.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_DOSFULLSCREEN))
  631.             SessionData.SessionType=SSF_TYPE_VDM;
  632.                                         /* Program type: DOS Window */
  633.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_DOSWINDOW))
  634.             SessionData.SessionType=SSF_TYPE_WINDOWEDVDM;
  635. /*                                                                                      *\
  636.  * Query Program Style radiobuttons and set the corresponding bits in the StartSession  *
  637.  * structure. No change or the default selection are preselected during WM_INITDLG.     *
  638. \*                                                                                      */
  639.                                         /* Program style: Maximized */
  640.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_MAXIMIZED))
  641.             SessionData.PgmControl|=SSF_CONTROL_MAXIMIZE;
  642.         else
  643.             SessionData.PgmControl&=(~SSF_CONTROL_MAXIMIZE);
  644.                                         /* Program style: Minimized */
  645.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_MINIMIZED))
  646.             SessionData.PgmControl|=SSF_CONTROL_MINIMIZE;
  647.         else
  648.             SessionData.PgmControl&=(~SSF_CONTROL_MINIMIZE);
  649.                                         /* Program style: Invisible */
  650.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_INVISIBLE))
  651.             SessionData.PgmControl|=SSF_CONTROL_INVISIBLE;
  652.         else
  653.             SessionData.PgmControl&=(~SSF_CONTROL_INVISIBLE);
  654.                                         /* Program style: No autoclose */
  655.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_NOAUTOCLOSE))
  656.             SessionData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
  657.         else
  658.             SessionData.PgmControl&=(~SSF_CONTROL_NOAUTOCLOSE);
  659.                                         /* Program style: Background */
  660.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_BACKGROUND))
  661.             SessionData.FgBg|=SSF_FGBG_BACK;
  662.         else
  663.             SessionData.FgBg&=(~SSF_FGBG_BACK);
  664. /*                                                                                      *\
  665.  * Query Size & Position radiobutton, set the corresponding bit, and load the values    *
  666.  * from the corresponding entryfields for the StartSession structure.                   *
  667. \*                                                                                      */
  668.         {
  669.         UCHAR   Buffer[4];
  670.  
  671.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_SIZEPOSITION))
  672.             SessionData.PgmControl|=SSF_CONTROL_SETPOS;
  673.         else
  674.             SessionData.PgmControl&=(~SSF_CONTROL_SETPOS);
  675.         WinQueryWindowText(             /* Query data entered in Parameters entry */
  676.             WinWindowFromID(hwndDlg, PIEF_X),
  677.                                         /* into temporary structure */
  678.             sizeof(Buffer),
  679.             Buffer);
  680.         SessionData.InitXPos=(USHORT)atol(Buffer);
  681.         WinQueryWindowText(
  682.             WinWindowFromID(hwndDlg, PIEF_Y),
  683.             sizeof(Buffer),
  684.             Buffer);
  685.         SessionData.InitYPos=(USHORT)atol(Buffer);
  686.         WinQueryWindowText(
  687.             WinWindowFromID(hwndDlg, PIEF_XSIZE),
  688.             sizeof(Buffer),
  689.             Buffer);
  690.         SessionData.InitXSize=(USHORT)atol(Buffer);
  691.         WinQueryWindowText(
  692.             WinWindowFromID(hwndDlg, PIEF_YSIZE),
  693.             sizeof(Buffer),
  694.             Buffer);
  695.         SessionData.InitYSize=(USHORT)atol(Buffer);
  696.         }
  697. /*                                                                                      *\
  698.  * Query Program Priority radiobuttons and set the corresponding bits in the            *
  699.  * StartSession structure. The default priority is No-Change. The listbox is also       *
  700.  * queried and the Delta Priority is also set in the StartSession structure. It must be *
  701.  * one of the radiobuttons, so else part of if-else is not required.                    *
  702. \*                                                                                      */
  703.                                         /* Program Priority: No-Change */
  704.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_NOCHANGE))
  705.             SessionData.PriorityClass=PRTYC_NOCHANGE;
  706.                                         /* Program Priority: Idle-time */
  707.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_IDLETIME))
  708.             SessionData.PriorityClass=PRTYC_IDLETIME;
  709.                                         /* Program Priority: Regular */
  710.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_REGULAR))
  711.             SessionData.PriorityClass=PRTYC_REGULAR;
  712.                                         /* Program Priority: Time-critical */
  713.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_TIMECRITICAL))
  714.             SessionData.PriorityClass=PRTYC_TIMECRITICAL;
  715.                                         /* Program Priority: Server */
  716.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_FOREGROUNDSERVER))
  717.             SessionData.PriorityClass=PRTYC_FOREGROUNDSERVER;
  718.                                         /* Query index of selected item on correct it */
  719.         SessionData.PriorityDelta=(
  720.             WinQueryLboxSelectedItem(
  721.                 WinWindowFromID(hwndDlg, PILB_DELTAPRIORITY))
  722.             -PRTYD_MAXIMUM)*(-1);
  723.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  724.         break;
  725.  
  726.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  727.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  728.         break;
  729.  
  730.     default:
  731.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  732.     }
  733.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  734.     break;
  735.  
  736. default:                                /* Default window procedure must be called */
  737.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  738. }
  739. return((MRESULT)FALSE);                 /* We have handled the message */
  740. }
  741.  
  742. /*--------------------------------------------------------------------------------------*\
  743.  * This dialog procedure handles the PC/2 - Menu Installation dialog.                   *
  744.  * Req:                                                                                 *
  745.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  746.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  747.  *                      is used to start the session and set its priority.              *
  748. \*--------------------------------------------------------------------------------------*/
  749. MRESULT  EXPENTRY MI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  750. {
  751. switch(msg)
  752. {
  753. case WM_INITDLG:
  754.     {
  755.     SWP         swp;
  756.  
  757.     WinQueryWindowPos(                  /* Query position of dialog window */
  758.         hwndDlg,                        /* Handle of dialog window */
  759.         &swp);                          /* Fill with position */
  760.     WinSetWindowPos(                    /* Set dialog window position */
  761.         hwndDlg,                        /* Handle of dialog window */
  762.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  763.         (swpScreen.cx-swp.cx)/2,
  764.         (swpScreen.cy-swp.cy)/2,
  765.         0,
  766.         0,
  767.         SWP_MOVE);
  768. /*                                                                                      *\
  769.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  770.  * default number of 63.                                                                *
  771. \*                                                                                      */
  772.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  773.         hwndDlg,                        /* Handle of dialog window */
  774.         MIEF_MENUTITLE,                 /* Program submenu title entryfield */
  775.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  776.         MPFROMSHORT(EF_SIZE60),
  777.         (MPARAM)NULL);                  /* No additional parameter */
  778.     WinSetDlgItemText(                  /* Set text of title entryfield */
  779.         hwndDlg,
  780.         MIEF_MENUTITLE,
  781.         SessionData.PgmTitle);
  782.     break;
  783.     }
  784.  
  785. case WM_HELP:                           /* Help pressed */
  786.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  787.         hwndHelp,                       /* Help window */
  788.         HM_DISPLAY_HELP,                /* Display a help panel */
  789.         MPFROMSHORT(MIID_MENUDIALOG),   /* Panel ID in ressource file */
  790.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  791.     break;
  792.  
  793. case WM_COMMAND:                        /* Button pressed */
  794.     switch(SHORT1FROMMP(mp1))
  795.     {
  796.     case DID_OK:                        /* Enter key pressed */
  797. /*                                                                                      *\
  798.  * Query the Submenu Title and copy it to the corresponding entry in the StartSession   *
  799.  * structure.                                                                           *
  800. \*                                                                                      */
  801.         WinQueryWindowText(             /* Query data entered in Submenu title entry */
  802.             WinWindowFromID(hwndDlg, MIEF_MENUTITLE),
  803.                                         /* into SessionData structure */
  804.             sizeof(SessionData.PgmTitle),
  805.             SessionData.PgmTitle);
  806.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  807.         break;
  808.  
  809.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  810.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  811.         break;
  812.  
  813.     default:
  814.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  815.     }
  816.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  817.     break;
  818.  
  819. default:                                /* Default window procedure must be called */
  820.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  821. }
  822. return((MRESULT)FALSE);                 /* We have handled the message */
  823. }
  824.  
  825.  
  826.