home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / utils / pc2 / source / dialog.c next >
Encoding:
C/C++ Source or Header  |  1993-05-31  |  71.4 KB  |  1,295 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.50 05,1993 $ (LBL)";
  12.  
  13. #define         _FILE_  "PC/2 - Dialog.c V1.50"
  14.  
  15. #include        "PC2.h"                 /* User include files */
  16. #include        "Error.h"
  17.  
  18. PFNWP           PI_ClassDialogProcedure;
  19.  
  20. /*--------------------------------------------------------------------------------------*\
  21.  * This dialog procedure handles the PC/2 - About dialog.                               *
  22.  * Req: none                                                                            *
  23. \*--------------------------------------------------------------------------------------*/
  24. MRESULT  EXPENTRY AD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  25. {
  26. switch(msg)
  27. {
  28. case WM_INITDLG:
  29.     {
  30.     SWP         swp;
  31.  
  32.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  33.     WinQueryWindowPos(                  /* Query position of dialog window */
  34.         hwndDlg,                        /* Handle of dialog window */
  35.         &swp);                          /* Fill with position */
  36.     WinSetWindowPos(                    /* Set dialog window position */
  37.         hwndDlg,                        /* Handle of dialog window */
  38.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  39.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  40.     break;
  41.     }
  42.  
  43. case WM_HELP:                           /* Help pressed */
  44.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  45.         hwndHelp,                       /* Help window */
  46.         HM_DISPLAY_HELP,                /* Display a help panel */
  47.         MPFROMSHORT(ID_ABOUTDIALOG),    /* Panel ID in ressource file */
  48.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  49.     break;
  50.  
  51. case WM_COMMAND:                        /* Button pressed */
  52.     switch(SHORT1FROMMP(mp1))
  53.     {
  54.     case DID_OK:                        /* Enter key pressed */
  55.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  56.         break;
  57.  
  58.     case DID_CANCEL:                    /* Cancel key pressed */
  59.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  60.         break;
  61.  
  62.     default:
  63.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  64.     }
  65.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  66.     break;
  67.  
  68. default:                                /* Default window procedure must be called */
  69.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  70. }
  71. return((MRESULT)FALSE);                 /* We have handled the message */
  72. }
  73.  
  74. /*--------------------------------------------------------------------------------------*\
  75.  * This dialog procedure handles the PC/2 - Desktop configuration dialog.               *
  76.  * Req: none                                                                            *
  77. \*--------------------------------------------------------------------------------------*/
  78. MRESULT  EXPENTRY DD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  79. {
  80. switch(msg)
  81. {
  82. case WM_INITDLG:
  83.     {
  84.     SWP         swp;
  85.                                         /* Child windows that change with the
  86.                                            DDCB_VIRTUALDESKTOP checkbox */
  87.     USHORT      usChild2VirtualDesktopCB[]={DDCB_MOVEDESKTOP, DDCB_CLICK2MOVE,
  88.                                             DDCB_OVERVIEW, DDEF_DESKTOPNAME,
  89.                                             DDLB_SCROLLPERCENTAGE};
  90.     UCHAR       ucBuffer[5];
  91.     ULONG       ulTemp;
  92.  
  93.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  94.     WinQueryWindowPos(                  /* Query position of dialog window */
  95.         hwndDlg,                        /* Handle of dialog window */
  96.         &swp);                          /* Fill with position */
  97.     WinSetWindowPos(                    /* Set dialog window position */
  98.         hwndDlg,                        /* Handle of dialog window */
  99.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  100.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  101. /*                                                                                      *\
  102.  * Check the checkboxes that should be set according to the bitmap currently used in    *
  103.  * PC2.INI. If the virtual Desktop is disabled, then its child checkboxes can't be set, *
  104.  * because unchecking the virtual Desktop automatically unchecks its child checkboxes.  *
  105. \*                                                                                      */
  106.                                         /* Check ckeckbox if sliding focus flag is set */
  107.     if(HookParameters.ulStatusFlag & SLIDINGFOCUS)
  108.         WinSendDlgItemMsg(hwndDlg, DDCB_SLIDINGFOCUS, BM_SETCHECK,
  109.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  110.                                         /* Check checkbox if virtual Desktop flag is set */
  111.     if(HookParameters.ulStatusFlag & VIRTUALDESKTOP)
  112.         WinSendDlgItemMsg(hwndDlg, DDCB_VIRTUALDESKTOP, BM_SETCHECK,
  113.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  114.                                         /* Check checkbox if move Desktop flag is set */
  115.     if(HookParameters.ulStatusFlag & MOVEDESKTOP)
  116.         WinSendDlgItemMsg(hwndDlg, DDCB_MOVEDESKTOP, BM_SETCHECK,
  117.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  118.                                         /* Check checkbox if click to move flag is set */
  119.     if(HookParameters.ulStatusFlag & CLICK2MOVE)
  120.         WinSendDlgItemMsg(hwndDlg, DDCB_CLICK2MOVE, BM_SETCHECK,
  121.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  122.                                         /* Check checkbox if overview window flag is set */
  123.     if(HookParameters.ulStatusFlag & OVERVIEW)
  124.         WinSendDlgItemMsg(hwndDlg, DDCB_OVERVIEW, BM_SETCHECK,
  125.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  126. /*                                                                                      *\
  127.  * Write the Desktop name from PC2.INI to the entryfield.                               *
  128. \*                                                                                      */
  129.                                         /* First set the limit to 19 */
  130.     WinSendDlgItemMsg(hwndDlg, DDEF_DESKTOPNAME, EM_SETTEXTLIMIT,
  131.         MPFROMSHORT(19), (MPARAM)NULL);
  132.                                         /* Insert the string */
  133.     WinSetDlgItemText(hwndDlg, DDEF_DESKTOPNAME, HookParameters.ucDesktopName);
  134. /*                                                                                      *\
  135.  * Add 25, 50, 75 and 100 % to DDLB_SCROLLPERCENTAGE listbox, and scroll the currently  *
  136.  * in PC2.INI selected one to top and select it.                                        *
  137. \*                                                                                      */
  138.                                         /* Insert percentages at the end */
  139.     for(ulTemp=25; ulTemp<=100; ulTemp+=25)
  140.         {
  141.         sprintf(ucBuffer, "%d", ulTemp);
  142.         WinInsertLboxItem(WinWindowFromID(hwndDlg, DDLB_SCROLLPERCENTAGE),
  143.             LIT_END, ucBuffer);
  144.         }
  145.                                         /* Select the one currently selected in PC2.INI
  146.                                            (1-based !!!) */
  147.     WinSendDlgItemMsg(hwndDlg, DDLB_SCROLLPERCENTAGE, LM_SELECTITEM,
  148.         MPFROMSHORT(HookParameters.ulScrollPercentage/25-1), MPFROMSHORT(TRUE));
  149.                                         /* Scroll the selected one to top */
  150.     WinSendDlgItemMsg(hwndDlg, DDLB_SCROLLPERCENTAGE, LM_SETTOPINDEX,
  151.         MPFROMSHORT(HookParameters.ulScrollPercentage/25-1), (MPARAM)NULL);
  152. /*                                                                                      *\
  153.  * Disable the child windows of the virtual Desktop, if this checkbox isn't checked.    *
  154. \*                                                                                      */
  155.     if(!(HookParameters.ulStatusFlag & VIRTUALDESKTOP))
  156.         DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  157.             sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  158.     break;
  159.     }
  160.  
  161. case WM_HELP:                           /* Help pressed */
  162.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  163.         MPFROMSHORT(ID_DESKTOPDIALOG), HM_RESOURCEID);
  164.     break;
  165.  
  166. case WM_CONTROL:                        /* Test for checkbuttons buttons pressed */
  167. /*                                                                                      *\
  168.  * Only if the DDCB_VIRTUALDESKTOP checkbox is pressed, its child windows are to be     *
  169.  * enabled. Otherwise the are disabled, but allways visible.                            *
  170. \*                                                                                      */
  171.     {                                   /* Child windows that change with the
  172.                                            DDCB_VIRTUALDESKTOP checkbox */
  173.     USHORT      usChild2VirtualDesktopCB[]={DDCB_MOVEDESKTOP, DDCB_CLICK2MOVE,
  174.                                             DDCB_OVERVIEW, DDEF_DESKTOPNAME,
  175.                                             DDLB_SCROLLPERCENTAGE};
  176.  
  177.     if(SHORT2FROMMP(mp1)==BN_CLICKED)   /* Was autoradio button clicked ? */
  178.         switch(SHORT1FROMMP(mp1))
  179.         {
  180.         case DDCB_VIRTUALDESKTOP:       /* Virtal Desktop enable/disable checkbox */
  181.             if((BOOL)WinSendDlgItemMsg(hwndDlg, DDCB_VIRTUALDESKTOP, BM_QUERYCHECK,
  182.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  183.                                         /* Enable and show VirtualDesktopCB child windows */
  184.                 DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  185.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE);
  186.             else
  187.                 {
  188.                                         /* If move Desktop checkbox is checked, uncheck it */
  189.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_MOVEDESKTOP))
  190.                     WinSendDlgItemMsg(hwndDlg, DDCB_MOVEDESKTOP, BM_SETCHECK,
  191.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  192.                                         /* If click to move checkbox is checked, uncheck it */
  193.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_CLICK2MOVE))
  194.                     WinSendDlgItemMsg(hwndDlg, DDCB_CLICK2MOVE, BM_SETCHECK,
  195.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  196.                                         /* If overview checkbox is checked, uncheck it */
  197.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_OVERVIEW))
  198.                     WinSendDlgItemMsg(hwndDlg, DDCB_OVERVIEW, BM_SETCHECK,
  199.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  200.                 DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  201.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  202.                 }
  203.             break;
  204.         }
  205.     }
  206.     break;
  207.  
  208. case WM_COMMAND:                        /* Button pressed */
  209.     switch(SHORT1FROMMP(mp1))
  210.     {
  211.     case DID_OK:                        /* Enter key pressed */
  212.                                         /* Now query PC2HOOK.DLL parameters before we update */
  213.         pPC2DLL_QueryParameters(&HookParameters);
  214.                                         /* Query checkboxes' state and set according flag */
  215.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_SLIDINGFOCUS))
  216.             HookParameters.ulStatusFlag|=SLIDINGFOCUS;
  217.         else HookParameters.ulStatusFlag&=~SLIDINGFOCUS;
  218.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_VIRTUALDESKTOP))
  219.             HookParameters.ulStatusFlag|=VIRTUALDESKTOP;
  220.         else HookParameters.ulStatusFlag&=~VIRTUALDESKTOP;
  221.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_MOVEDESKTOP))
  222.             HookParameters.ulStatusFlag|=MOVEDESKTOP;
  223.         else HookParameters.ulStatusFlag&=~MOVEDESKTOP;
  224.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_CLICK2MOVE))
  225.             HookParameters.ulStatusFlag|=CLICK2MOVE;
  226.         else HookParameters.ulStatusFlag&=~CLICK2MOVE;
  227.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_OVERVIEW))
  228.             HookParameters.ulStatusFlag|=OVERVIEW;
  229.         else HookParameters.ulStatusFlag&=~OVERVIEW;
  230.                                         /* Query desktop name */
  231.         WinQueryWindowText(WinWindowFromID(hwndDlg, DDEF_DESKTOPNAME),
  232.             sizeof(HookParameters.ucDesktopName), HookParameters.ucDesktopName);
  233.                                         /* Query scroll percentage listbox (0-based !!!) */
  234.         HookParameters.ulScrollPercentage=25*(1+
  235.             WinQueryLboxSelectedItem(WinWindowFromID(hwndDlg, DDLB_SCROLLPERCENTAGE)));
  236.                                         /* Reinitialize scroll percentage */
  237.         HookParameters.SlidingXFactor=(HookParameters.ulScrollPercentage*
  238.             HookParameters.DesktopSize.x)/100;
  239.         HookParameters.SlidingYFactor=(HookParameters.ulScrollPercentage*
  240.             HookParameters.DesktopSize.y)/100;
  241.                                         /* Show or hide overview window according to
  242.                                            the user selected flag */
  243.         if(HookParameters.ulStatusFlag & OVERVIEW)
  244.             WinSetWindowPos(hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_SHOW | SWP_DEACTIVATE);
  245.         else
  246.             WinSetWindowPos(hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE | SWP_DEACTIVATE);
  247.                                         /* Now update changes to PC2HOOK.DLL */
  248.         pPC2DLL_SetParameters(&HookParameters);
  249.                                         /* Write changes to PC2.INI */
  250.         INIAccess(pucFilenameINI, FALSE);
  251.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  252.         break;
  253.  
  254.     case DID_CANCEL:                    /* Cancel key pressed */
  255.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  256.         break;
  257.  
  258.     default:
  259.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  260.     }
  261.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  262.     break;
  263.  
  264. default:                                /* Default window procedure must be called */
  265.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  266. }
  267. return((MRESULT)FALSE);                 /* We have handled the message */
  268. }
  269.  
  270. /*--------------------------------------------------------------------------------------*\
  271.  * This dialog procedure handles the PC/2 - Program Installation dialog.                *
  272.  * Req:                                                                                 *
  273.  *      StartSession .. a structure of type SESSIONDATA where the information entered   *
  274.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  275.  *                      is used to start the session and set its priority.              *
  276. \*--------------------------------------------------------------------------------------*/
  277. MRESULT  EXPENTRY PI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  278. {
  279. switch(msg)
  280. {
  281. case WM_INITDLG:
  282.     {
  283.     SWP         swp;
  284.  
  285.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  286.     WinQueryWindowPos(                  /* Query position of dialog window */
  287.         hwndDlg,                        /* Handle of dialog window */
  288.         &swp);                          /* Fill with position */
  289.     WinSetWindowPos(                    /* Set dialog window position */
  290.         hwndDlg,                        /* Handle of dialog window */
  291.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  292.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  293. /*                                                                                      *\
  294.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  295.  * default number of 63 and load the data from the SESSIONDATA structure SessionData    *
  296.  * into the entryfields.                                                                *
  297. \*                                                                                      */
  298.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  299.         hwndDlg,                        /* Handle of dialog window */
  300.         PIEF_PROGRAMTITLE,              /* Program title entryfield */
  301.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  302.         MPFROMSHORT(EF_SIZE60),
  303.         (MPARAM)NULL);                  /* No additional parameter */
  304.     WinSetDlgItemText(                  /* Load the default text of the entryfield */
  305.         hwndDlg, PIEF_PROGRAMTITLE, SessionData.PgmTitle);
  306.     WinSendDlgItemMsg(
  307.         hwndDlg,
  308.         PIEF_PATHFILENAME,              /* Path and Filename title entryfield */
  309.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  310.         MPFROMSHORT(EF_SIZE255),
  311.         (MPARAM)NULL);
  312.     WinSetDlgItemText(hwndDlg, PIEF_PATHFILENAME, SessionData.PgmName);
  313.     WinSendDlgItemMsg(
  314.         hwndDlg,
  315.         PIEF_DIRECTORY,                 /* Working directory entryfield */
  316.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  317.         MPFROMSHORT(EF_SIZE255),
  318.         (MPARAM)NULL);
  319.     WinSetDlgItemText(hwndDlg, PIEF_DIRECTORY, SessionData.PgmDirectory);
  320.     WinSendDlgItemMsg(
  321.         hwndDlg,
  322.         PIEF_PARAMETERS,                /* Program Parameters entryfield */
  323.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  324.         MPFROMSHORT(EF_SIZE255),
  325.         (MPARAM)NULL);
  326.     WinSetDlgItemText(hwndDlg, PIEF_PARAMETERS, SessionData.PgmInputs);
  327.                                         /* Insert DOS Settings. If none exist add the
  328.                                            IDLE_* default settings */
  329.     if(strlen(SessionData.PgmDosSettings)!=0)
  330.         WinSendDlgItemMsg(
  331.             hwndDlg,
  332.             PIEF_DOSSETTINGS,           /* Program DOS Settings entryfield */
  333.             MLM_INSERT,                 /* Insert text */
  334.             MPFROMP(SessionData.PgmDosSettings),
  335.             (MPARAM)NULL);
  336.     else
  337.         WinSendDlgItemMsg(
  338.             hwndDlg,
  339.             PIEF_DOSSETTINGS,           /* Program DOS Settings entryfield */
  340.             MLM_INSERT,                 /* Insert text */
  341.             MPFROMP("IDLE_SECONDS=5\nIDLE_SENSITIVITY=100\n"),
  342.             (MPARAM)NULL);
  343. /*                                                                                      *\
  344.  * Now we preselect the radiobutton in the Program type group to the state indicated by *
  345.  * the SessionData structure.                                                           *
  346. \*                                                                                      */
  347.     WinSendMsg(hwndDlg, WM_SETUPPROGRAMTYPE,
  348.         MPFROMSHORT(SessionData.SessionType), (MPARAM)NULL);
  349. /*                                                                                      *\
  350.  * Now we preselect the radiobutton in the Program style group to the state indicated   *
  351.  * by the SessionData structure.                                                        *
  352. \*                                                                                      */
  353.     if(!(SessionData.PgmControl & (SSF_CONTROL_MAXIMIZE | SSF_CONTROL_MINIMIZE)))
  354.         WinSendDlgItemMsg(              /* Send message to Default radiobutton */
  355.             hwndDlg,                    /* Handle of dialog window */
  356.             PIRB_DEFAULTSTYLE,          /* Program style: Default radiobutton */
  357.             BM_SETCHECK,                /* Set it to pressed */
  358.             MPFROMSHORT(TRUE),
  359.             (MPARAM)NULL);
  360.     if(SessionData.PgmControl & SSF_CONTROL_MAXIMIZE)
  361.         WinSendDlgItemMsg(
  362.             hwndDlg,
  363.             PIRB_MAXIMIZED,             /* Program style: Maximized radiobutton */
  364.             BM_SETCHECK,                /* Set it to pressed */
  365.             MPFROMSHORT(TRUE),
  366.             (MPARAM)NULL);
  367.     if(SessionData.PgmControl & SSF_CONTROL_MINIMIZE)
  368.         WinSendDlgItemMsg(
  369.             hwndDlg,
  370.             PIRB_MINIMIZED,             /* Program style: Minimized radiobutton */
  371.             BM_SETCHECK,                /* Set it to pressed */
  372.             MPFROMSHORT(TRUE),
  373.             (MPARAM)NULL);
  374.     if(SessionData.PgmControl & SSF_CONTROL_INVISIBLE)
  375.         WinSendDlgItemMsg(
  376.             hwndDlg,
  377.             PIRB_INVISIBLE,             /* Program style: Invisible checkbox */
  378.             BM_SETCHECK,                /* Set it to pressed */
  379.             MPFROMSHORT(TRUE),
  380.             (MPARAM)NULL);
  381.     if(SessionData.PgmControl & SSF_CONTROL_NOAUTOCLOSE)
  382.         WinSendDlgItemMsg(
  383.             hwndDlg,
  384.             PIRB_NOAUTOCLOSE,           /* Program style: NoAutoClose checkbox */
  385.             BM_SETCHECK,                /* Set it to pressed */
  386.             MPFROMSHORT(TRUE),
  387.             (MPARAM)NULL);
  388.     if(SessionData.FgBg & SSF_FGBG_BACK)
  389.         WinSendDlgItemMsg(
  390.             hwndDlg,
  391.             PIRB_BACKGROUND,            /* Program style: Background checkbox */
  392.             BM_SETCHECK,                /* Set it to pressed */
  393.             MPFROMSHORT(TRUE),
  394.             (MPARAM)NULL);
  395. /*                                                                                      *\
  396.  * Now we preselect the radiobutton in the Program Size & Position group to the state   *
  397.  * indicated by the SessionData structure.                                              *
  398. \*                                                                                      */
  399.     if(SessionData.PgmControl & SSF_CONTROL_SETPOS)
  400.         {                               /* If requested select it for the first time */
  401.         WinSendDlgItemMsg(hwndDlg, PIRB_SIZEPOSITION, BM_SETCHECK,
  402.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  403.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  404.             MPFROMSHORT(TRUE), MPFROMSHORT(TRUE));
  405.         }
  406.     else
  407.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  408.             MPFROMSHORT(FALSE), MPFROMSHORT(TRUE));
  409. /*                                                                                      *\
  410.  * Subclass dialog window procedure to catch drag & drop messages of the dialog window, *
  411.  * which doesn't contain any child windows of it (entryfields, buttons, text fields).   *
  412. \*                                                                                      */
  413.                                         /* Subclass window procedure for drag & drop support
  414.                                            save the old procedure, because the subclassing procedure
  415.                                            must call the subclassed dialog procedure for all
  416.                                            messages it doesn't handle itself, i.e. all but drag & drop */
  417.     PI_ClassDialogProcedure=WinSubclassWindow(hwndDlg, PI_SubclassedDialogProcedure);
  418.     break;
  419.     }
  420.  
  421. /*                                                                                      *\
  422.  * Syntax: WM_SETUPPROGRAMTYPE, (USHORT SessionType), NULL                              *                                           *
  423. \*                                                                                      */
  424. case WM_SETUPPROGRAMTYPE:
  425. /*                                                                                      *\
  426.  * Adjust the Program Type radiobuttons by selecting only the button corresponding to   *
  427.  * the SessionType.                                                                     *
  428. \*                                                                                      */
  429.     {                                   /* Radiobutton IDs sorted */
  430.     USHORT      usSessionTypeRBs[]={PIRB_SHELL, PIRB_OS2FULLSCREEN, PIRB_OS2WINDOW,
  431.                                     PIRB_PM, PIRB_DOSFULLSCREEN, PIRB_DOSWINDOW,
  432.                                     PIRB_WPSOBJECT};
  433.                                         /* Corresponding session type IDs sorted */
  434.     USHORT      usSessionTypeIDs[]={SSF_TYPE_DEFAULT, SSF_TYPE_FULLSCREEN, SSF_TYPE_WINDOWABLEVIO,
  435.                                     SSF_TYPE_PM, SSF_TYPE_VDM, SSF_TYPE_WINDOWEDVDM,
  436.                                     SSF_TYPE_WPSOBJECT};
  437.     USHORT      usSessionType=SHORT1FROMMP(mp1);
  438.     USHORT      usTemp;
  439.                                         /* Loop for all buttons and deselect all but the
  440.                                            one specified in usSessionType */
  441.     for(usTemp=0; usTemp<=(sizeof(usSessionTypeRBs)/sizeof(USHORT)); usTemp++)
  442.         if(usSessionTypeIDs[usTemp]==usSessionType)
  443.             {
  444.             WinSendDlgItemMsg(          /* Send message to one Program Type radiobutton,
  445.                                            this only updates the radiobutton but doesn't
  446.                                            create a WM_CONTROL message */
  447.                 hwndDlg,                /* Handle of dialog window */
  448.                                         /* Program type radiobutton */
  449.                 usSessionTypeRBs[usTemp],
  450.                 BM_SETCHECK,            /* Set it to pressed */
  451.                 MPFROMSHORT(TRUE),
  452.                 (MPARAM)NULL);
  453.                                         /* Simulate the click to update the dialog's child windows */
  454.             WinSendMsg(hwndDlg, WM_CONTROL,
  455.                 MPFROM2SHORT(usSessionTypeRBs[usTemp], BN_CLICKED), (MPARAM)NULL);
  456.             }
  457.                                         /* Hide DOS Settings window until the application
  458.                                            type is DOS Window or DOS Fullscreen */
  459.     if(usSessionType==SSF_TYPE_WPSOBJECT)
  460.                                         /* Only default Style is allowed */
  461.         WinSendDlgItemMsg(hwndDlg, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  462.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  463.     }
  464.     break;
  465.  
  466. /*                                                                                      *\
  467.  * Syntax: WM_SETUPSIZEPOSITION, (BOOL bWriteable), (BOOL bInsert)                      *
  468. \*                                                                                      */
  469. case WM_SETUPSIZEPOSITION:
  470. /*                                                                                      *\
  471.  * The 4 entryfields for the Size&Position are a bit more complicated to handle.        *
  472.  * First we set the entryfields to a size of 4 and the default values are read from the *
  473.  * SessionData structure. Only if Size&Position is selected, this 4 entryfields are not *
  474.  * readonly. Flag bWriteable is true if Size&Position is selected, Flag bInsert is true *
  475.  * if we write the values the first time.                                               *
  476. \*                                                                                      */
  477.     {
  478.     USHORT      usSizePositionEFs[]={PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  479.     BOOL        bWriteable=SHORT1FROMMP(mp1);
  480.     BOOL        bInsert=SHORT1FROMMP(mp2);
  481.     USHORT      usTemp;
  482.     SHORT       *psSizePosition;
  483.     UCHAR       ucBuffer[6];            /* Prefix, 4 numbers, \0 */
  484.  
  485.                                         /* Get first Size & Position value */
  486.     psSizePosition=&SessionData.InitXPos;
  487.                                         /* Loop for all entryfields and enable and insert
  488.                                            values into them */
  489.     for(usTemp=0; usTemp<=(sizeof(usSizePositionEFs)/sizeof(USHORT));
  490.         usTemp++, psSizePosition++)
  491.         {
  492.         if(bWriteable==TRUE)            /* If writeable, enable them */
  493.             WinSendDlgItemMsg(          /* Send message to entryfield */
  494.                 hwndDlg,
  495.                                         /* Program size & position entryfield */
  496.                 usSizePositionEFs[usTemp],
  497.                 EM_SETREADONLY,         /* Set to enable read/write */
  498.                 MPFROMSHORT(FALSE),
  499.                 (MPARAM)NULL);
  500.         else
  501.             WinSendDlgItemMsg(          /* Send message to entryfield */
  502.                 hwndDlg,
  503.                                         /* Program size & position entryfield */
  504.                 usSizePositionEFs[usTemp],
  505.                 EM_SETREADONLY,         /* Set to enable readonly */
  506.                 MPFROMSHORT(TRUE),
  507.                 (MPARAM)NULL);
  508.         if(bInsert==TRUE)               /* If initializing, insert them */
  509.             {
  510.             WinSendDlgItemMsg(          /* Send message to dialog window */
  511.                 hwndDlg,                /* Handle of dialog window */
  512.                                         /* Program size: X entryfield */
  513.                 usSizePositionEFs[usTemp],
  514.                 EM_SETTEXTLIMIT,        /* Set text limit to 5 */
  515.                 MPFROMSHORT(5),
  516.                 (MPARAM)NULL);
  517.             WinSetDlgItemText(          /* Set a text string in a dialog item */
  518.                 hwndDlg,
  519.                 usSizePositionEFs[usTemp],
  520.                 (CHAR *)_itoa(*psSizePosition, ucBuffer, 10));
  521.             }
  522.         }
  523.     }
  524.     break;
  525.  
  526. case WM_HELP:                           /* Help pressed */
  527.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  528.         hwndHelp,                       /* Help window */
  529.         HM_DISPLAY_HELP,                /* Display a help panel */
  530.                                         /* Panel ID in ressource file */
  531.         MPFROMSHORT(PIID_PROGRAMDIALOG),
  532.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  533.     break;
  534.  
  535. case WM_CONTROL:                        /* Test for autoradio buttons pressed */
  536. /*                                                                                      *\
  537.  * The Size & Position radiobutton must be checked every time it is selected, because   *
  538.  * only if it is selected, the user may have write access to X, Y, Size X and Size Y    *
  539.  * entryfields, otherwise they are read only. The DOS Setting MLE is only visible if a  *
  540.  * DOS window or fullscreen application type is selected.                               *
  541. \*                                                                                      */
  542.     {                                   /* Child windows that change with the
  543.                                            PIRB_WPSOBJECT radiobutton */
  544.     USHORT      usChild2WPSObject[]={PIRB_MAXIMIZED, PIRB_MINIMIZED, PIRB_SIZEPOSITION,
  545.                                      PIRB_INVISIBLE, PIRB_NOAUTOCLOSE, PIRB_BACKGROUND,
  546.                                      PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE,};
  547.                                         /* Hide the following for WPS Objects */
  548.     USHORT      usChild2WPSObjectHide[]={PIEF_DIRECTORY, PIEF_PARAMETERS};
  549.                                         /* Child window that change with a DOS radiobutton */
  550.     USHORT      usChild2DOS[]={PIEF_DOSSETTINGS};
  551.  
  552.     if(SHORT2FROMMP(mp1)==BN_CLICKED)   /* Was autoradio button clicked ? */
  553.         switch(SHORT1FROMMP(mp1))
  554.         {
  555.         case PIRB_SIZEPOSITION:         /* Program type: User defined size & position */
  556.             if((BOOL)WinSendDlgItemMsg( /* Send message to Size & Position radiobutton */
  557.                 hwndDlg,                /* Handle of dialog window */
  558.                 PIRB_SIZEPOSITION,      /* Program size: Size & Position radiobutton */
  559.                 BM_QUERYCHECK,          /* Query the state */
  560.                 (MPARAM)NULL,
  561.                 (MPARAM)NULL)==TRUE)
  562.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  563.                     MPFROMSHORT(TRUE), MPFROMSHORT(FALSE));
  564.             else
  565.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  566.                     MPFROMSHORT(FALSE), MPFROMSHORT(FALSE));
  567.             break;
  568.  
  569.         case PIRB_DOSFULLSCREEN:
  570.         case PIRB_DOSWINDOW:
  571.                                         /* Enable and show DOS child windows */
  572.             DisableDialogItem(hwndDlg, usChild2DOS,
  573.                 sizeof(usChild2DOS)/sizeof(USHORT), WS_VISIBLE);
  574.                                         /* Enable and show WPSObject child windows */
  575.             DisableDialogItem(hwndDlg, usChild2WPSObject,
  576.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  577.                                         /* Enable and show WPSObject child windows */
  578.             DisableDialogItem(hwndDlg, usChild2WPSObjectHide,
  579.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  580.             break;
  581.  
  582.         case PIRB_SHELL:
  583.         case PIRB_OS2FULLSCREEN:
  584.         case PIRB_OS2WINDOW:
  585.         case PIRB_PM:
  586.                                         /* Enable and hide DOS child windows */
  587.             DisableDialogItem(hwndDlg, usChild2DOS,
  588.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  589.                                         /* Enable and show WPSObject child windows */
  590.             DisableDialogItem(hwndDlg, usChild2WPSObject,
  591.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  592.                                         /* Enable and show WPSObject child windows */
  593.             DisableDialogItem(hwndDlg, usChild2WPSObjectHide,
  594.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  595.             break;
  596.         
  597.         case PIRB_WPSOBJECT:
  598.                                         /* Disable and show WPSObject child windows */
  599.             DisableDialogItem(hwndDlg, usChild2WPSObject,
  600.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  601.                                         /* Hide but enable WPSObject child windows */
  602.             DisableDialogItem(hwndDlg, usChild2WPSObjectHide,
  603.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), 0);
  604.                                         /* Enable and hide DOS child windows */
  605.             DisableDialogItem(hwndDlg, usChild2DOS,
  606.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  607.                                         /* Only default Style is allowed */
  608.             WinSendDlgItemMsg(hwndDlg, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  609.                 MPFROMSHORT(TRUE), (MPARAM)NULL);
  610.                                         /* Load empty text in not required fields */
  611.             WinSetDlgItemText(hwndDlg, PIEF_DIRECTORY, "");
  612.             WinSetDlgItemText(hwndDlg, PIEF_PARAMETERS, "");
  613.             break;
  614.         }
  615.     }
  616.     break;
  617.  
  618. case WM_COMMAND:                        /* Button pressed */
  619.     switch(SHORT1FROMMP(mp1))
  620.     {
  621.     case PIPB_WINFILEDLG:               /* Locate file by standard file dialog */
  622. /*                                                                                      *\
  623.  * The user selected the File Find pushbutton to get the standard file dialog to find   *
  624.  * the program he wants to install.                                                     *
  625. \*                                                                                      */
  626.         {
  627.         FILEDLG fdFileDlg;              /* Standard file dialog control */
  628.         HWND    hwndFileDlg;            /* Handle of standard file dialog */
  629.  
  630.                                         /* Clear out structure */
  631.         memset(&fdFileDlg, 0, sizeof(FILEDLG));
  632.                                         /* Structure size */
  633.         fdFileDlg.cbSize=sizeof(FILEDLG);
  634.                                         /* FDS_* flags */
  635.         fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG | FDS_PRELOAD_VOLINFO;
  636.                                         /* Dialog title string */
  637.         fdFileDlg.pszTitle="PC/2 File Search";
  638.                                         /* Initial path, filename or file filter */
  639.         strcpy(fdFileDlg.szFullFile, "C:\\*");
  640.                                         /* Open the standard file dialog ...*/
  641.         hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwndDlg, &fdFileDlg);
  642.         if(hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
  643.                                         /* Load the values of the standard file dialog to
  644.                                            the corresponding entryfield in the Program
  645.                                            installation dialog. It is a file not an object. */
  646.             InstallFilename2Dialog(hwndDlg, fdFileDlg.szFullFile, FALSE);
  647.         }
  648.                                         /* Prevent to dismiss program installation dialog
  649.                                            by exiting switch via a break statement */
  650.         return((MRESULT)FALSE);
  651.  
  652.     case DID_OK:                        /* Enter key pressed */
  653. /*                                                                                      *\
  654.  * Query the Program Title, Filename, Parameters and DOS Settings and copy them to the  *
  655.  * corresponding entries in the StartSession structure.                                 *
  656. \*                                                                                      */
  657.         WinQueryWindowText(             /* Query data entered in Program title entry */
  658.             WinWindowFromID(hwndDlg, PIEF_PROGRAMTITLE),
  659.                                         /* into SessionData structure */
  660.             sizeof(SessionData.PgmTitle),
  661.             SessionData.PgmTitle);
  662.         WinQueryWindowText(             /* Query data entered in Path and Filename entry */
  663.             WinWindowFromID(hwndDlg, PIEF_PATHFILENAME),
  664.                                         /* into SessionData structure */
  665.             sizeof(SessionData.PgmName),
  666.             SessionData.PgmName);
  667.         WinQueryWindowText(             /* Query data entered in working Directory entry */
  668.             WinWindowFromID(hwndDlg, PIEF_DIRECTORY),
  669.                                         /* into SessionData structure */
  670.             sizeof(SessionData.PgmDirectory),
  671.             SessionData.PgmDirectory);
  672.         WinQueryWindowText(         /* Query data entered in Parameters entry */
  673.             WinWindowFromID(hwndDlg, PIEF_PARAMETERS),
  674.                                         /* into SessionData structure */
  675.             sizeof(SessionData.PgmInputs),
  676.             SessionData.PgmInputs);
  677.         WinQueryWindowText(             /* Query data entered in DOS Settings MLE */
  678.             WinWindowFromID(hwndDlg, PIEF_DOSSETTINGS),
  679.                                         /* into SessionData structure */
  680.             sizeof(SessionData.PgmDosSettings),
  681.             SessionData.PgmDosSettings);
  682. /*                                                                                      *\
  683.  * Query the Program Type radiobuttons and set the corresponding bit into the           *
  684.  * StartSession structure. No change or the default selection are preselected during    *
  685.  * WM_INITDLG. It must be one of them set, so we don't need else parts for if-else.     *
  686. \*                                                                                      */
  687.                                         /* Program type: WPS default */
  688.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_SHELL))
  689.             SessionData.SessionType=SSF_TYPE_DEFAULT;
  690.                                         /* Program type: OS/2 Fullscreen */
  691.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_OS2FULLSCREEN))
  692.             SessionData.SessionType=SSF_TYPE_FULLSCREEN;
  693.                                         /* Program type: OS/2 Window */
  694.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_OS2WINDOW))
  695.             SessionData.SessionType=SSF_TYPE_WINDOWABLEVIO;
  696.                                         /* Program type: PM */
  697.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_PM))
  698.             SessionData.SessionType=SSF_TYPE_PM;
  699.                                         /* Program type: DOS Fullscreen */
  700.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_DOSFULLSCREEN))
  701.             SessionData.SessionType=SSF_TYPE_VDM;
  702.                                         /* Program type: DOS Window */
  703.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_DOSWINDOW))
  704.             SessionData.SessionType=SSF_TYPE_WINDOWEDVDM;
  705.                                         /* Program type: WPS Object */
  706.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_WPSOBJECT))
  707.             SessionData.SessionType=SSF_TYPE_WPSOBJECT;
  708. /*                                                                                      *\
  709.  * Query Program Style radiobuttons and set the corresponding bits in the StartSession  *
  710.  * structure. No change or the default selection are preselected during WM_INITDLG.     *
  711. \*                                                                                      */
  712.                                         /* Program style: Maximized */
  713.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_MAXIMIZED))
  714.             SessionData.PgmControl|=SSF_CONTROL_MAXIMIZE;
  715.         else
  716.             SessionData.PgmControl&=(~SSF_CONTROL_MAXIMIZE);
  717.                                         /* Program style: Minimized */
  718.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_MINIMIZED))
  719.             SessionData.PgmControl|=SSF_CONTROL_MINIMIZE;
  720.         else
  721.             SessionData.PgmControl&=(~SSF_CONTROL_MINIMIZE);
  722.                                         /* Program style: Invisible */
  723.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_INVISIBLE))
  724.             SessionData.PgmControl|=SSF_CONTROL_INVISIBLE;
  725.         else
  726.             SessionData.PgmControl&=(~SSF_CONTROL_INVISIBLE);
  727.                                         /* Program style: No autoclose */
  728.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_NOAUTOCLOSE))
  729.             SessionData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
  730.         else
  731.             SessionData.PgmControl&=(~SSF_CONTROL_NOAUTOCLOSE);
  732.                                         /* Program style: Background */
  733.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_BACKGROUND))
  734.             SessionData.FgBg|=SSF_FGBG_BACK;
  735.         else
  736.             SessionData.FgBg&=(~SSF_FGBG_BACK);
  737. /*                                                                                      *\
  738.  * Query Size & Position radiobutton, set the corresponding bit, and load the values    *
  739.  * from the corresponding entryfields for the StartSession structure.                   *
  740. \*                                                                                      */
  741.         {
  742.         UCHAR   Buffer[6];              /* Prefix, 4 numbers, \0 */
  743.  
  744.         if(WinQueryButtonCheckstate(hwndDlg, PIRB_SIZEPOSITION))
  745.             SessionData.PgmControl|=SSF_CONTROL_SETPOS;
  746.         else
  747.             SessionData.PgmControl&=(~SSF_CONTROL_SETPOS);
  748.         WinQueryWindowText(WinWindowFromID(hwndDlg, PIEF_X), sizeof(Buffer), Buffer);
  749.         SessionData.InitXPos=(SHORT)atol(Buffer);
  750.         if(SessionData.InitXPos<HookParameters.VirtualDesktopMin.x)
  751.             SessionData.InitXPos=HookParameters.VirtualDesktopMin.x;
  752.         if(SessionData.InitXPos>2*HookParameters.VirtualDesktopMax.x)
  753.             SessionData.InitXPos=HookParameters.VirtualDesktopMax.x;
  754.         WinQueryWindowText(WinWindowFromID(hwndDlg, PIEF_Y), sizeof(Buffer), Buffer);
  755.         SessionData.InitYPos=(SHORT)atol(Buffer);
  756.         if(SessionData.InitYPos<HookParameters.VirtualDesktopMin.y)
  757.             SessionData.InitYPos=HookParameters.VirtualDesktopMin.y;
  758.         if(SessionData.InitYPos>2*HookParameters.VirtualDesktopMax.y)
  759.             SessionData.InitYPos=HookParameters.VirtualDesktopMax.y;
  760.         WinQueryWindowText(WinWindowFromID(hwndDlg, PIEF_XSIZE), sizeof(Buffer), Buffer);
  761.         SessionData.InitXSize=(USHORT)atol(Buffer);
  762.         if(SessionData.InitXSize<0) SessionData.InitXSize*=-1;
  763.         WinQueryWindowText(WinWindowFromID(hwndDlg, PIEF_YSIZE), sizeof(Buffer), Buffer);
  764.         SessionData.InitYSize=(USHORT)atol(Buffer);
  765.         if(SessionData.InitYSize<0) SessionData.InitYSize*=-1;
  766.         }
  767.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  768.         break;
  769.  
  770.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  771.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  772.         break;
  773.  
  774.     default:
  775.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  776.     }
  777.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  778.     break;
  779.  
  780. default:                                /* Default window procedure must be called */
  781.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  782. }
  783. return((MRESULT)FALSE);                 /* We have handled the message */
  784. }
  785.  
  786.  
  787. /*--------------------------------------------------------------------------------------*\
  788.  * This dialog procedure handles the subclassed PC/2 - Program Installation dialog.     *
  789.  * Req:                                                                                 *
  790.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  791. \*--------------------------------------------------------------------------------------*/
  792. MRESULT  EXPENTRY PI_SubclassedDialogProcedure(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  793. {
  794. PDRAGINFO       pDragInfo;              /* Pointer to DRAGINFO structure */
  795. PDRAGITEM       pDragItem;              /* Pointer to DRAGITEM structure */
  796.  
  797. switch(msg)
  798. {
  799. /*                                                                                      *\
  800.  * Allow objects to be dropped on dialog box to add first dragitem as an application.   *
  801. \*                                                                                      */
  802. case DM_DRAGOVER:
  803.     pDragInfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  804.                                         /* Access the structure */
  805.     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
  806.                                         /* Get the first itemp of the item(s) dragged
  807.                                            onto dialog window */
  808.     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
  809.     if(pDragInfo->cditem!=1)
  810.                                         /* Don't allow dropping of more than one item */
  811.         return(MPFROM2SHORT(DOR_NODROP, DO_UNKNOWN));
  812.     else
  813.                                         /* Allow drop of undefined operation onto dialog window */
  814.         return(MPFROM2SHORT(DOR_DROP, DO_UNKNOWN));
  815.  
  816. case DM_DROP:
  817.     {
  818.     UCHAR       ucBuffer[256];
  819.     UCHAR       ucObjectType[256];
  820.     UCHAR       *pucBuffer;
  821.  
  822.     pDragInfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  823.                                         /* Access the structure */
  824.     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
  825.                                         /* Get the first itemp of the item(s) dragged
  826.                                            onto dialog window */
  827.     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
  828.                                         /* Query the rendering format */
  829.     DrgQueryStrName(pDragItem->hstrRMF, sizeof(ucObjectType), ucObjectType);
  830.                                         /* Scan for an WPS object */
  831.     if(strstr(ucObjectType, "<DRM_OBJECT, DRF_OBJECT>")==NULL)
  832.         {                               /* It is an application to get path and filename */
  833.                                         /* Query path (container) */
  834.         DrgQueryStrName(pDragItem->hstrContainerName, sizeof(ucBuffer), ucBuffer);
  835.                                         /* Position to \0 of path */
  836.         pucBuffer=ucBuffer+strlen(ucBuffer);
  837.                                         /* Query filename and append it to path */
  838.         DrgQueryStrName(pDragItem->hstrSourceName, sizeof(ucBuffer)-strlen(pucBuffer), pucBuffer);
  839.                                         /* Now change the entryfields to the dropped object
  840.                                            which is not a WPS object */
  841.         InstallFilename2Dialog(hwnd, ucBuffer, FALSE);
  842.         }
  843.     else
  844.         {                               /* It is an WPS Object so only get object name */
  845.                                         /* Query filename but don't append it to path */
  846.         DrgQueryStrName(pDragItem->hstrSourceName, sizeof(ucBuffer), ucBuffer);
  847.                                         /* Now change the entryfields to the dropped object
  848.                                            which is a WPS object */
  849.         InstallFilename2Dialog(hwnd, ucBuffer, TRUE);
  850.         }
  851.     }
  852.     break;
  853.  
  854. default:                                /* Pass all other messages to default window procedure */
  855.     return((MRESULT)PI_ClassDialogProcedure(hwnd, msg, mp1, mp2));
  856. }
  857. }
  858.  
  859. /*--------------------------------------------------------------------------------------*\
  860.  * This dialog procedure handles the PC/2 - Menu Installation dialog.                   *
  861.  * Req:                                                                                 *
  862.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  863.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  864.  *                      is used to start the session and set its priority.              *
  865. \*--------------------------------------------------------------------------------------*/
  866. MRESULT  EXPENTRY MI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  867. {
  868. switch(msg)
  869. {
  870. case WM_INITDLG:
  871.     {
  872.     SWP         swp;
  873.  
  874.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  875.     WinQueryWindowPos(                  /* Query position of dialog window */
  876.         hwndDlg,                        /* Handle of dialog window */
  877.         &swp);                          /* Fill with position */
  878.     WinSetWindowPos(                    /* Set dialog window position */
  879.         hwndDlg,                        /* Handle of dialog window */
  880.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  881.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  882. /*                                                                                      *\
  883.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  884.  * default number of 63.                                                                *
  885. \*                                                                                      */
  886.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  887.         hwndDlg,                        /* Handle of dialog window */
  888.         MIEF_MENUTITLE,                 /* Program submenu title entryfield */
  889.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  890.         MPFROMSHORT(EF_SIZE60),
  891.         (MPARAM)NULL);                  /* No additional parameter */
  892.     WinSetDlgItemText(                  /* Set text of title entryfield */
  893.         hwndDlg, MIEF_MENUTITLE, SessionData.PgmTitle);
  894.     break;
  895.     }
  896.  
  897. case WM_HELP:                           /* Help pressed */
  898.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  899.         hwndHelp,                       /* Help window */
  900.         HM_DISPLAY_HELP,                /* Display a help panel */
  901.         MPFROMSHORT(MIID_MENUDIALOG),   /* Panel ID in ressource file */
  902.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  903.     break;
  904.  
  905. case WM_COMMAND:                        /* Button pressed */
  906.     switch(SHORT1FROMMP(mp1))
  907.     {
  908.     case DID_OK:                        /* Enter key pressed */
  909. /*                                                                                      *\
  910.  * Query the Submenu Title and copy it to the corresponding entry in the StartSession   *
  911.  * structure.                                                                           *
  912. \*                                                                                      */
  913.         WinQueryWindowText(             /* Query data entered in Submenu title entry */
  914.             WinWindowFromID(hwndDlg, MIEF_MENUTITLE),
  915.                                         /* into SessionData structure */
  916.             sizeof(SessionData.PgmTitle),
  917.             SessionData.PgmTitle);
  918.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  919.         break;
  920.  
  921.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  922.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  923.         break;
  924.  
  925.     default:
  926.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  927.     }
  928.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  929.     break;
  930.  
  931. default:                                /* Default window procedure must be called */
  932.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  933. }
  934. return((MRESULT)FALSE);                 /* We have handled the message */
  935. }
  936.  
  937. /*--------------------------------------------------------------------------------------*\
  938.  * This dialog procedure handles the PC/2 - ShutDown OS/2 dialog.                       *
  939.  * Req: none                                                                            *
  940. \*--------------------------------------------------------------------------------------*/
  941. MRESULT  EXPENTRY SD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  942. {
  943. switch(msg)
  944. {
  945. case WM_INITDLG:
  946.     {
  947.     SWP         swp;
  948.  
  949.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  950.     WinQueryWindowPos(                  /* Query position of dialog window */
  951.         hwndDlg,                        /* Handle of dialog window */
  952.         &swp);                          /* Fill with position */
  953.     WinSetWindowPos(                    /* Set dialog window position */
  954.         hwndDlg,                        /* Handle of dialog window */
  955.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  956.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  957.     WinPostMsg(hwndDlg, WM_SHUTDOWN, NULL, NULL);
  958.     break;
  959.     }
  960.  
  961. /*                                                                                      *\
  962.  * Syntax: WM_SHUTDOWN, NULL, NULL                                                      *
  963. \*                                                                                      */
  964. case WM_SHUTDOWN:
  965. /*                                                                                      *\
  966.  * Wait for 2 seconds and then shut down OS/2.                                          *
  967. \*                                                                                      */
  968.     DosSleep(02000);
  969.     DosShutdown(0);
  970.     break;
  971.  
  972. default:                                /* Default window procedure must be called */
  973.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  974. }
  975. return((MRESULT)FALSE);                 /* We have handled the message */
  976. }
  977.  
  978. /*--------------------------------------------------------------------------------------*\
  979.  * This dialog procedure handles the PC/2 - Startup Parameters dialog.                  *
  980.  * Req: *PgmInputs .....A pointer to a string of commandline params of an application   *
  981.  *                      via mp2                                                         *
  982. \*--------------------------------------------------------------------------------------*/
  983. MRESULT  EXPENTRY SU_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  984. {
  985. static COMMANDLINEPARAMS        *pCLPParams;
  986.  
  987. switch(msg)
  988. {
  989. case WM_INITDLG:
  990.     {
  991.     UCHAR       ucBuffer[EF_SIZE255+1];
  992.  
  993.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  994.     pCLPParams=PVOIDFROMMP(mp2);
  995. /*                                                                                      *\
  996.  * Load text from CLPParams into the dialog box text fields, and set the text limit of  *
  997.  * the entryfield to 127.                                                               *
  998. \*                                                                                      */
  999.     sprintf(ucBuffer, "%s[...] %s", pCLPParams->ucPBefore, pCLPParams->ucPAfter);
  1000.                                         /* User information text field */
  1001.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPINFO, pCLPParams->ucPUser);
  1002.                                         /* Current parameters text field */
  1003.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPPARAMETERS, ucBuffer);
  1004.     WinSendDlgItemMsg(hwndDlg, SUEF_STARTUPPARAMETERS, EM_SETTEXTLIMIT,
  1005.         MPFROMSHORT(EF_SIZE60), (MPARAM)NULL);
  1006.     break;
  1007.     }
  1008.  
  1009. case WM_HELP:                           /* Help pressed */
  1010.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  1011.         MPFROMSHORT(SUID_STARTUPDIALOG), HM_RESOURCEID);
  1012.     break;
  1013.  
  1014. case WM_COMMAND:                        /* Button pressed */
  1015.     switch(SHORT1FROMMP(mp1))
  1016.     {
  1017.     case DID_OK:                        /* Enter key pressed */
  1018.         WinQueryWindowText(WinWindowFromID(hwndDlg, SUEF_STARTUPPARAMETERS),
  1019.             sizeof(pCLPParams->ucPUser), pCLPParams->ucPUser);
  1020.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1021.         break;
  1022.  
  1023.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1024.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1025.         break;
  1026.  
  1027.     default:
  1028.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1029.     }
  1030.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1031.     break;
  1032.  
  1033. default:                                /* Default window procedure must be called */
  1034.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1035. }
  1036. return((MRESULT)FALSE);                 /* We have handled the message */
  1037. }
  1038.  
  1039. /*--------------------------------------------------------------------------------------*\
  1040.  * This dialog procedure handles the PC/2 - Resort dialog.                              *
  1041. \*--------------------------------------------------------------------------------------*/
  1042. MRESULT  EXPENTRY RD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1043. {
  1044. static MENUDATA *pSortedMenuData;       /* Pointer to the first element of the resorted
  1045.                                            linked list */
  1046. static MENUDATA *pParentMenuData;       /* Menuitem, which current level is a child of */
  1047. static USHORT   usChild2InitPBs[]={DID_OK};
  1048. static USHORT   usChild2MovePBs[]={DID_CANCEL};
  1049. static USHORT   usChild2OKPBs[]={RDPB_MOVE};
  1050. static BOOL     bFirstMove;
  1051. switch(msg)
  1052. {
  1053. case WM_INITDLG:
  1054.     {
  1055.     SWP         swp;
  1056.     MENUDATA    *pMDSource;             /* Pointer withing the current linked list */
  1057.  
  1058.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1059.     WinQueryWindowPos(                  /* Query position of dialog window */
  1060.         hwndDlg,                        /* Handle of dialog window */
  1061.         &swp);                          /* Fill with position */
  1062.     WinSetWindowPos(                    /* Set dialog window position */
  1063.         hwndDlg,                        /* Handle of dialog window */
  1064.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1065.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1066. /*                                                                                      *\
  1067.  * Disable OK pushbutton, until all items have been moved. Get the first element of the *
  1068.  * current level of the linked list which will be resorted. Add all Menuitems of the    *
  1069.  * current level of the linked list to the source listbox. Save the parent Menuitem,    *
  1070.  * from where the current level is a child of.                                          *
  1071. \*                                                                                      */
  1072.     bFirstMove=FALSE;                   /* We didn't make any sort before */
  1073.     pSortedMenuData=NULL;               /* Pointer of resorted linked list points to a non
  1074.                                            available Menuitem */
  1075.                                         /* Disable and show OK pushbutton */
  1076.     DisableDialogItem(hwndDlg, usChild2InitPBs,
  1077.         sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1078.     if(pMenuData==pPopupMenu)           /* Is current level is the root of all levels ? */
  1079.         pParentMenuData=NULL;           /* Yes, then parent Menuitem is NULL */
  1080.     else                                /* No, then get parent Menuitem */
  1081.         pParentMenuData=pMenuData->Back;
  1082.     pMDSource=pMenuData;                /* Get first element of linked list */
  1083.     do                                  /* Add current level of Menuitems to the source listbox */
  1084.     {
  1085.         if(pMDSource->Item==ENTRYSUBMENU) /* It is a Submenu */
  1086.             {
  1087.             UCHAR       ucBuffer[EF_SIZE60+4];
  1088.                                         /* Add >> for a Submenu */
  1089.             sprintf(ucBuffer, "%s >>", pMDSource->PgmTitle);
  1090.                                         /* Insert Menuitem at the end of the listbox */
  1091.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  1092.                 MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  1093.             }
  1094.                                         /* It's a Menuitem */
  1095.         if(pMDSource->Item==ENTRYMENUITEM)
  1096.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  1097.                 MPFROMSHORT(LIT_END), MPFROMP(pMDSource->PgmTitle));
  1098.                                         /* It may also be an empty entry, but then we
  1099.                                            ignore it, because it must be filled with
  1100.                                            Menuitem or Submenu data first */
  1101.         if(pMDSource->Next!=NULL)       /* Get through linked list without diving into
  1102.                                            Submenus */
  1103.                 pMDSource=pMDSource->Next;
  1104.         else break;                     /* We're at the end of the linked list */
  1105.     }while(TRUE);
  1106.     break;
  1107.     }
  1108.  
  1109. case WM_HELP:                           /* Help pressed */
  1110.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  1111.         MPFROMSHORT(RDID_RESORTDIALOG), HM_RESOURCEID);
  1112.     break;
  1113.  
  1114. case WM_COMMAND:                        /* Button pressed */
  1115.     switch(SHORT1FROMMP(mp1))
  1116.     {
  1117.     case RDPB_MOVE:                     /* Move pushbutton */
  1118.         {
  1119.         MENUDATA        *pMDSource;     /* Walk through current linked list */
  1120.                                         /* Walk through destination linked list */
  1121.         MENUDATA        *pMDDestination;
  1122.         SHORT           sCount;
  1123.  
  1124. /*                                                                                      *\
  1125.  * For the first resort operation, disable the Cancel pushbutton.                       *
  1126. \*                                                                                      */
  1127.         if(bFirstMove==FALSE)           /* After the first move operation, disable the
  1128.                                            Cancel pushbutton */
  1129.             {
  1130.             bFirstMove=TRUE;            /* We make now the first move */
  1131.             DisableDialogItem(hwndDlg, usChild2MovePBs,
  1132.                 sizeof(usChild2MovePBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1133.             }
  1134. /*                                                                                      *\
  1135.  * Now get the selected Menuitem of the source listbox, delete it from the listbox. If  *
  1136.  * the source listbox is now empty, reenable the OK pushbutton again.                   *
  1137. \*                                                                                      */
  1138.                                         /* Query the selected Menuitem from the source listbox */
  1139.         sCount=(SHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYSELECTION,
  1140.             MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  1141.         if(sCount==LIT_NONE)            /* If no item selected ignore this button */
  1142.             return((MRESULT)FALSE);
  1143.         {
  1144.         UCHAR   ucBuffer[EF_SIZE60+4];
  1145.         SHORT   usItems;
  1146.                                         /* Query the text of the selected Menuitem from the
  1147.                                            source listbox */
  1148.         WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMTEXT,
  1149.             MPFROM2SHORT(sCount, sizeof(ucBuffer)), MPFROMP(ucBuffer));
  1150.                                         /* Delete the selected Menuitem from the source listbox */
  1151.         WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_DELETEITEM,
  1152.             MPFROMSHORT(sCount), (MPARAM)NULL);
  1153.                                         /* Insert the text of the selected Menuitem into the
  1154.                                            destination listbox */
  1155.         WinSendDlgItemMsg(hwndDlg, RDLB_DESTINATIONMENU, LM_INSERTITEM,
  1156.             MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  1157.                                         /* Query the number of Menuitems from the source
  1158.                                            listbox */
  1159.         usItems=(USHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMCOUNT,
  1160.             (MPARAM)NULL, (MPARAM)NULL);
  1161.         if(usItems==0)                  /* If now more items left, reenable OK pushbutton
  1162.                                            and disable Resort pushbutton */
  1163.             {
  1164.             DisableDialogItem(hwndDlg, usChild2InitPBs,
  1165.                 sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE);
  1166.             DisableDialogItem(hwndDlg, usChild2OKPBs,
  1167.                 sizeof(usChild2OKPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1168.             }
  1169.         }
  1170. /*                                                                                      *\
  1171.  * Now remove the selected Menuitem from the current linked list, by updating the       *
  1172.  * pointers according to previous or following Menuitems.                               *
  1173. \*                                                                                      */
  1174.         pMDSource=pMenuData;            /* Point to the first element of the linked list */
  1175.         for( ; sCount>0; sCount--)      /* Walk through the linked list to the selected
  1176.                                            item */
  1177.             pMDSource=pMDSource->Next;
  1178.         pMDDestination=pSortedMenuData; /* Point to the first element of the resorted linked list */
  1179.         if(pMDDestination!=NULL)        /* Walk through the resorted linked list to the
  1180.                                            last Menuitem, if there's at least one element */
  1181.             for( ; pMDDestination->Next!=NULL; pMDDestination=pMDDestination->Next);
  1182. /*                                                                                      *\
  1183.  * Now update the Popup-Menu, by moving the selected Menuitem.                          *
  1184. \*                                                                                      */
  1185.         if((pMDDestination==NULL) && (pParentMenuData==NULL))
  1186.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pPopupMenu));
  1187.         if((pMDDestination==NULL) && (pParentMenuData!=NULL))
  1188.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pParentMenuData));
  1189.         if(pMDDestination!=NULL)
  1190.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pMDDestination));
  1191.  
  1192.         if((pMDSource->Back!=NULL) && (pMDSource->Next!=NULL))
  1193.             {                           /* Current element follows another and is followed
  1194.                                            by another element, so simple remove it by
  1195.                                            updating the pointers. Be carefull if the
  1196.                                            parent element is a Submenu where the current
  1197.                                            level is a leaf of. */
  1198.             if((pMDSource->Back)->Submenu==pMDSource)
  1199.                 {
  1200.                 (pMDSource->Back)->Submenu=pMDSource->Next;
  1201.                 pMenuData=pMDSource->Next;
  1202.                 }
  1203.             else
  1204.                 (pMDSource->Back)->Next=pMDSource->Next;
  1205.             (pMDSource->Next)->Back=pMDSource->Back;
  1206.             }
  1207.         if((pMDSource->Back!=NULL) && (pMDSource->Next==NULL))
  1208.             {                           /* Current element follows another but is the last
  1209.                                            one of the current linked list.  Be carefull if
  1210.                                            the parent element is a Submenu where the current
  1211.                                            level is a leaf of. */
  1212.                                         /* Next element of course is NULL */
  1213.             if((pMDSource->Back)->Submenu==pMDSource)
  1214.                 {
  1215.                 (pMDSource->Back)->Submenu=pMDSource->Next;
  1216.                 pMenuData=pMDSource->Next;
  1217.                 }
  1218.             else
  1219.                 (pMDSource->Back)->Next=pMDSource->Next;
  1220.             }
  1221.         if((pMDSource->Back==NULL) && (pMDSource->Next!=NULL))
  1222.             {                           /* Current element is the first one of the complete
  1223.                                            linked list, but is followed by another */
  1224.             (pMDSource->Next)->Back=NULL;
  1225.             pMenuData=pMDSource->Next;
  1226.             pPopupMenu=pMDSource->Next;
  1227.             }
  1228.         if((pMDSource->Back==NULL) && (pMDSource->Next==NULL))
  1229.             {                           /* Current element is the first one of the complete
  1230.                                            linked list, and isn't followed by another */
  1231.             pMenuData=NULL;
  1232.             pPopupMenu=NULL;
  1233.             }
  1234. /*                                                                                      *\
  1235.  * Now add the deleted Menuitem at the end of the resorted linked list, by updating the *
  1236.  * pointer of the last element to point to the deleted one.                             *
  1237. \*                                                                                      */
  1238.         if(pMDDestination==NULL)
  1239.             {                           /* If the resorted linked list is empty, add
  1240.                                            deleted element and update pointers */
  1241.             pSortedMenuData=pMDSource;
  1242.             pMDDestination=pMDSource;
  1243.             pMDDestination->Next=NULL;
  1244.             pMDDestination->Back=NULL;
  1245.             }
  1246.         else
  1247.             {                           /* If the resorted linked list isn't empty, add
  1248.                                            deleted element at the end and update pointers */
  1249.             pMDDestination->Next=pMDSource;
  1250.             pMDSource->Back=pMDDestination;
  1251.             pMDSource->Next=NULL;
  1252.             }
  1253.         }
  1254.         return((MRESULT)FALSE);         /* We don't want to close the dialog by breaking
  1255.                                            out of the switch statement */
  1256.  
  1257.     case DID_OK:                        /* Enter key pressed */
  1258. /*                                                                                      *\
  1259.  * Now replace the current linked list, which is empty as all Menuitems have been re-   *
  1260.  * moved, with the resorted linked list.                                                *
  1261. \*                                                                                      */
  1262.         if(pParentMenuData==NULL)
  1263.             {                           /* If the root of the complete linked list has been
  1264.                                            resorted, update the root pointers */
  1265.             pPopupMenu=pSortedMenuData;
  1266.             pMenuData=pPopupMenu;
  1267.             }
  1268.         else
  1269.             {                           /* If the current level has a parent Menuitem, a
  1270.                                            Submenu of course, update the current level pointers */
  1271.             pMenuData=pSortedMenuData;
  1272.             pSortedMenuData->Back=pParentMenuData;
  1273.             pParentMenuData->Submenu=pMenuData;
  1274.             }
  1275.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1276.         break;
  1277.  
  1278.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1279.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1280.         break;
  1281.  
  1282.     default:
  1283.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1284.     }
  1285.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1286.     break;
  1287.  
  1288. default:                                /* Default window procedure must be called */
  1289.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1290. }
  1291. return((MRESULT)FALSE);                 /* We have handled the message */
  1292. }
  1293.  
  1294.  
  1295.