home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1995 November / PCWK1195.iso / inne / podstawy / os2 / nakladki / pc2v190.exe / SOURCE.ZIP / Source / Dialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-01  |  172.9 KB  |  2,977 lines

  1. /***********************************************************************\
  2.  *                                PC2.c                                *
  3.  *           Copyright (C) by Stangl Roman, 1993, 1994, 1995           *
  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.90 05,1995 $ (LBL)";
  12.  
  13. #define         _FILE_  "PC/2 - Dialog.c V1.90"
  14.  
  15. #include        "PC2.h"                 /* User include files */
  16. #include        "Error.h"
  17.  
  18.                                         /* Program Installation dialog notebook pages */
  19. NBPAGE          nbPINotebookPage[]=
  20. {
  21.     {PI_NotebookProcedure,  0,  0,  "Application Settings",      "~Application", PIID_PAGE1, PIEF_PROGRAMTITLE},
  22.     {PI_NotebookProcedure,  0,  0,  "Session Settings",          "~Session",     PIID_PAGE2, PIRB_SHELL},
  23.     {PI_NotebookProcedure,  0,  0,  "Style Settings",            "S~tyle",       PIID_PAGE3, PIRB_DEFAULTSTYLE},
  24.     {PI_NotebookProcedure,  0,  0,  "Hotkey Settings",           "Hot~key",      PIID_PAGE4, PIEF_SESSIONTITLE},
  25.     {PI_NotebookProcedure,  0,  0,  "Priority Settings",         "~Priority",    PIID_PAGE5, PIRB_NOCHANGE},
  26.     {PI_NotebookProcedure,  0,  0,  "Environment Settings",      "~Environment", PIID_PAGE6, PIMLE_ENVIRONMENT},
  27.     {NULL,                  0,  0,  "",                          "",             0,          0}
  28. };
  29.  
  30.                                         /* Desktop Settings dialog notebook pages */
  31. NBPAGE          nbDDNotebookPage[]=
  32. {
  33.     {DD_NotebookProcedure,  0,  0,  "Virtual Desktop Settings",  "~Desktop",     DDID_PAGE1, DDCB_VIRTUALDESKTOP},
  34.     {DD_NotebookProcedure,  0,  0,  "Physical Desktop Settings", "~Screen",      DDID_PAGE2, DDCB_BUTTON2ZORDER},
  35.     {DD_NotebookProcedure,  0,  0,  "General PC/2 Settings",     "~General",     DDID_PAGE3, DDCB_NORMALSHUTDOWN},
  36.     {NULL,                  0,  0,  "",                     "",                  0,          0}
  37. };
  38.  
  39. /*--------------------------------------------------------------------------------------*\
  40.  * This dialog procedure handles the PC/2 - About dialog.                               *
  41.  * Req: none                                                                            *
  42. \*--------------------------------------------------------------------------------------*/
  43. MRESULT  EXPENTRY AD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  44. {
  45. switch(msg)
  46. {
  47. case WM_INITDLG:
  48.     {
  49.     SWP         swp;
  50.  
  51.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  52.     WinQueryWindowPos(                  /* Query position of dialog window */
  53.         hwndDlg,                        /* Handle of dialog window */
  54.         &swp);                          /* Fill with position */
  55.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  56.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  57.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  58.     swp.cx=swp.cy=0;
  59.     swp.hwndInsertBehind=NULLHANDLE;
  60.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  61.     break;
  62.     }
  63.  
  64. case WM_HELP:                           /* Help pressed */
  65.     if(pHP->hwndHelp!=NULLHANDLE)
  66.         WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  67.             MPFROMSHORT(ID_ABOUTDIALOG), HM_RESOURCEID);
  68.     break;
  69.  
  70. case WM_COMMAND:                        /* Button pressed */
  71.     switch(SHORT1FROMMP(mp1))
  72.     {
  73.     case DID_OK:                        /* Enter key pressed */
  74.                                         /* Dialog terminated with DID_OK */
  75.         WinDismissDlg(hwndDlg, DID_OK);
  76.         break;
  77.  
  78.     case DID_CANCEL:                    /* Cancel key pressed */
  79.                                         /* Dialog terminated with DID_CANCEL */
  80.         WinDismissDlg(hwndDlg, DID_CANCEL);
  81.         break;
  82.  
  83.     default:
  84.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  85.     }
  86.     break;
  87.  
  88. default:                                /* Default window procedure must be called */
  89.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  90. }
  91. return((MRESULT)FALSE);                 /* We have handled the message */
  92. }
  93.  
  94. /*--------------------------------------------------------------------------------------*\
  95.  * This dialog procedure handles the PC/2 - Desktop configuration dialog.               *
  96.  * Req: none                                                                            *
  97. \*--------------------------------------------------------------------------------------*/
  98. MRESULT  EXPENTRY DD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  99. {
  100. static HWND          hwndNB;            /* Program Installation dialog notebook window handle */
  101.  
  102. switch(msg)
  103. {
  104. case WM_INITDLG:
  105.     {
  106.     HPS         hps;                    /* Used to query font metrics for tab size */
  107.     FONTMETRICS fmFontMetrics;
  108.     POINTL      aptlTabText[TXTBOX_COUNT];
  109.     USHORT      usTabTextLength=50;
  110.     SWP         swp;
  111.     ULONG       ulPage, ulPageID;
  112.     RECTL       rectlNB;                /* Notebook rectangle to load notebook dialog page into */
  113.     POINTL      ptlNB;                  /* Notebook page conversion from dialog units to pixels */
  114.  
  115.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  116.                                         /* Get window handle of notebook */
  117.     hwndNB=WinWindowFromID(hwndDlg, DDNB_NOTEBOOK);
  118.                                         /* Set spiralbind style */
  119.     WinSetWindowULong(hwndNB, QWL_STYLE, WinQueryWindowULong(hwndNB, QWL_STYLE) | BKS_SPIRALBIND);
  120.     hps=WinGetPS(hwndNB);               /* Get presentation space to query fontmetrics */
  121.     memset(&fmFontMetrics, 0, sizeof(FONTMETRICS));
  122.     if(GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fmFontMetrics))
  123.         fmFontMetrics.lMaxBaselineExt<<=1;
  124.     else
  125.         fmFontMetrics.lMaxBaselineExt=30;
  126.                                         /* Load and associate all dialogs of the Program
  127.                                            Installation dialog to notebook pages */
  128.     for(ulPage=0; nbDDNotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  129.         {
  130.                                         /* Load a dialog into a page */
  131.         if(!(nbDDNotebookPage[ulPage].hwndNBPage=WinLoadDlg(
  132.             hwndDlg,                    /* Parent window */
  133.             hwndDlg,                    /* Owner window */
  134.                                         /* Window procedure */
  135.             nbDDNotebookPage[ulPage].pDialogWndProc,
  136.             NULLHANDLE,                 /* Resource idendity */
  137.                                         /* Dialog idendity */
  138.             nbDDNotebookPage[ulPage].ulIDDialogPage,
  139.             NULL)))                     /* Application defined data area */
  140.                                         /* On error suggest exiting */
  141.             PM_ERR(pHP->habPc2, pHP->hwndFrame, HELP_CREATEDIALOG, MB_ERROR|MB_OK|MB_HELP|MB_MOVEABLE|MB_DEFBUTTON1,
  142.                 "Creation of a dialog box failed - continuing...");
  143.                                         /* Query length of largest tab text */
  144.         if(GpiQueryTextBox(hps, strlen(nbDDNotebookPage[ulPage].pszTab),
  145.             nbDDNotebookPage[ulPage].pszTab, TXTBOX_COUNT, aptlTabText))
  146.             if(usTabTextLength<aptlTabText[TXTBOX_CONCAT].x)
  147.                 usTabTextLength=aptlTabText[TXTBOX_CONCAT].x;
  148.         ulPageID=(ULONG)WinSendMsg(     /* Insert a page into the notebook */
  149.             hwndNB,
  150.             BKM_INSERTPAGE,
  151.             (MPARAM)NULL,               /* Page ID, ignored if BKA_FIRST or BKA_LAST
  152.                                            specified */
  153.                                         /* Style and order attribute */
  154.             MPFROM2SHORT(BKA_MAJOR | BKA_STATUSTEXTON | BKA_AUTOPAGESIZE, BKA_LAST));
  155.         nbDDNotebookPage[ulPage].ulIDPage=ulPageID;
  156.                                         /* Set text into the status line */
  157.         WinSendMsg(hwndNB,
  158.             BKM_SETSTATUSLINETEXT,
  159.             MPFROMP(ulPageID),
  160.             MPFROMP(nbDDNotebookPage[ulPage].pszStatusLine));
  161.                                         /* Set text into tab */
  162.         WinSendMsg(hwndNB,
  163.             BKM_SETTABTEXT,
  164.             MPFROMP(ulPageID),
  165.             MPFROMP(nbDDNotebookPage[ulPage].pszTab));
  166.                                         /* Associate page with dialog */
  167.         WinSendMsg(hwndNB,
  168.             BKM_SETPAGEWINDOWHWND,
  169.             MPFROMP(ulPageID),
  170.             MPFROMLONG(nbDDNotebookPage[ulPage].hwndNBPage));
  171.         }
  172.     WinReleasePS(hps);
  173.     WinSendMsg(hwndNB,                  /* Set background to dialog box background */
  174.         BKM_SETNOTEBOOKCOLORS,
  175.         MPFROMLONG(SYSCLR_FIELDBACKGROUND),
  176.         MPFROMSHORT(BKA_BACKGROUNDPAGECOLORINDEX));
  177.     WinSendMsg(hwndNB,                  /* Set tab dimension */
  178.         BKM_SETDIMENSIONS,
  179.         MPFROM2SHORT(usTabTextLength+5, (SHORT)((float)fmFontMetrics.lMaxBaselineExt*0.8)),
  180.         MPFROMSHORT(BKA_MAJORTAB));
  181.                                         /* Notebook page dialog panel size in dialog units */
  182.     ptlNB.x=NOTEBOOKPAGE_CX;
  183.     ptlNB.y=NOTEBOOKPAGE_CY;
  184.                                         /* Map dialog units to screen pixels */
  185.     WinMapDlgPoints(hwndDlg, &ptlNB, 1, TRUE);
  186.                                         /* Query notebook size and position in pixels */
  187.     WinQueryWindowPos(hwndNB, &swp);
  188.     rectlNB.yBottom=rectlNB.xLeft=0;
  189.     rectlNB.xRight=swp.cx;
  190.     rectlNB.yTop=swp.cy;
  191.                                         /* Return size of notebook page in pixel for given
  192.                                            notebook window size (with tab text size set) */
  193.     WinSendMsg(hwndNB, BKM_CALCPAGERECT, MPFROMP(&rectlNB), MPFROMSHORT(TRUE));
  194.                                         /* Calculate notebook size so that notebook dialog page fits
  195.                                            into the notebook page */
  196.     swp.cx-=(rectlNB.xRight-rectlNB.xLeft)-ptlNB.x;
  197.     swp.cy-=(rectlNB.yTop-rectlNB.yBottom)-ptlNB.y;
  198.                                         /* Size notebook accordingly */
  199.     swp.fl=SWP_SIZE;
  200.     swp.x=swp.y=0;
  201.     swp.hwndInsertBehind=NULLHANDLE;
  202.     swp.hwnd=hwndNB;
  203.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  204.     WinQueryWindowPos(                  /* Query position of dialog window */
  205.         hwndDlg,                        /* Handle of dialog window */
  206.         &swp);                          /* Fill with position */
  207.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  208.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  209.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  210.     swp.cx=swp.cy=0;
  211.     swp.hwndInsertBehind=NULLHANDLE;
  212.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  213.                                         /* Now initialize all notebook page dialogs
  214.                                            by posting to 1st page */
  215.     WinPostMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, WM_SETUPNOTEBOOKPAGES, (MPARAM)NULL, (MPARAM)NULL);
  216.     break;
  217.     }
  218.  
  219. case WM_HELP:                           /* Help pressed */
  220.     {
  221.     ULONG   ulPageId, ulPage;
  222.     ULONG   ulHelp[]={DDID_PAGE1, DDID_PAGE2, DDID_PAGE3};
  223.  
  224.     ulPageId=(ULONG)WinSendMsg(hwndNB,  /* Query the currently active page */
  225.         BKM_QUERYPAGEID,
  226.         MPFROMLONG(0),                  /* Location page ID, ignored if */
  227.                                         /* Page ID is BKA_TOP */
  228.         MPFROM2SHORT(BKA_TOP, BKA_MAJOR));
  229.     for(ulPage=0; nbDDNotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  230.         if(nbDDNotebookPage[ulPage].ulIDPage==ulPageId)
  231.             if(pHP->hwndHelp!=NULLHANDLE)
  232.                 WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  233.                     MPFROMSHORT(ulHelp[ulPage]), HM_RESOURCEID);
  234.     }
  235.     break;
  236.  
  237. case WM_COMMAND:                        /* Button pressed */
  238.     switch(SHORT1FROMMP(mp1))
  239.     {
  240.     case DID_OK:                        /* Enter key pressed */
  241.         {
  242.         UCHAR       ucBuffer[4];
  243.         POINTL      DesktopCountMin, DesktopCountMax;
  244.         ULONG       ulOldStatusFlag=pHP->ulStatusFlag;
  245.  
  246. /*                                                                                      *\
  247.  * First notebook page.                                                                 *
  248. \*                                                                                      */
  249.                                         /* Query checkboxes' state and set according flag */
  250.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_VIRTUALDESKTOP))
  251.             pHP->ulStatusFlag|=VIRTUALDESKTOP;
  252.         else pHP->ulStatusFlag&=~VIRTUALDESKTOP;
  253.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_MOVEDESKTOP))
  254.             pHP->ulStatusFlag|=MOVEDESKTOP;
  255.         else pHP->ulStatusFlag&=~MOVEDESKTOP;
  256.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_EXPANDWPS))
  257.             pHP->ulStatusFlag|=EXPANDWPS;
  258.         else pHP->ulStatusFlag&=~EXPANDWPS;
  259.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_CLICK2MOVE))
  260.             pHP->ulStatusFlag|=CLICK2MOVE;
  261.         else pHP->ulStatusFlag&=~CLICK2MOVE;
  262.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_OVERVIEW))
  263.             pHP->ulStatusFlag|=OVERVIEW;
  264.         else pHP->ulStatusFlag&=~OVERVIEW;
  265.                                         /* Query scroll percentage entryfield (0-based !!!) */
  266.         WinQueryWindowText(WinWindowFromID(nbDDNotebookPage[PAGE_1].hwndNBPage, DDEF_SCROLLPERCENTAGE),
  267.             sizeof(ucBuffer), ucBuffer);
  268.         pHP->ulScrollPercentage=(ULONG)atol(ucBuffer);;
  269.                                         /* Reinitialize scroll percentage */
  270.         pHP->SlidingXFactor=(pHP->ulScrollPercentage*
  271.             pHP->DesktopSize.x)/100;
  272.         pHP->SlidingYFactor=(pHP->ulScrollPercentage*
  273.             pHP->DesktopSize.y)/100;
  274. /*                                                                                      *\
  275.  * Get the count of Virtual Desktops, and adjust HookParameters control structure       *
  276.  * accordingly. This will allow dynamic change on the overview window and allowed user  *
  277.  * operation borders.                                                                   *
  278. \*                                                                                      */
  279.                                         /* Get number of horizontal and vertical Virtual Desktops */
  280.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_HORIZONTALDESKTOPS,
  281.             SPBM_QUERYVALUE, MPFROMP(&pHP->ulHorizontalDesktops), MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  282.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_VERTICALDESKTOPS,
  283.             SPBM_QUERYVALUE, MPFROMP(&pHP->ulVerticalDesktops), MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  284.         DesktopCountMin.x=(pHP->ulHorizontalDesktops-1)>>1;
  285.         DesktopCountMin.y=(pHP->ulVerticalDesktops-1)>>1;
  286.         DesktopCountMax.x=pHP->ulHorizontalDesktops-DesktopCountMin.x;
  287.         DesktopCountMax.y=pHP->ulVerticalDesktops-DesktopCountMin.y;
  288.         pHP->VirtualDesktopMin.x=(-pHP->DesktopSize.x)*DesktopCountMin.x;
  289.         pHP->VirtualDesktopMin.y=(-pHP->DesktopSize.y)*DesktopCountMin.y;
  290.         pHP->VirtualDesktopMax.x=pHP->DesktopSize.x*DesktopCountMax.x;
  291.         pHP->VirtualDesktopMax.y=pHP->DesktopSize.y*DesktopCountMax.y;
  292.                                         /* Query click flag */
  293.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDRB_BUTTON1CLICK))
  294.             pHP->ulClickFlag=WM_BUTTON1CLICK;
  295.         else pHP->ulClickFlag=WM_BUTTON1DBLCLK;
  296.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_SELECTFIRSTITEM))
  297.             pHP->ulStatusFlag|=SELECTFIRSTITEM;
  298.         else pHP->ulStatusFlag&=~SELECTFIRSTITEM;
  299.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_NORMALSHUTDOWN))
  300.             pHP->ulStatusFlag|=NORMALSHUTDOWN;
  301.         else pHP->ulStatusFlag&=~NORMALSHUTDOWN;
  302.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_IGNOREAUTOSTART))
  303.             pHP->ulStatusFlag|=IGNOREAUTOSTART;
  304.         else pHP->ulStatusFlag&=~IGNOREAUTOSTART;
  305.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_SLIDINGFOCUS))
  306.             pHP->ulStatusFlag|=SLIDINGFOCUS;
  307.         else pHP->ulStatusFlag&=~SLIDINGFOCUS;
  308.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_PRESERVEZORDER))
  309.             pHP->ulStatusFlag|=PRESERVEZORDER;
  310.         else pHP->ulStatusFlag&=~PRESERVEZORDER;
  311.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_HIDETITLEBAR))
  312.             pHP->ulStatusFlag|=HIDETITLEBAR;
  313.         else pHP->ulStatusFlag&=~HIDETITLEBAR;
  314.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_HIDESMARTICONBAR))
  315.             pHP->ulStatusFlag|=HIDESMARTICONBAR;
  316.         else pHP->ulStatusFlag&=~HIDESMARTICONBAR;
  317.         {                               /* Show or hide overview window according to
  318.                                            the user selected flag */
  319.         SWP     swp;
  320.  
  321.         swp.x=swp.y=swp.cx=swp.cy=0;
  322.         swp.hwnd=pHP->hwndFrame;
  323.         if(pHP->ulStatusFlag & OVERVIEW)
  324.             {
  325.             swp.fl=SWP_SHOW|SWP_DEACTIVATE;
  326.             swp.hwndInsertBehind=HWND_BOTTOM;
  327.             WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  328.             }
  329.         else
  330.             {
  331.             swp.fl=SWP_HIDE|SWP_DEACTIVATE;
  332.             swp.hwndInsertBehind=HWND_BOTTOM;
  333.             WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  334.             }
  335.         }
  336. /*                                                                                      *\
  337.  * Add or remove Titlebar + Hide Button or Smart icon bar according to user request.    *
  338. \*                                                                                      */
  339.         {
  340.         ULONG   ulChangedFCF;
  341.  
  342.         ulChangedFCF=0;
  343.                                         /* If titlebar is set but should be hidden, update
  344.                                            its window, which is a child of the frame */
  345.         if( (!!(pHP->ulOverviewFCF & (FCF_TITLEBAR|FCF_HIDEBUTTON)))==
  346.             (!!(pHP->ulStatusFlag & HIDETITLEBAR)) )
  347.             ulChangedFCF|=FCF_TITLEBAR|FCF_HIDEBUTTON;
  348.                                         /* If menubar is set but should be hidden, update
  349.                                            its window */
  350.         if( (!!(pHP->ulOverviewFCF & FCF_MENU))==
  351.             (!!(pHP->ulStatusFlag & HIDESMARTICONBAR)) )
  352.             ulChangedFCF|=FCF_MENU;
  353.                                         /* Set new FCF_* flags for titlebar + hide button */
  354.         if(pHP->ulStatusFlag & HIDETITLEBAR)
  355.             pHP->ulOverviewFCF&=~(FCF_TITLEBAR|FCF_HIDEBUTTON);
  356.         else
  357.             pHP->ulOverviewFCF|=(FCF_TITLEBAR|FCF_HIDEBUTTON);
  358.                                         /* Set new FCF_* flags for smarticon bar */
  359.         if(pHP->ulStatusFlag & HIDESMARTICONBAR)
  360.             pHP->ulOverviewFCF&=~(FCF_MENU);
  361.         else
  362.             pHP->ulOverviewFCF|=(FCF_MENU);
  363.                                         /* Now update Overview window */
  364.         if(ulChangedFCF)
  365.             WinPostMsg(pHP->hwndClient, WM_OVERVIEWFCF, MPFROMLONG(ulChangedFCF), NULL);
  366.         }
  367. /*                                                                                      *\
  368.  * Second notebook page.                                                                *
  369. \*                                                                                      */
  370.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_BUTTON2ZORDER))
  371.             pHP->ulStatusFlag|=BUTTON2ZORDER;
  372.         else pHP->ulStatusFlag&=~BUTTON2ZORDER;
  373.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_KEEPONTOP))
  374.             pHP->ulStatusFlag|=KEEPONTOP;
  375.         else pHP->ulStatusFlag&=~KEEPONTOP;
  376.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_USESPOOLER))
  377.             pHP->ulStatusFlag|=SHOWSPOOLERWINDOW;
  378.         else pHP->ulStatusFlag&=~SHOWSPOOLERWINDOW;
  379.                                         /* Query Desktop and Window List name */
  380.         WinQueryWindowText(WinWindowFromID(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_DESKTOPNAME),
  381.             sizeof(pHP->ucDesktopName), pHP->ucDesktopName);
  382.         WinQueryWindowText(WinWindowFromID(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_WINDOWLISTNAME),
  383.             sizeof(pHP->ucWindowListName), pHP->ucWindowListName);
  384. /*                                                                                      *\
  385.  * Get PM background bitmap settings.                                                   *
  386. \*                                                                                      */
  387.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_BACKGROUNDBITMAP))
  388.             pHP->ulStatusFlag|=BACKGROUNDBITMAP;
  389.         else pHP->ulStatusFlag&=~BACKGROUNDBITMAP;
  390.         WinQueryWindowText(WinWindowFromID(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_BACKGROUNDBITMAP),
  391.             sizeof(pHP->ucBackgroundBitmap), pHP->ucBackgroundBitmap);
  392.                                         /* Get number of tiled bitmaps */
  393.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDSB_BITMAPTILEDCOUNT,
  394.             SPBM_QUERYVALUE, MPFROMP(&pHP->ulBackgroundBitmapFlag), MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  395.                                         /* Query background bitmap style into upper USHORT */
  396.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPNORMAL))
  397.             pHP->ulBackgroundBitmapFlag|=BITMAPNORMAL;
  398.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPSCALED))
  399.             pHP->ulBackgroundBitmapFlag|=BITMAPSCALED;
  400.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPTILED))
  401.             pHP->ulBackgroundBitmapFlag|=BITMAPTILED;
  402. /*                                                                                      *\
  403.  * Third notebook page.                                                                 *
  404. \*                                                                                      */
  405. /*                                                                                      *\
  406.  * Get general environment settings flag.                                               *
  407. \*                                                                                      */
  408.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_NORMALSHUTDOWN))
  409.             pHP->ulStatusFlag|=NORMALSHUTDOWN;
  410.         else pHP->ulStatusFlag&=~NORMALSHUTDOWN;
  411.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_IGNOREAUTOSTART))
  412.             pHP->ulStatusFlag|=IGNOREAUTOSTART;
  413.         else pHP->ulStatusFlag&=~IGNOREAUTOSTART;
  414.         if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_HOTKEY4PC2ONLY))
  415.             pHP->ulStatusFlag|=HOTKEY4PC2ONLY;
  416.         else pHP->ulStatusFlag&=~HOTKEY4PC2ONLY;
  417. /*                                                                                      *\
  418.  * Update INI file and resize WPS when necessary.                                       *
  419. \*                                                                                      */
  420.                                         /* Write changes to PC2.INI */
  421.         if(!INIAccess(pHP->ucFilenameINI, FALSE))
  422.             USR_ERR(pHP->hwndFrame, HELP_PC2INI, MB_INFORMATION|MB_OK|MB_MOVEABLE|MB_DEFBUTTON1,
  423.                 "Can't save configuration data into PC2.INI - continuing... ");
  424.                                         /* Size WPS according to expand WPS flag */
  425.         if(pHP->ulStatusFlag & EXPANDWPS)
  426.             WinPostMsg(pHP->hwndThread, WM_EXPANDWPS, (MPARAM)TRUE, NULL);
  427.                                         /* If WPS was expanded before we must reduce it,
  428.                                            if WPS is not the same as before */
  429.         if((ulOldStatusFlag & EXPANDWPS) && !(pHP->ulStatusFlag & EXPANDWPS))
  430.             WinPostMsg(pHP->hwndThread, WM_EXPANDWPS, (MPARAM)FALSE, NULL);
  431.                                         /* Inform working thread to change PM background bitmap */
  432.         WinPostMsg(pHP->hwndThread, WM_BACKGROUNDBITMAP, NULL, NULL);
  433.                                         /* Dialog terminated with DID_OK */
  434.         WinDismissDlg(hwndDlg, DID_OK);
  435.         }
  436.         break;
  437.  
  438.     case DID_CANCEL:                    /* Cancel key pressed */
  439.                                         /* Dialog terminated with DID_CANCEL */
  440.         WinDismissDlg(hwndDlg, DID_CANCEL);
  441.         break;
  442.  
  443.     default:
  444.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  445.     }
  446.     break;
  447.  
  448. default:                                /* Default window procedure must be called */
  449.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  450. }
  451. return((MRESULT)FALSE);                 /* We have handled the message */
  452. }
  453.  
  454.  
  455. /*--------------------------------------------------------------------------------------*\
  456.  * This dialog procedure handles the PC/2 - Desktop Settings dialog notebook pages.     *
  457.  * Req:                                                                                 *
  458.  *      nbDDNotebookPage[] ...  Structure of the Desktop Settings notebook pages        *
  459. \*--------------------------------------------------------------------------------------*/
  460. MRESULT  EXPENTRY DD_NotebookProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  461. {
  462.                                         /* Child windows that change with the
  463.                                            DDCD_SLIDINGFOCUS checkbox */
  464. static USHORT   usChild2SlidingFocusCB[]={DDCB_PRESERVEZORDER};
  465.                                         /* Child windows that change with the
  466.                                            DDCB_VIRTUALDESKTOP checkbox */
  467. static USHORT   usChild2VirtualDesktopCB[]={DDCB_MOVEDESKTOP, DDCB_CLICK2MOVE,
  468.                                             DDCB_OVERVIEW, DDCB_EXPANDWPS, DDEF_SCROLLPERCENTAGE,
  469.                                             DDSB_HORIZONTALDESKTOPS, DDSB_VERTICALDESKTOPS};
  470.                                         /* Child window that change with DDCB_MOVEDESKTOP checkbox */
  471. static USHORT   usChild2MoveDesktopCB[]={DDCB_EXPANDWPS};
  472.                                         /* Child windows that change with DDCB_BACKGROUNDBITMAP */
  473. static USHORT   usChild2BackgroundBitmapCB[]={DDEF_BACKGROUNDBITMAP, DDPB_WINFILEDLG, DDRB_BITMAPNORMAL,
  474.                                               DDRB_BITMAPSCALED, DDRB_BITMAPTILED, DDSB_BITMAPTILEDCOUNT};
  475.                                         /* Child windows that change with DDCB_BITMAPTILED */
  476. static USHORT   usChild2BitmapTiledCB[]={DDSB_BITMAPTILEDCOUNT};
  477.  
  478. switch(msg)
  479. {
  480. /*                                                                                      *\
  481.  * Syntax: WM_SETUPNOTEBOOKPAGES, NULL, NULL                                            *                                           *
  482. \*                                                                                      */
  483. case WM_SETUPNOTEBOOKPAGES:
  484.     {
  485.     UCHAR       ucBuffer[4];
  486. /*                                                                                      *\
  487.  * Check the checkboxes that should be set according to the bitmap currently used in    *
  488.  * PC2.INI. If the virtual Desktop is disabled, then its child checkboxes can't be set, *
  489.  * because unchecking the virtual Desktop automatically unchecks its child checkboxes.  *
  490. \*                                                                                      */
  491. /*                                                                                      *\
  492.  * First notebook page.                                                                 *
  493. \*                                                                                      */
  494.                                         /* Check checkbox if Virtual Desktop flag is set */
  495.     if(pHP->ulStatusFlag & VIRTUALDESKTOP)
  496.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_VIRTUALDESKTOP, BM_SETCHECK,
  497.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  498.                                         /* Check checkbox if move Desktop flag is set. If set
  499.                                            disable expand WPS checkbox, else it may be set */
  500.     if(pHP->ulStatusFlag & MOVEDESKTOP)
  501.         {
  502.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_MOVEDESKTOP, BM_SETCHECK,
  503.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  504.         DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2MoveDesktopCB,
  505.             sizeof(usChild2MoveDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  506.         }
  507.                                         /* Check checkbox if expand WPS flag is set */
  508.     if(pHP->ulStatusFlag & EXPANDWPS)
  509.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_EXPANDWPS, BM_SETCHECK,
  510.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  511.                                         /* Check checkbox if click to move flag is set */
  512.     if(pHP->ulStatusFlag & CLICK2MOVE)
  513.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_CLICK2MOVE, BM_SETCHECK,
  514.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  515.                                         /* Check checkbox if overview window flag is set */
  516.     if(pHP->ulStatusFlag & OVERVIEW)
  517.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_OVERVIEW, BM_SETCHECK,
  518.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  519. /*                                                                                      *\
  520.  * Set scrolling percentage entryfield and horizontal scrollbar in 5 % increments.      *
  521. \*                                                                                      */
  522.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDHSB_SCROLLPERCENTAGE,
  523.         SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 20), (MPARAM)NULL);
  524.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDHSB_SCROLLPERCENTAGE,
  525.         SBM_SETSCROLLBAR, MPFROMSHORT(pHP->ulScrollPercentage/5),
  526.         MPFROM2SHORT(0, 20));
  527.                                         /* Insert the string */
  528.     WinSetDlgItemText(nbDDNotebookPage[PAGE_1].hwndNBPage, DDEF_SCROLLPERCENTAGE,
  529.         (CHAR *)_itoa(pHP->ulScrollPercentage, ucBuffer, 10));
  530. /*                                                                                      *\
  531.  * Set horizontal and vertical count of Virtual Desktops into spinbuttons after         *
  532.  * initialising them into the range of 1 to 9.                                          *
  533. \*                                                                                      */
  534.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_HORIZONTALDESKTOPS,
  535.         SPBM_SETLIMITS, MPFROMLONG(9), MPFROMLONG(1));
  536.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_HORIZONTALDESKTOPS,
  537.         SPBM_SETCURRENTVALUE, MPFROMLONG(pHP->ulHorizontalDesktops), (MPARAM)0);
  538.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_VERTICALDESKTOPS,
  539.         SPBM_SETLIMITS, MPFROMLONG(9), MPFROMLONG(1));
  540.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDSB_VERTICALDESKTOPS,
  541.         SPBM_SETCURRENTVALUE, MPFROMLONG(pHP->ulVerticalDesktops), (MPARAM)0);
  542. /*                                                                                      *\
  543.  * Disable the child windows of the virtual Desktop, if this checkbox isn't checked.    *
  544. \*                                                                                      */
  545.     if(!(pHP->ulStatusFlag & VIRTUALDESKTOP))
  546.         DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2VirtualDesktopCB,
  547.             sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  548. /*                                                                                      *\
  549.  * Set click flag.                                                                      *
  550. \*                                                                                      */
  551.     if(pHP->ulClickFlag==WM_BUTTON1CLICK)
  552.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDRB_BUTTON1CLICK, BM_SETCHECK,
  553.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  554.     else
  555.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDRB_BUTTON1DBLCLK, BM_SETCHECK,
  556.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  557.                                         /* Check checkbox if select first menuitem flag is set */
  558.     if(pHP->ulStatusFlag & SELECTFIRSTITEM)
  559.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_SELECTFIRSTITEM, BM_SETCHECK,
  560.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  561. /*                                                                                      *\
  562.  * Set general environment settings flag.                                               *
  563. \*                                                                                      */
  564.                                         /* Check checkbox if normal shutdown flag is set */
  565.     if(pHP->ulStatusFlag & NORMALSHUTDOWN)
  566.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_NORMALSHUTDOWN, BM_SETCHECK,
  567.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  568.                                         /* Check checkbox if ignore autostart flag is set */
  569.     if(pHP->ulStatusFlag & IGNOREAUTOSTART)
  570.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_IGNOREAUTOSTART, BM_SETCHECK,
  571.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  572. /*                                                                                      *\
  573.  * Disable the child windows of the sliding Focus, if this checkbox isn't checked.      *
  574. \*                                                                                      */
  575.     if(!(pHP->ulStatusFlag & SLIDINGFOCUS))
  576.         DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2SlidingFocusCB,
  577.             sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  578.                                         /* Check ckeckbox if sliding focus flag is set */
  579.     if(pHP->ulStatusFlag & SLIDINGFOCUS)
  580.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_SLIDINGFOCUS, BM_SETCHECK,
  581.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  582.                                         /* Check ckeckbox if preserve z-order flag is set */
  583.     if(pHP->ulStatusFlag & PRESERVEZORDER)
  584.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_PRESERVEZORDER, BM_SETCHECK,
  585.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  586. /*                                                                                      *\
  587.  * Set overview window flags.                                                           *
  588. \*                                                                                      */
  589.                                         /* Check ckeckbox if hide titlebar flag is set */
  590.     if(pHP->ulStatusFlag & HIDETITLEBAR)
  591.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_HIDETITLEBAR, BM_SETCHECK,
  592.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  593.                                         /* Check ckeckbox if hide smarticonbar flag is set */
  594.     if(pHP->ulStatusFlag & HIDESMARTICONBAR)
  595.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_HIDESMARTICONBAR, BM_SETCHECK,
  596.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  597. /*                                                                                      *\
  598.  * Second notebook page.                                                                *
  599. \*                                                                                      */
  600. /*                                                                                      *\
  601.  * Write the Desktop and Window List currently available or the default ones from       *
  602.  * PC2.INI into the entryfields. The maximum length of both we assume MAXNAMEL.         *
  603. \*                                                                                      */
  604.                                         /* First set the limits to MAXNAMEL */
  605.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_DESKTOPNAME, EM_SETTEXTLIMIT,
  606.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  607.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_WINDOWLISTNAME, EM_SETTEXTLIMIT,
  608.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  609.                                         /* Insert the strings */
  610.     WinSetDlgItemText(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_DESKTOPNAME, pHP->ucDesktopName);
  611.     WinSetDlgItemText(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_WINDOWLISTNAME, pHP->ucWindowListName);
  612.                                         /* Check ckeckbox if button 2 z-order flag is set */
  613.     if(pHP->ulStatusFlag & BUTTON2ZORDER)
  614.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_BUTTON2ZORDER, BM_SETCHECK,
  615.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  616.                                         /* Check checkbox if keep on top flag is set */
  617.     if(pHP->ulStatusFlag & KEEPONTOP)
  618.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_KEEPONTOP, BM_SETCHECK,
  619.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  620.                                         /* Check checkbox if use Spooler Window flag is set */
  621.     if(pHP->ulStatusFlag & SHOWSPOOLERWINDOW)
  622.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_USESPOOLER, BM_SETCHECK,
  623.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  624. /*                                                                                      *\
  625.  * Disable the child windows of the background bitmap, if this checkbox isn't checked.  *
  626. \*                                                                                      */
  627.     if(!(pHP->ulStatusFlag & BACKGROUNDBITMAP))
  628.         DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BackgroundBitmapCB,
  629.             sizeof(usChild2BackgroundBitmapCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  630.     else
  631.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_BACKGROUNDBITMAP, BM_SETCHECK,
  632.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  633.                                         /* Setup bitmap name entryfield */
  634.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_BACKGROUNDBITMAP, EM_SETTEXTLIMIT,
  635.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  636.     WinSetDlgItemText(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_BACKGROUNDBITMAP,
  637.         pHP->ucBackgroundBitmap);
  638.                                         /* Setup bitmap radiobuttons */
  639.     if(pHP->ulBackgroundBitmapFlag & BITMAPNORMAL)
  640.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPNORMAL, BM_SETCHECK,
  641.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  642.     if(pHP->ulBackgroundBitmapFlag & BITMAPSCALED)
  643.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPSCALED, BM_SETCHECK,
  644.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  645.     if(pHP->ulBackgroundBitmapFlag & BITMAPTILED)
  646.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPTILED, BM_SETCHECK,
  647.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  648.     else
  649.         DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BitmapTiledCB,
  650.             sizeof(usChild2BitmapTiledCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  651. /*                                                                                      *\
  652.  * Set tiled count of background bitmap into spinbuttons after initialising it into the *
  653.  * range of 1 to 99 (taken from lower USHORT of ulBackgroundBitmapFlag).                *
  654. \*                                                                                      */
  655.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDSB_BITMAPTILEDCOUNT,
  656.         SPBM_SETLIMITS, MPFROMLONG(99), MPFROMLONG(1));
  657.     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDSB_BITMAPTILEDCOUNT,
  658.         SPBM_SETCURRENTVALUE, MPFROMLONG(pHP->ulBackgroundBitmapFlag & 0xFFFF), (MPARAM)0);
  659. /*                                                                                      *\
  660.  * Third notebook page.                                                                 *
  661. \*                                                                                      */
  662. /*                                                                                      *\
  663.  * Set general environment settings flag.                                               *
  664. \*                                                                                      */
  665.                                         /* Check checkbox if normal shutdown flag is set */
  666.     if(pHP->ulStatusFlag & NORMALSHUTDOWN)
  667.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_NORMALSHUTDOWN, BM_SETCHECK,
  668.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  669.                                         /* Check checkbox if ignore autostart flag is set */
  670.     if(pHP->ulStatusFlag & IGNOREAUTOSTART)
  671.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_IGNOREAUTOSTART, BM_SETCHECK,
  672.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  673.                                         /* Check checkbox if Hotkeys should not be detected
  674.                                            systemwidw */
  675.     if(pHP->ulStatusFlag & HOTKEY4PC2ONLY)
  676.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_3].hwndNBPage, DDCB_HOTKEY4PC2ONLY, BM_SETCHECK,
  677.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  678.     break;
  679.     }
  680.  
  681. case WM_HSCROLL:                        /* Messages generated by horizontal scrollbars */
  682. /*                                                                                      *\
  683.  * This message is generated when a horizontal scrollbar is manipulated. See if it is   *
  684.  * our scrollbar DDHSB_SCROLLPERCENTAGE and process.                                    *
  685. \*                                                                                      */
  686.     if(SHORT1FROMMP(mp1)==DDHSB_SCROLLPERCENTAGE)
  687.         {
  688.         UCHAR       ucBuffer[4];
  689.         SHORT       sSliderPosition=SHORT1FROMMP(mp2);;
  690.  
  691.         switch(SHORT2FROMMP(mp2))
  692.         {                               /* All messages contain the new slider position,
  693.                                            so just use this value to change the priority
  694.                                            delta entryfield value */
  695.         case SB_LINELEFT:
  696.             pHP->ulScrollPercentage-=5;
  697.             break;
  698.  
  699.         case SB_PAGELEFT:
  700.             pHP->ulScrollPercentage-=25;
  701.             break;
  702.  
  703.         case SB_LINERIGHT:
  704.             pHP->ulScrollPercentage+=5;
  705.             break;
  706.  
  707.         case SB_PAGERIGHT:
  708.             pHP->ulScrollPercentage+=25;
  709.             break;
  710.  
  711.         case SB_SLIDERTRACK:
  712.         case SB_SLIDERPOSITION:
  713.             pHP->ulScrollPercentage=sSliderPosition*5;
  714.             break;
  715.         }
  716.         if(((LONG)pHP->ulScrollPercentage)<0) pHP->ulScrollPercentage=0;
  717.         if(pHP->ulScrollPercentage>100) pHP->ulScrollPercentage=100;
  718.         WinSetDlgItemText(nbDDNotebookPage[PAGE_1].hwndNBPage, DDEF_SCROLLPERCENTAGE,
  719.             (CHAR *)_itoa(pHP->ulScrollPercentage, ucBuffer, 10));
  720.         WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDHSB_SCROLLPERCENTAGE,
  721.             SBM_SETPOS, MPFROMSHORT(pHP->ulScrollPercentage/5), (MPARAM)NULL);
  722.         }
  723.     break;
  724.  
  725. case WM_CONTROL:                        /* Test for checkbuttons buttons pressed */
  726. /*                                                                                      *\
  727.  * Only if the DDCB_VIRTUALDESKTOP checkbox is pressed, its child windows are to be     *
  728.  * enabled. Otherwise the are disabled, but allways visible.                            *
  729. \*                                                                                      */
  730.     {
  731.                                         /* Was button class window clicked or double-clicked ? */
  732.     if((SHORT2FROMMP(mp1)==BN_CLICKED) || (SHORT2FROMMP(mp1)==BN_DBLCLICKED))
  733.         switch(SHORT1FROMMP(mp1))
  734.         {
  735.         case DDCB_VIRTUALDESKTOP:       /* Virtal Desktop enable/disable checkbox */
  736.             if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_VIRTUALDESKTOP, BM_QUERYCHECK,
  737.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  738.                                         /* Enable and show VirtualDesktopCB child windows */
  739.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2VirtualDesktopCB,
  740.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE);
  741.             else
  742.                 {
  743.                                         /* If move Desktop checkbox is checked, uncheck it */
  744.                 if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_MOVEDESKTOP))
  745.                     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_MOVEDESKTOP, BM_SETCHECK,
  746.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  747.                                         /* If click to move checkbox is checked, uncheck it */
  748.                 if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_CLICK2MOVE))
  749.                     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_CLICK2MOVE, BM_SETCHECK,
  750.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  751.                                         /* If overview checkbox is checked, uncheck it */
  752.                 if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_OVERVIEW))
  753.                     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_OVERVIEW, BM_SETCHECK,
  754.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  755.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2VirtualDesktopCB,
  756.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  757.                 }
  758.             break;
  759.  
  760.         case DDCB_MOVEDESKTOP:          /* Move WPS selected */
  761.             if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_MOVEDESKTOP, BM_QUERYCHECK,
  762.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  763.                 {                       /* If expand WPS is checked, uncheck it and disable */
  764.                 if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_EXPANDWPS))
  765.                     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_EXPANDWPS, BM_SETCHECK,
  766.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  767.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2MoveDesktopCB,
  768.                     sizeof(usChild2MoveDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  769.                 }
  770.             else
  771.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2MoveDesktopCB,
  772.                     sizeof(usChild2MoveDesktopCB)/sizeof(USHORT), WS_VISIBLE);
  773.             break;
  774.  
  775.         case DDCB_SLIDINGFOCUS:         /* Sliding Focus enable/disable checkbox */
  776.             if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_SLIDINGFOCUS, BM_QUERYCHECK,
  777.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  778.                                         /* Enable and show SlidingFocusCB child windows */
  779.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2SlidingFocusCB,
  780.                     sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE);
  781.             else
  782.                 {                       /* If preserve Z-order is checked, uncheck it */
  783.                 if(WinQueryButtonCheckstate(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_PRESERVEZORDER))
  784.                     WinSendDlgItemMsg(nbDDNotebookPage[PAGE_1].hwndNBPage, DDCB_PRESERVEZORDER, BM_SETCHECK,
  785.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  786.                                         /* Disable and show SlidingFocusCB child windows */
  787.                 DisableDialogItem(nbDDNotebookPage[PAGE_1].hwndNBPage, usChild2SlidingFocusCB,
  788.                     sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  789.                 }
  790.             break;
  791.  
  792.         case DDCB_BACKGROUNDBITMAP:     /* Background bitmap enable/disable checkbox */
  793.             if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDCB_BACKGROUNDBITMAP, BM_QUERYCHECK,
  794.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  795.                 {
  796.                                         /* Enable and show BackgroundBitmapCB child windows */
  797.                 DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BackgroundBitmapCB,
  798.                     sizeof(usChild2BackgroundBitmapCB)/sizeof(USHORT), WS_VISIBLE);
  799.                                         /* If bitmap should be not tiled, ensure that spinbutton is disabled */
  800.                 if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPTILED, BM_QUERYCHECK,
  801.                     (MPARAM)NULL, (MPARAM)NULL)==FALSE)
  802.                     DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BitmapTiledCB,
  803.                         sizeof(usChild2BitmapTiledCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  804.                 }
  805.             else
  806.                                         /* Disable and show BackgroundBitmapCB child windows */
  807.                 DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BackgroundBitmapCB,
  808.                     sizeof(usChild2BackgroundBitmapCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  809.             break;
  810.  
  811.         case DDRB_BITMAPNORMAL:         /* Enable tile count spinbutton on DDRB_BITMAPTILED otherwise disable it */
  812.         case DDRB_BITMAPSCALED:
  813.         case DDRB_BITMAPTILED:
  814.             if((BOOL)WinSendDlgItemMsg(nbDDNotebookPage[PAGE_2].hwndNBPage, DDRB_BITMAPTILED, BM_QUERYCHECK,
  815.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  816.                                         /* Enable and show BitmapTiledCB child windows */
  817.                 DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BitmapTiledCB,
  818.                     sizeof(usChild2BitmapTiledCB)/sizeof(USHORT), WS_VISIBLE);
  819.             else
  820.                                         /* Disable and show BitmapTiledCB child windows */
  821.                 DisableDialogItem(nbDDNotebookPage[PAGE_2].hwndNBPage, usChild2BitmapTiledCB,
  822.                     sizeof(usChild2BitmapTiledCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  823.             break;
  824.         }
  825.     }
  826.     break;
  827.  
  828. case WM_COMMAND:                        /* Button pressed */
  829.     switch(SHORT1FROMMP(mp1))
  830.     {
  831.     case DID_CANCEL:                    /* Cancel key pressed on a dialog within a notebook page,
  832.                                            ignore it within dialog but post it to parent dialog */
  833.         {
  834.         HWND    hwndNotebook;
  835.  
  836.                                         /* Query parent of current notebook page window,
  837.                                            Query parent of this, which is the notebook */
  838.         hwndNotebook=WinQueryWindow(WinQueryWindow(hwndDlg, QW_PARENT), QW_PARENT);
  839.                                         /* Post CANCEL to parent of notebook which is the dialog */
  840.         WinPostMsg(WinQueryWindow(hwndNotebook, QW_PARENT), WM_COMMAND,
  841.             MPFROMSHORT(DID_CANCEL), MPFROM2SHORT(CMDSRC_ACCELERATOR, FALSE));
  842.                                         /* We have handled the message */
  843.         return((MRESULT)TRUE);
  844.         }
  845.  
  846.     case DDPB_WINFILEDLG:               /* Locate file by standard file dialog */
  847. /*                                                                                      *\
  848.  * The user selected the File Find pushbutton to get the standard file dialog to find   *
  849.  * a background bitmap.                                                                 *
  850. \*                                                                                      */
  851.         {
  852.         FILEDLG fdFileDlg;              /* Standard file dialog control */
  853.         HWND    hwndFileDlg;            /* Handle of standard file dialog */
  854.  
  855.                                         /* Clear out structure */
  856.         memset(&fdFileDlg, 0, sizeof(FILEDLG));
  857.                                         /* Structure size */
  858.         fdFileDlg.cbSize=sizeof(FILEDLG);
  859.                                         /* FDS_* flags */
  860.         fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG | FDS_PRELOAD_VOLINFO;
  861.                                         /* Dialog title string */
  862.         fdFileDlg.pszTitle="PC/2 File Search";
  863.                                         /* Initial path, filename or file filter */
  864.         strcpy(fdFileDlg.szFullFile, "*.BMP");
  865.                                         /* Open the standard file dialog ...*/
  866.         hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwndDlg, &fdFileDlg);
  867.         if(hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
  868.                                         /* Load the values of the standard file dialog to
  869.                                            the corresponding entryfield in the Desktop
  870.                                            settings dialog */
  871.             WinSetDlgItemText(nbDDNotebookPage[PAGE_2].hwndNBPage, DDEF_BACKGROUNDBITMAP,
  872.                 fdFileDlg.szFullFile);
  873.         }
  874.         break;
  875.     }
  876.     break;
  877.  
  878. default:                                /* Default window procedure must be called */
  879.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  880. }
  881. return((MRESULT)FALSE);                 /* We have handled the message */
  882. }
  883.  
  884.  
  885. /*--------------------------------------------------------------------------------------*\
  886.  * This dialog procedure handles the PC/2 - Program Installation dialog.                *
  887.  * Req:                                                                                 *
  888.  *      StartSession .. a structure of type SESSIONDATA where the information entered   *
  889.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  890.  *                      is used to start the session and set its priority.              *
  891. \*--------------------------------------------------------------------------------------*/
  892. MRESULT  EXPENTRY PI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  893. {
  894. static HWND         hwndNB;             /* Program Installation dialog notebook window handle */
  895. static SESSIONDATA  *pSessionData;      /* Pointer to SESSIONDATA structure for current instance */
  896. static KEYDATA      SavedKeyData;       /* Hotkey for current instance, saved to be able to restore
  897.                                            when user presses CANCEL (because this instance's Hotkey
  898.                                            is deleted while this dialog is up as the user may choose
  899.                                            to change it) */
  900.  
  901. switch(msg)
  902. {
  903. case WM_INITDLG:
  904.     {
  905.     HPS         hps;                    /* Used to query font metrics for tab size */
  906.     FONTMETRICS fmFontMetrics;
  907.     POINTL      aptlTabText[TXTBOX_COUNT];
  908.     USHORT      usTabTextLength=50;
  909.     SWP         swp;
  910.     ULONG       ulPage, ulPageID;
  911.     RECTL       rectlNB;                /* Notebook rectangle to load notebook dialog page into */
  912.     POINTL      ptlNB;                  /* Notebook page conversion from dialog units to pixels */
  913.  
  914.                                         /* Access parameters passed */
  915.     pSessionData=(SESSIONDATA *)PVOIDFROMMP(mp2);
  916.                                         /* Save Hotkey to restore during CANCEL processing */
  917.     SavedKeyData=pSessionData->KeyData;
  918.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  919.                                         /* Get window handle of notebook */
  920.     hwndNB=WinWindowFromID(hwndDlg, PINB_NOTEBOOK);
  921.                                         /* Set spiral binding */
  922.     WinSetWindowULong(hwndNB, QWL_STYLE, WinQueryWindowULong(hwndNB, QWL_STYLE) | BKS_SPIRALBIND);
  923.     hps=WinGetPS(hwndNB);               /* Get presentation space to query fontmetrics */
  924.     memset(&fmFontMetrics, 0, sizeof(FONTMETRICS));
  925.     if(GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fmFontMetrics))
  926.         fmFontMetrics.lMaxBaselineExt<<=1;
  927.     else
  928.         fmFontMetrics.lMaxBaselineExt=30;
  929.                                         /* Load and associate all dialogs of the Program
  930.                                            Installation dialog to notebook pages */
  931.     for(ulPage=0; nbPINotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  932.         {
  933.                                         /* Load a dialog into a page */
  934.         if(!(nbPINotebookPage[ulPage].hwndNBPage=WinLoadDlg(
  935.             hwndDlg,                    /* Parent window */
  936.             hwndDlg,                    /* Owner window */
  937.                                         /* Window procedure */
  938.             nbPINotebookPage[ulPage].pDialogWndProc,
  939.             NULLHANDLE,                 /* Resource idendity */
  940.                                         /* Dialog idendity */
  941.             nbPINotebookPage[ulPage].ulIDDialogPage,
  942.             NULL)))                     /* Application defined data area */
  943.                                         /* On error suggest exiting */
  944.             PM_ERR(pHP->habPc2, pHP->hwndFrame, HELP_CREATEDIALOG, MB_ERROR|MB_OK|MB_HELP|MB_MOVEABLE|MB_DEFBUTTON1,
  945.                 "Creation of a dialog box failed - continuing...");
  946.                                         /* Query length of largest tab text */
  947.         if(GpiQueryTextBox(hps, strlen(nbPINotebookPage[ulPage].pszTab),
  948.             nbPINotebookPage[ulPage].pszTab, TXTBOX_COUNT, aptlTabText))
  949.             if(usTabTextLength<aptlTabText[TXTBOX_CONCAT].x)
  950.                 usTabTextLength=aptlTabText[TXTBOX_CONCAT].x;
  951.         ulPageID=(ULONG)WinSendMsg(     /* Insert a page into the notebook */
  952.             hwndNB,
  953.             BKM_INSERTPAGE,
  954.             (MPARAM)NULL,               /* Page ID, ignored if BKA_FIRST or BKA_LAST
  955.                                            specified */
  956.                                         /* Style and order attribute */
  957.             MPFROM2SHORT(BKA_MAJOR | BKA_STATUSTEXTON | BKA_AUTOPAGESIZE, BKA_LAST));
  958.         nbPINotebookPage[ulPage].ulIDPage=ulPageID;
  959.                                         /* Set text into the status line */
  960.         WinSendMsg(hwndNB,
  961.             BKM_SETSTATUSLINETEXT,
  962.             MPFROMP(ulPageID),
  963.             MPFROMP(nbPINotebookPage[ulPage].pszStatusLine));
  964.                                         /* Set text into tab */
  965.         WinSendMsg(hwndNB,
  966.             BKM_SETTABTEXT,
  967.             MPFROMP(ulPageID),
  968.             MPFROMP(nbPINotebookPage[ulPage].pszTab));
  969.                                         /* Associate page with dialog */
  970.         WinSendMsg(hwndNB,
  971.             BKM_SETPAGEWINDOWHWND,
  972.             MPFROMP(ulPageID),
  973.             MPFROMLONG(nbPINotebookPage[ulPage].hwndNBPage));
  974.         }
  975.     WinReleasePS(hps);
  976.     WinSendMsg(hwndNB,                  /* Set background to dialog box background */
  977.         BKM_SETNOTEBOOKCOLORS,
  978.         MPFROMLONG(SYSCLR_FIELDBACKGROUND),
  979.         MPFROMSHORT(BKA_BACKGROUNDPAGECOLORINDEX));
  980.     WinSendMsg(hwndNB,                  /* Set tab dimension */
  981.         BKM_SETDIMENSIONS,
  982.         MPFROM2SHORT(usTabTextLength+5, (SHORT)((float)fmFontMetrics.lMaxBaselineExt*0.8)),
  983.         MPFROMSHORT(BKA_MAJORTAB));
  984.                                         /* Notebook page dialog panel size in dialog units */
  985.     ptlNB.x=NOTEBOOKPAGE_CX;
  986.     ptlNB.y=NOTEBOOKPAGE_CY;
  987.                                         /* Map dialog units to screen pixels */
  988.     WinMapDlgPoints(hwndDlg, &ptlNB, 1, TRUE);
  989.                                         /* Query notebook size and position in pixels */
  990.     WinQueryWindowPos(hwndNB, &swp);
  991.     rectlNB.yBottom=rectlNB.xLeft=0;
  992.     rectlNB.xRight=swp.cx;
  993.     rectlNB.yTop=swp.cy;
  994.                                         /* Return size of notebook page in pixel for given
  995.                                            notebook window size (with tab text size set) */
  996.     WinSendMsg(hwndNB, BKM_CALCPAGERECT, MPFROMP(&rectlNB), MPFROMSHORT(TRUE));
  997.                                         /* Calculate notebook size so that notebook dialog page fits
  998.                                            into the notebook page */
  999.     swp.cx-=(rectlNB.xRight-rectlNB.xLeft)-ptlNB.x;
  1000.     swp.cy-=(rectlNB.yTop-rectlNB.yBottom)-ptlNB.y;
  1001.                                         /* Size notebook accordingly */
  1002.     swp.fl=SWP_SIZE;
  1003.     swp.x=swp.y=0;
  1004.     swp.hwndInsertBehind=NULLHANDLE;
  1005.     swp.hwnd=hwndNB;
  1006.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  1007.     WinQueryWindowPos(                  /* Query position of dialog window */
  1008.         hwndDlg,                        /* Handle of dialog window */
  1009.         &swp);                          /* Fill with position */
  1010.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  1011.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  1012.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  1013.     swp.cx=swp.cy=0;
  1014.     swp.hwndInsertBehind=NULLHANDLE;
  1015.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  1016.                                         /* Now initialize all notebook page dialogs
  1017.                                            by posting to 1st page */
  1018.     WinPostMsg(nbPINotebookPage[PAGE_1].hwndNBPage, WM_SETUPNOTEBOOKPAGES, MPFROMP(pSessionData), (MPARAM)NULL);
  1019.     break;
  1020.     }
  1021.  
  1022. case WM_HELP:                           /* Help pressed */
  1023.     {
  1024.     ULONG   ulPageId, ulPage;
  1025.     ULONG   ulHelp[]={PIID_PAGE1, PIID_PAGE2, PIID_PAGE3, PIID_PAGE4, PIID_PAGE5, PIID_PAGE6};
  1026.  
  1027.     ulPageId=(ULONG)WinSendMsg(hwndNB,  /* Query the currently active page */
  1028.         BKM_QUERYPAGEID,
  1029.         MPFROMLONG(0),                  /* Location page ID, ignored if */
  1030.                                         /* Page ID is BKA_TOP */
  1031.         MPFROM2SHORT(BKA_TOP, BKA_MAJOR));
  1032.     for(ulPage=0; nbPINotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  1033.         if(nbPINotebookPage[ulPage].ulIDPage==ulPageId)
  1034.             if(pHP->hwndHelp!=NULLHANDLE)
  1035.                 WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  1036.                     MPFROMSHORT(ulHelp[ulPage]), HM_RESOURCEID);
  1037.     }
  1038.     break;
  1039.  
  1040. case WM_COMMAND:                        /* Button pressed */
  1041.     switch(SHORT1FROMMP(mp1))
  1042.     {
  1043.     case DID_OK:                        /* Enter key pressed */
  1044. /*                                                                                      *\
  1045.  * Query the Program Title, Filename, Parameters and DOS Settings and copy them to the  *
  1046.  * corresponding entries in the StartSession structure.                                 *
  1047. \*                                                                                      */
  1048.         {
  1049.         ULONG   ulDosSettingsLength;
  1050.         UCHAR   *pucChar;
  1051.  
  1052.         WinQueryWindowText(             /* Query data entered in Program title entry */
  1053.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PROGRAMTITLE),
  1054.                                         /* into SessionData structure */
  1055.             sizeof(pSessionData->PgmTitle),
  1056.             pSessionData->PgmTitle);
  1057.         WinQueryWindowText(             /* Query data entered in Path and Filename entry */
  1058.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PATHFILENAME),
  1059.                                         /* into SessionData structure */
  1060.             sizeof(pSessionData->PgmName),
  1061.             pSessionData->PgmName);
  1062.         WinQueryWindowText(             /* Query data entered in working Directory entry */
  1063.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_DIRECTORY),
  1064.                                         /* into SessionData structure */
  1065.             sizeof(pSessionData->PgmDirectory),
  1066.             pSessionData->PgmDirectory);
  1067.         WinQueryWindowText(         /* Query data entered in Parameters entry */
  1068.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PARAMETERS),
  1069.                                         /* into SessionData structure */
  1070.             sizeof(pSessionData->PgmInputs),
  1071.             pSessionData->PgmInputs);
  1072.                                         /* Now get the variable length DOS settings */
  1073.                                         /* Allocate required length + space for \r\n */
  1074.         ulDosSettingsLength=(ULONG)(WinQueryWindowTextLength(WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage,
  1075.             PIMLE_DOSSETTINGS)))+2;
  1076.                                         /* Deallocate old and allocate new Environment settings */
  1077.         free(pSessionData->PgmDosSettings);
  1078.         pSessionData->PgmDosSettings=malloc(ulDosSettingsLength);
  1079.         WinQueryWindowText(             /* Query the DOS settings */
  1080.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIMLE_DOSSETTINGS),
  1081.             ulDosSettingsLength,
  1082.             pSessionData->PgmDosSettings);
  1083.                                         /* Remove all trailing \r and \n to add just 1 \r\n */
  1084.         for(pucChar=strchr(pSessionData->PgmDosSettings, '\0'); pucChar!=pSessionData->PgmDosSettings; )
  1085.             if((*--pucChar=='\r') || (*pucChar=='\n')) *pucChar='\0';
  1086.             else break;
  1087.                                         /* If not empty string ("\0") add 1 \r\n */
  1088.         if(pucChar!=pSessionData->PgmDosSettings)
  1089.             strcat(pSessionData->PgmDosSettings, "\r\n");
  1090.         }
  1091. /*                                                                                      *\
  1092.  * Query the Program Type radiobuttons and set the corresponding bit into the           *
  1093.  * StartSession structure. No change or the default selection are preselected during    *
  1094.  * WM_INITDLG. It must be one of them set, so we don't need else parts for if-else.     *
  1095. \*                                                                                      */
  1096.                                         /* Program type: WPS default */
  1097.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_SHELL))
  1098.             pSessionData->SessionType=PROG_DEFAULT;
  1099.                                         /* Program type: OS/2 Fullscreen */
  1100.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_OS2FULLSCREEN))
  1101.             pSessionData->SessionType=PROG_FULLSCREEN;
  1102.                                         /* Program type: OS/2 Window */
  1103.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_OS2WINDOW))
  1104.             pSessionData->SessionType=PROG_WINDOWABLEVIO;
  1105.                                         /* Program type: PM */
  1106.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_PM))
  1107.             pSessionData->SessionType=PROG_PM;
  1108.                                         /* Program type: DOS Fullscreen */
  1109.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_DOSFULLSCREEN))
  1110.             pSessionData->SessionType=PROG_VDM;
  1111.                                         /* Program type: DOS Window */
  1112.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_DOSWINDOW))
  1113.             pSessionData->SessionType=PROG_WINDOWEDVDM;
  1114.                                         /* Program type: WPS Object */
  1115.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WPSOBJECT))
  1116.             pSessionData->SessionType=PROG_WPSOBJECT;
  1117.                                         /* Program type: WIN-OS2 session. Type can then be
  1118.                                            queried from WIN-OS2 session radiobuttons */
  1119.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WINOS2))
  1120.             {
  1121.             BOOL    bCommonVDM=TRUE;
  1122.  
  1123.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PICB_WINSEPARATE))
  1124.                 bCommonVDM=FALSE;
  1125.             else
  1126.                 {                       /* If we start into a common WIN-OS2 seamless VDM, ensure
  1127.                                            that the program name contains no path information */
  1128.                 UCHAR   ucBuffer[EF_SIZE255+1];
  1129.                 UCHAR   *pucPgmName;
  1130.  
  1131.                 strcpy(ucBuffer, pSessionData->PgmName);
  1132.                 if((pucPgmName=strrchr(ucBuffer, '\\'))!=NULL)
  1133.                     strcpy(pSessionData->PgmName, ++pucPgmName);
  1134.                 }
  1135.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WINREAL))
  1136.                 pSessionData->SessionType=PROG_WINDOW_REAL;
  1137.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WINSTANDARD))
  1138.                 pSessionData->SessionType=
  1139.                     (bCommonVDM==TRUE ? PROG_31_STDSEAMLESSCOMMON : PROG_WINDOW_PROT);
  1140.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WIN386ENHANCED))
  1141.                 pSessionData->SessionType=
  1142.                     (bCommonVDM==TRUE ? PROG_31_ENHSEAMLESSCOMMON : PROG_31_ENH);
  1143.             }
  1144. /*                                                                                      *\
  1145.  * Query Program Style radiobuttons and set the corresponding bits in the StartSession  *
  1146.  * structure. No change or the default selection are preselected during WM_INITDLG.     *
  1147. \*                                                                                      */
  1148.                                         /* Program style: Maximized */
  1149.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PIRB_MAXIMIZED))
  1150.             pSessionData->PgmControl|=SSF_CONTROL_MAXIMIZE;
  1151.         else
  1152.             pSessionData->PgmControl&=(~SSF_CONTROL_MAXIMIZE);
  1153.                                         /* Program style: Minimized */
  1154.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PIRB_MINIMIZED))
  1155.             pSessionData->PgmControl|=SSF_CONTROL_MINIMIZE;
  1156.         else
  1157.             pSessionData->PgmControl&=(~SSF_CONTROL_MINIMIZE);
  1158.                                         /* Program style: Invisible */
  1159.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_INVISIBLE))
  1160.             pSessionData->PgmControl|=SSF_CONTROL_INVISIBLE;
  1161.         else
  1162.             pSessionData->PgmControl&=(~SSF_CONTROL_INVISIBLE);
  1163.                                         /* Program style: No autoclose */
  1164.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_NOAUTOCLOSE))
  1165.             pSessionData->PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
  1166.         else
  1167.             pSessionData->PgmControl&=(~SSF_CONTROL_NOAUTOCLOSE);
  1168.                                         /* Program style: Autostart */
  1169.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_AUTOSTART))
  1170.             pSessionData->PgmControl|=SSF_CONTROL_AUTOSTART;
  1171.         else
  1172.             pSessionData->PgmControl&=(~SSF_CONTROL_AUTOSTART);
  1173.                                         /* Program style: Background */
  1174.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_BACKGROUND))
  1175.             pSessionData->FgBg|=SSF_FGBG_BACK;
  1176.         else
  1177.             pSessionData->FgBg&=(~SSF_FGBG_BACK);
  1178. /*                                                                                      *\
  1179.  * Query Size & Position radiobutton, set the corresponding bit, and load the values    *
  1180.  * from the corresponding entryfields for the StartSession structure.                   *
  1181. \*                                                                                      */
  1182.         {
  1183.         UCHAR   ucBuffer[6];            /* Prefix, 4 numbers, \0 */
  1184.  
  1185.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_SIZEPOSITION))
  1186.             pSessionData->PgmControl|=SSF_CONTROL_SETPOS;
  1187.         else
  1188.             pSessionData->PgmControl&=(~SSF_CONTROL_SETPOS);
  1189.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndNBPage, PIEF_X), sizeof(ucBuffer), ucBuffer);
  1190.         pSessionData->InitXPos=(SHORT)atol(ucBuffer);
  1191.         if(pSessionData->InitXPos<pHP->VirtualDesktopMin.x)
  1192.             pSessionData->InitXPos=pHP->VirtualDesktopMin.x;
  1193.         if(pSessionData->InitXPos>2*pHP->VirtualDesktopMax.x)
  1194.             pSessionData->InitXPos=pHP->VirtualDesktopMax.x;
  1195.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndNBPage, PIEF_Y), sizeof(ucBuffer), ucBuffer);
  1196.         pSessionData->InitYPos=(SHORT)atol(ucBuffer);
  1197.         if(pSessionData->InitYPos<pHP->VirtualDesktopMin.y)
  1198.             pSessionData->InitYPos=pHP->VirtualDesktopMin.y;
  1199.         if(pSessionData->InitYPos>2*pHP->VirtualDesktopMax.y)
  1200.             pSessionData->InitYPos=pHP->VirtualDesktopMax.y;
  1201.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndNBPage, PIEF_XSIZE), sizeof(ucBuffer), ucBuffer);
  1202.         pSessionData->InitXSize=(USHORT)atol(ucBuffer);
  1203.         if(pSessionData->InitXSize<0) pSessionData->InitXSize*=-1;
  1204.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndNBPage, PIEF_YSIZE), sizeof(ucBuffer), ucBuffer);
  1205.         pSessionData->InitYSize=(USHORT)atol(ucBuffer);
  1206.         if(pSessionData->InitYSize<0) pSessionData->InitYSize*=-1;
  1207.         }
  1208. /*                                                                                      *\
  1209.  * Query Hotkey settings notebook page                                                  *
  1210. \*                                                                                      */
  1211.         {
  1212.         UCHAR   ucBuffer[]=" ";
  1213.  
  1214.         pSessionData->SwpFlag=0;        /* Assume no flags, which will now be corrected */
  1215.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_WSMAXIMIZED))
  1216.             pSessionData->SwpFlag=SWP_MAXIMIZE;
  1217.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_WSRESTORE))
  1218.             pSessionData->SwpFlag=SWP_RESTORE;
  1219.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PICB_DONTMOVE))
  1220.             pSessionData->SwpFlag|=SWP_NOMOVE;
  1221.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_CTRL))
  1222.             pSessionData->KeyData.usFlags=KC_CTRL;
  1223.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_ALT))
  1224.             pSessionData->KeyData.usFlags=KC_ALT;
  1225.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY),
  1226.             sizeof(ucBuffer), ucBuffer);
  1227.                                         /* If no hotkey is contained in the hotkey combobox
  1228.                                            none is available or it is disabled ignore hotkey feature */
  1229.         if(!strcmp(ucBuffer, "") ||
  1230.             !WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndNBPage, PICB_HOTKEYENABLED))
  1231.             {
  1232.             pSessionData->KeyData.usFlags=0;
  1233.             pSessionData->KeyData.usCh=0;
  1234.             }
  1235.         else                            /* Mark the selected key as used */
  1236.             {
  1237.             KEYDATA     *pKeyDataIndex;
  1238.             ULONG       ulTemp1;
  1239.  
  1240.             pSessionData->KeyData.usCh=(USHORT)ucBuffer[0];
  1241.                                         /* Point to Hotkey control structure */
  1242.             pKeyDataIndex=pHP->pKeyData;
  1243.                                         /* Loop for all keys and set used one */
  1244.             for(ulTemp1=0; ulTemp1<KEYDATACOUNT; pKeyDataIndex++, ulTemp1++)
  1245.                 {
  1246.                                         /* Set current key to used */
  1247.                 if((pKeyDataIndex->usCh==pSessionData->KeyData.usCh)  &&
  1248.                     (pKeyDataIndex->usFlags==pSessionData->KeyData.usFlags))
  1249.                     {
  1250.                     pKeyDataIndex->bUsed=TRUE;
  1251.                     pKeyDataIndex->pMenuData=pSessionData->KeyData.pMenuData;
  1252.                     }
  1253.                 }
  1254.             }
  1255.                                         /* Query the name of the session to search in Window List
  1256.                                            or in titlebars. If nothing is entered take the Program
  1257.                                            Title entryfield text, but ensure that tildes (~) are
  1258.                                            removed, because the session is launched with tiles
  1259.                                            removed. The tildes are only used to define mnemonics
  1260.                                            within PC/2's Popup-Menu. */
  1261.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_4].hwndNBPage, PIEF_SESSIONTITLE),
  1262.             sizeof(pSessionData->WindowTitle), pSessionData->WindowTitle);
  1263.         if(!strcmp(pSessionData->WindowTitle, ""))
  1264.             {
  1265.             UCHAR   *pucTo, *pucFrom;
  1266.  
  1267.             for(pucFrom=pSessionData->PgmTitle, pucTo=pSessionData->WindowTitle; *pucFrom; pucFrom++)
  1268.                 if(*pucFrom!='~') *pucTo++=*pucFrom;
  1269.             *pucTo='\0';                /* Zero termination */
  1270.             }
  1271.         }
  1272. /*                                                                                      *\
  1273.  * Query Program Priority radiobuttons and set the corresponding bits in the            *
  1274.  * StartSession structure. The default priority is No-Change. The listbox is also       *
  1275.  * queried and the Delta Priority is also set in the StartSession structure. It must be *
  1276.  * one of the radiobuttons, so else part of if-else is not required.                    *
  1277. \*                                                                                      */
  1278.         {
  1279.         UCHAR   ucBuffer[3];            /* 2 numbers, \0 */
  1280.                                         /* Program Priority: No-Change */
  1281.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_NOCHANGE))
  1282.             pSessionData->PriorityClass=PRTYC_NOCHANGE;
  1283.                                         /* Program Priority: Idle-time */
  1284.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_IDLETIME))
  1285.             pSessionData->PriorityClass=PRTYC_IDLETIME;
  1286.                                         /* Program Priority: Regular */
  1287.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_REGULAR))
  1288.             pSessionData->PriorityClass=PRTYC_REGULAR;
  1289.                                         /* Program Priority: Time-critical */
  1290.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_TIMECRITICAL))
  1291.             pSessionData->PriorityClass=PRTYC_TIMECRITICAL;
  1292.                                         /* Program Priority: Server */
  1293.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_FOREGROUNDSERVER))
  1294.             pSessionData->PriorityClass=PRTYC_FOREGROUNDSERVER;
  1295.                                         /* Query index of selected item on correct it */
  1296.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA),
  1297.             sizeof(ucBuffer), ucBuffer);
  1298.         pSessionData->PriorityDelta=(SHORT)atol(ucBuffer);
  1299.         }
  1300. /*                                                                                      *\
  1301.  * Query Program Environment and replace the one currently set at                       *
  1302.  * pSessionData->PgmEnvironment. The environment is used to complete/replace part of    *
  1303.  * the Environment of PC/2 when the application is started. The environment may also    *
  1304.  * contain BEGINLIBPATH and/or ENDLIBPATH which is not an environment variable, but     *
  1305.  * threated the same way (available only for OS/2 WARP 3.00+.                           *
  1306. \*                                                                                      */
  1307.         {
  1308.         ULONG   ulPgmEnvironmentLength;
  1309.         UCHAR   *pucChar;
  1310.  
  1311.                                         /* Allocate required length + space for \r\n */
  1312.         ulPgmEnvironmentLength=(ULONG)(WinQueryWindowTextLength(WinWindowFromID(nbPINotebookPage[PAGE_6].hwndNBPage,
  1313.             PIMLE_ENVIRONMENT)))+2;
  1314.                                         /* Deallocate old and allocate new Environment settings */
  1315.         free(pSessionData->PgmEnvironment);
  1316.         pSessionData->PgmEnvironment=malloc(ulPgmEnvironmentLength);
  1317.         WinQueryWindowText(             /* Query the environment settings */
  1318.             WinWindowFromID(nbPINotebookPage[PAGE_6].hwndNBPage, PIMLE_ENVIRONMENT),
  1319.             ulPgmEnvironmentLength,
  1320.             pSessionData->PgmEnvironment);
  1321.                                         /* Remove all trailing \r and \n to add just 1 \r\n */
  1322.         for(pucChar=strchr(pSessionData->PgmEnvironment, '\0'); pucChar!=pSessionData->PgmEnvironment; )
  1323.             if((*--pucChar=='\r') || (*pucChar=='\n')) *pucChar='\0';
  1324.             else break;
  1325.                                         /* If not empty string ("\0") add 1 \r\n */
  1326.         if(pucChar!=pSessionData->PgmEnvironment)
  1327.             strcat(pSessionData->PgmEnvironment, "\r\n");
  1328.         }
  1329.                                         /* Dialog terminated with DID_OK */
  1330.         WinDismissDlg(hwndDlg, DID_OK);
  1331.         break;
  1332.  
  1333.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1334.                                         /* Mark the selected key as used */
  1335.         {
  1336.         KEYDATA     *pKeyDataIndex;
  1337.         ULONG       ulTemp1;
  1338.  
  1339.                                     /* Point to Hotkey control structure */
  1340.         pKeyDataIndex=pHP->pKeyData;
  1341.                                     /* Loop for all keys and set used one */
  1342.         for(ulTemp1=0; ulTemp1<KEYDATACOUNT; pKeyDataIndex++, ulTemp1++)
  1343.             {
  1344.                                     /* Set original key to used */
  1345.             if((pKeyDataIndex->usCh==SavedKeyData.usCh)  &&
  1346.                 (pKeyDataIndex->usFlags==SavedKeyData.usFlags))
  1347.                 {
  1348.                 pKeyDataIndex->bUsed=TRUE;
  1349.                 pKeyDataIndex->pMenuData=pSessionData->KeyData.pMenuData;
  1350.                 }
  1351.             }
  1352.         }
  1353.                                     /* Query the name of the session to search in Window List
  1354.                                         /* Dialog terminated with DID_CANCEL */
  1355.         WinDismissDlg(hwndDlg, DID_CANCEL);
  1356.         break;
  1357.  
  1358.     default:
  1359.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1360.     }
  1361.     break;
  1362.  
  1363. default:                                /* Default window procedure must be called */
  1364.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1365. }
  1366. return((MRESULT)FALSE);                 /* We have handled the message */
  1367. }
  1368.  
  1369. /*--------------------------------------------------------------------------------------*\
  1370.  * This dialog procedure handles the PC/2 - Program Installation dialog notebook pages. *
  1371.  * Req:                                                                                 *
  1372.  *      nbPINotebookPage[] ...  Structure of the Program Installtion notebook pages     *
  1373. \*--------------------------------------------------------------------------------------*/
  1374. MRESULT  EXPENTRY PI_NotebookProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1375. {
  1376. static SESSIONDATA  *pSessionData;      /* Pointer to SESSIONDATA structure for current instance */
  1377.  
  1378. static SHORT        sPriorityDelta=PRTYC_NOCHANGE;
  1379.  
  1380. switch(msg)
  1381. {
  1382. /*                                                                                      *\
  1383.  * Syntax: WM_SETUPNOTEBOOKPAGES, (SESSIONDATA *pSessionData), NULL                     *                                           *
  1384. \*                                                                                      */
  1385. case WM_SETUPNOTEBOOKPAGES:
  1386.     {
  1387. /*                                                                                      *\
  1388.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  1389.  * default number of 63 and load the data from the SESSIONDATA structure SessionData    *
  1390.  * into the entryfields.                                                                *
  1391. \*                                                                                      */
  1392.                                         /* Access parameters passed */
  1393.     pSessionData=(SESSIONDATA *)PVOIDFROMMP(mp1);
  1394.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  1395.                                         /* Handle of page 1 */
  1396.         nbPINotebookPage[PAGE_1].hwndNBPage,
  1397.         PIEF_PROGRAMTITLE,              /* Program title entryfield */
  1398.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  1399.         MPFROMSHORT(MAXNAMEL),
  1400.         (MPARAM)NULL);                  /* No additional parameter */
  1401.     WinSetDlgItemText(                  /* Load the default text of the entryfield */
  1402.         nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PROGRAMTITLE, pSessionData->PgmTitle);
  1403.     WinSendDlgItemMsg(
  1404.         nbPINotebookPage[PAGE_1].hwndNBPage,
  1405.         PIEF_PATHFILENAME,              /* Path and Filename title entryfield */
  1406.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  1407.         MPFROMSHORT(EF_SIZE255),
  1408.         (MPARAM)NULL);
  1409.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PATHFILENAME, pSessionData->PgmName);
  1410.     WinSendDlgItemMsg(
  1411.         nbPINotebookPage[PAGE_1].hwndNBPage,
  1412.         PIEF_DIRECTORY,                 /* Working directory entryfield */
  1413.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  1414.         MPFROMSHORT(EF_SIZE255),
  1415.         (MPARAM)NULL);
  1416.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_DIRECTORY, pSessionData->PgmDirectory);
  1417.     WinSendDlgItemMsg(
  1418.         nbPINotebookPage[PAGE_1].hwndNBPage,
  1419.         PIEF_PARAMETERS,                /* Program Parameters entryfield */
  1420.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  1421.         MPFROMSHORT(EF_SIZE255),
  1422.         (MPARAM)NULL);
  1423.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PARAMETERS, pSessionData->PgmInputs);
  1424.                                         /* Insert DOS Settings. If none exist add the
  1425.                                            IDLE_* default settings */
  1426.     if(strlen(pSessionData->PgmDosSettings)!=0)
  1427.         WinSendDlgItemMsg(
  1428.             nbPINotebookPage[PAGE_1].hwndNBPage,
  1429.             PIMLE_DOSSETTINGS,          /* Program DOS Settings entryfield */
  1430.             MLM_INSERT,                 /* Insert text */
  1431.             MPFROMP(pSessionData->PgmDosSettings),
  1432.             (MPARAM)NULL);
  1433.     else
  1434.         WinSendDlgItemMsg(
  1435.             nbPINotebookPage[PAGE_1].hwndNBPage,
  1436.             PIMLE_DOSSETTINGS,          /* Program DOS Settings entryfield */
  1437.             MLM_INSERT,                 /* Insert text */
  1438.             MPFROMP("IDLE_SECONDS=5\nIDLE_SENSITIVITY=100\n"),
  1439.             (MPARAM)NULL);
  1440. /*                                                                                      *\
  1441.  * Now we preselect the radiobutton in the Program type group to the state indicated by *
  1442.  * the SessionData structure.                                                           *
  1443. \*                                                                                      */
  1444.     WinSendMsg(hwndDlg, WM_SETUPPROGRAMTYPE,
  1445.         MPFROMSHORT(pSessionData->SessionType), (MPARAM)NULL);
  1446. /*                                                                                      *\
  1447.  * Now we preselect the radiobutton in the Program style group to the state indicated   *
  1448.  * by the SessionData structure.                                                        *
  1449. \*                                                                                      */
  1450.     if(!(pSessionData->PgmControl & (SSF_CONTROL_MAXIMIZE | SSF_CONTROL_MINIMIZE)))
  1451.         WinSendDlgItemMsg(              /* Send message to Default radiobutton */
  1452.                                         /* Handle of dialog window */
  1453.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1454.             PIRB_DEFAULTSTYLE,          /* Program style: Default radiobutton */
  1455.             BM_SETCHECK,                /* Set it to pressed */
  1456.             MPFROMSHORT(TRUE),
  1457.             (MPARAM)NULL);
  1458.     if(pSessionData->PgmControl & SSF_CONTROL_MAXIMIZE)
  1459.         WinSendDlgItemMsg(
  1460.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1461.             PIRB_MAXIMIZED,             /* Program style: Maximized radiobutton */
  1462.             BM_SETCHECK,                /* Set it to pressed */
  1463.             MPFROMSHORT(TRUE),
  1464.             (MPARAM)NULL);
  1465.     if(pSessionData->PgmControl & SSF_CONTROL_MINIMIZE)
  1466.         WinSendDlgItemMsg(
  1467.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1468.             PIRB_MINIMIZED,             /* Program style: Minimized radiobutton */
  1469.             BM_SETCHECK,                /* Set it to pressed */
  1470.             MPFROMSHORT(TRUE),
  1471.             (MPARAM)NULL);
  1472.     if(pSessionData->PgmControl & SSF_CONTROL_INVISIBLE)
  1473.         WinSendDlgItemMsg(
  1474.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1475.             PICB_INVISIBLE,             /* Program style: Invisible checkbox */
  1476.             BM_SETCHECK,                /* Set it to pressed */
  1477.             MPFROMSHORT(TRUE),
  1478.             (MPARAM)NULL);
  1479.     if(pSessionData->PgmControl & SSF_CONTROL_NOAUTOCLOSE)
  1480.         WinSendDlgItemMsg(
  1481.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1482.             PICB_NOAUTOCLOSE,           /* Program style: NoAutoClose checkbox */
  1483.             BM_SETCHECK,                /* Set it to pressed */
  1484.             MPFROMSHORT(TRUE),
  1485.             (MPARAM)NULL);
  1486.     if(pSessionData->PgmControl & SSF_CONTROL_AUTOSTART)
  1487.         WinSendDlgItemMsg(
  1488.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1489.             PICB_AUTOSTART,             /* Program style: Autostart checkbox */
  1490.             BM_SETCHECK,                /* Set it to pressed */
  1491.             MPFROMSHORT(TRUE),
  1492.             (MPARAM)NULL);
  1493.     if(pSessionData->FgBg & SSF_FGBG_BACK)
  1494.         WinSendDlgItemMsg(
  1495.             nbPINotebookPage[PAGE_3].hwndNBPage,
  1496.             PICB_BACKGROUND,            /* Program style: Background checkbox */
  1497.             BM_SETCHECK,                /* Set it to pressed */
  1498.             MPFROMSHORT(TRUE),
  1499.             (MPARAM)NULL);
  1500. /*                                                                                      *\
  1501.  * Now we preselect the radiobutton in the Program Size & Position group to the state   *
  1502.  * indicated by the SessionData structure.                                              *
  1503. \*                                                                                      */
  1504.     if(pSessionData->PgmControl & SSF_CONTROL_SETPOS)
  1505.         {                               /* If requested select it for the first time */
  1506.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_SIZEPOSITION, BM_SETCHECK,
  1507.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1508.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  1509.             MPFROMSHORT(TRUE), MPFROMSHORT(TRUE));
  1510.         }
  1511.     else
  1512.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  1513.             MPFROMSHORT(FALSE), MPFROMSHORT(TRUE));
  1514.     }
  1515.                                         /* Simulate the click to update the dialog's child windows */
  1516.     WinSendMsg(nbPINotebookPage[PAGE_3].hwndNBPage, WM_CONTROL,
  1517.         MPFROM2SHORT(PICB_SIZEPOSITION, BN_CLICKED), (MPARAM)NULL);
  1518. /*                                                                                      *\
  1519.  * Now we initialize the priority settings notebook page.                               *
  1520. \*                                                                                      */
  1521.      WinSendMsg(hwndDlg, WM_SETUPPROGRAMPRIORITY,
  1522.         MPFROMSHORT(pSessionData->PriorityClass), MPFROMSHORT(pSessionData->PriorityDelta));
  1523. /*                                                                                      *\
  1524.  * Now we initialize the hotkey settings notebook page.                                 *
  1525. \*                                                                                      */
  1526.      WinSendMsg(hwndDlg, WM_SETUPHOTKEY, (MPARAM)NULL, (MPARAM)NULL);
  1527. /*                                                                                      *\
  1528.  * Now we initialize the Environment settings notebook page.                           *
  1529. \*                                                                                      */
  1530.                                         /* Insert Environment settings */
  1531.     WinSendDlgItemMsg(
  1532.         nbPINotebookPage[PAGE_6].hwndNBPage,
  1533.         PIMLE_ENVIRONMENT,              /* Program Environment entryfield */
  1534.         MLM_INSERT,                     /* Insert text */
  1535.         MPFROMP(pSessionData->PgmEnvironment),
  1536.         (MPARAM)NULL);
  1537.     break;
  1538.  
  1539. /*                                                                                      *\
  1540.  * Syntax: WM_SETUPPROGRAMTYPE, USHORT SessionType, NULL                                *
  1541. \*                                                                                      */
  1542. case WM_SETUPPROGRAMTYPE:
  1543. /*                                                                                      *\
  1544.  * Adjust the Program Type radiobuttons by selecting only the button corresponding to   *
  1545.  * the SessionType.                                                                     *
  1546. \*                                                                                      */
  1547.     {                                   /* Radiobutton IDs sorted */
  1548.     USHORT      usSessionTypeRBs[]={PIRB_SHELL, PIRB_OS2FULLSCREEN, PIRB_OS2WINDOW,
  1549.                                     PIRB_PM, PIRB_DOSFULLSCREEN, PIRB_DOSWINDOW,
  1550.                                     PIRB_WPSOBJECT};
  1551.                                         /* Corresponding session type IDs sorted */
  1552.     USHORT      usSessionTypeIDs[]={PROG_DEFAULT    , PROG_FULLSCREEN   , PROG_WINDOWABLEVIO,
  1553.                                     PROG_PM         , PROG_VDM          , PROG_WINDOWEDVDM,
  1554.                                     PROG_WPSOBJECT};
  1555.                                         /* Radiobutton IDs sorted */
  1556.     USHORT      usWINOS2TypeRBs[]={PIRB_WINREAL, PIRB_WINSTANDARD, PIRB_WIN386ENHANCED,
  1557.                                    PIRB_WINSTANDARD, PIRB_WIN386ENHANCED};
  1558.                                         /* Corresponding session type IDs sorted */
  1559.     USHORT      usWINOS2TypeIDs[]={PROG_WINDOW_REAL, PROG_WINDOW_PROT, PROG_31_ENH,
  1560.                                    PROG_31_STDSEAMLESSCOMMON, PROG_31_ENHSEAMLESSCOMMON};
  1561.                                         /* Child windows that change with allowance of environment specification */
  1562.     USHORT      usChild2Environment[]={PIMLE_ENVIRONMENT};
  1563.     USHORT      usSessionType=SHORT1FROMMP(mp1);
  1564.     USHORT      usTemp;
  1565.                                         /* Loop for all buttons and deselect all but the
  1566.                                            one specified in usSessionType */
  1567.     for(usTemp=0; usTemp<=(sizeof(usSessionTypeRBs)/sizeof(USHORT)); usTemp++)
  1568.         if(usSessionTypeIDs[usTemp]==usSessionType)
  1569.             {
  1570.             WinSendDlgItemMsg(          /* Send message to one Program Type radiobutton,
  1571.                                            this only updates the radiobutton but doesn't
  1572.                                            create a WM_CONTROL message */
  1573.                                         /* Handle of dialog window */
  1574.                 nbPINotebookPage[PAGE_2].hwndNBPage,
  1575.                                         /* Program type radiobutton */
  1576.                 usSessionTypeRBs[usTemp],
  1577.                 BM_SETCHECK,            /* Set it to pressed */
  1578.                 MPFROMSHORT(TRUE),
  1579.                 (MPARAM)NULL);
  1580.                                         /* Simulate the click to update the dialog's child windows */
  1581.             WinSendMsg(nbPINotebookPage[PAGE_2].hwndNBPage, WM_CONTROL,
  1582.                 MPFROM2SHORT(usSessionTypeRBs[usTemp], BN_CLICKED), (MPARAM)NULL);
  1583.             }
  1584.     if((usSessionType!=PROG_PM) && (usSessionType!=PROG_FULLSCREEN) && (usSessionType!=PROG_WINDOWABLEVIO))
  1585.                                         /* Disable and show Environment entryfield */
  1586.         DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  1587.             sizeof(usChild2Environment)/sizeof(USHORT), WS_DISABLED);
  1588.     switch(usSessionType)
  1589.     {                                   /* WIN-OS2 sessions must be treated similar */
  1590.     case PROG_WINDOW_REAL:
  1591.     case PROG_WINDOW_PROT:
  1592.     case PROG_31_ENH:
  1593.                                         /* For seamless separate WIN-OS2 session check PICB_WINSEPARATE */
  1594.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndNBPage, PICB_WINSEPARATE, BM_SETCHECK,
  1595.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1596.     case PROG_31_STDSEAMLESSCOMMON:
  1597.     case PROG_31_ENHSEAMLESSCOMMON:
  1598.                                         /* Loop for all WIN-OS2 buttons and deselect all but the
  1599.                                            one specified in usSessionType */
  1600.         for(usTemp=0; usTemp<=(sizeof(usWINOS2TypeRBs)/sizeof(USHORT)); usTemp++)
  1601.             if(usWINOS2TypeIDs[usTemp]==usSessionType)
  1602.                 WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndNBPage, usWINOS2TypeRBs[usTemp],
  1603.                     BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  1604.                                         /* Check WIN-OS2 session type radiobutton */
  1605.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WINOS2, BM_SETCHECK,
  1606.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1607.         WinSendMsg(nbPINotebookPage[PAGE_2].hwndNBPage, WM_CONTROL,
  1608.             MPFROM2SHORT(PIRB_WINOS2, BN_CLICKED), (MPARAM)NULL);
  1609.         break;
  1610.  
  1611.     default:
  1612.                                         /* Check WIN standard session radiobutton, because at
  1613.                                            least one should be checked, if no WIN-OS2 session
  1614.                                            type is selected */
  1615.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndNBPage, PICB_WINSEPARATE, BM_SETCHECK,
  1616.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1617.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndNBPage, PIRB_WINSTANDARD, BM_SETCHECK,
  1618.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1619.         break;
  1620.     }
  1621.                                         /* Hide DOS Settings window until the application
  1622.                                            type is DOS Window or DOS Fullscreen */
  1623.     if(usSessionType==PROG_WPSOBJECT)
  1624.                                         /* Only default Style is allowed */
  1625.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndNBPage, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  1626.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1627.     }
  1628.     break;
  1629.  
  1630. /*                                                                                      *\
  1631.  * Syntax: WM_SETUPSIZEPOSITION, (BOOL bWriteable), (BOOL bInsert)                      *
  1632. \*                                                                                      */
  1633. case WM_SETUPSIZEPOSITION:
  1634. /*                                                                                      *\
  1635.  * The 4 entryfields for the Size&Position are a bit more complicated to handle.        *
  1636.  * First we set the entryfields to a size of 4 and the default values are read from the *
  1637.  * SessionData structure. Only if Size&Position is selected, this 4 entryfields are not *
  1638.  * readonly. Flag bWriteable is true if Size&Position is selected, Flag bInsert is true *
  1639.  * if we write the values the first time.                                               *
  1640. \*                                                                                      */
  1641.     {
  1642.     USHORT      usSizePositionEFs[]={PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  1643.     BOOL        bWriteable=SHORT1FROMMP(mp1);
  1644.     BOOL        bInsert=SHORT1FROMMP(mp2);
  1645.     USHORT      usTemp;
  1646.     SHORT       *psSizePosition;
  1647.     UCHAR       ucBuffer[6];            /* Prefix, 4 numbers, \0 */
  1648.  
  1649.                                         /* Get first Size & Position value */
  1650.     psSizePosition=&pSessionData->InitXPos;
  1651.                                         /* Loop for all entryfields and enable and insert
  1652.                                            values into them */
  1653.     for(usTemp=0; usTemp<=(sizeof(usSizePositionEFs)/sizeof(USHORT));
  1654.         usTemp++, psSizePosition++)
  1655.         {
  1656.         if(bWriteable==TRUE)            /* If writeable, enable them */
  1657.             WinSendDlgItemMsg(          /* Send message to entryfield */
  1658.                 nbPINotebookPage[PAGE_3].hwndNBPage,
  1659.                                         /* Program size & position entryfield */
  1660.                 usSizePositionEFs[usTemp],
  1661.                 EM_SETREADONLY,         /* Set to enable read/write */
  1662.                 MPFROMSHORT(FALSE),
  1663.                 (MPARAM)NULL);
  1664.         else
  1665.             WinSendDlgItemMsg(          /* Send message to entryfield */
  1666.                 nbPINotebookPage[PAGE_3].hwndNBPage,
  1667.                                         /* Program size & position entryfield */
  1668.                 usSizePositionEFs[usTemp],
  1669.                 EM_SETREADONLY,         /* Set to enable readonly */
  1670.                 MPFROMSHORT(TRUE),
  1671.                 (MPARAM)NULL);
  1672.         if(bInsert==TRUE)               /* If initializing, insert them */
  1673.             {
  1674.             WinSendDlgItemMsg(          /* Send message to dialog window */
  1675.                                         /* Handle of dialog window */
  1676.                 nbPINotebookPage[PAGE_3].hwndNBPage,
  1677.                                         /* Program size: X entryfield */
  1678.                 usSizePositionEFs[usTemp],
  1679.                 EM_SETTEXTLIMIT,        /* Set text limit to 5 */
  1680.                 MPFROMSHORT(5),
  1681.                 (MPARAM)NULL);
  1682.             WinSetDlgItemText(          /* Set a text string in a dialog item */
  1683.                 nbPINotebookPage[PAGE_3].hwndNBPage,
  1684.                 usSizePositionEFs[usTemp],
  1685.                 (CHAR *)_itoa(*psSizePosition, ucBuffer, 10));
  1686.             }
  1687.         }
  1688.     }
  1689.     break;
  1690.  
  1691. /*                                                                                      *\
  1692.  * Syntax: WM_SETUPHOTKEY, NULL, NULL                                                   *
  1693. \*                                                                                      */
  1694. case WM_SETUPHOTKEY:
  1695. /*                                                                                      *\
  1696.  * Load Program Title into entryfield, fill the combobox and fill the MLE containing    *
  1697.  * the current window list.                                                             *
  1698. \*                                                                                      */
  1699.     {
  1700.     ULONG       ulTemp1, ulTemp2;
  1701.     PSWBLOCK    pSwBlock;               /* Pointer to window list */
  1702.                                         /* Used to add \n to switchlist entries */
  1703.     UCHAR       ucSwName[MAXNAMEL+1];
  1704.  
  1705.                                         /* Set Window Title entryfield */
  1706.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PIEF_SESSIONTITLE,
  1707.         EM_SETTEXTLIMIT, MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  1708.     WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndNBPage, PIEF_SESSIONTITLE, pSessionData->WindowTitle);
  1709.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY,
  1710.         EM_SETTEXTLIMIT, MPFROMSHORT(sizeof(" ")), (MPARAM)NULL);
  1711.                                         /* Set SWP control radiobuttons */
  1712.     if(pSessionData->SwpFlag & SWP_MAXIMIZE)
  1713.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_WSMAXIMIZED, BM_SETCHECK,
  1714.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1715.     else if(pSessionData->SwpFlag & SWP_RESTORE)
  1716.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_WSRESTORE, BM_SETCHECK,
  1717.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1718.     else
  1719.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PIRB_NONE, BM_SETCHECK,
  1720.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1721.     if(pSessionData->SwpFlag & SWP_NOMOVE)
  1722.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PICB_DONTMOVE, BM_SETCHECK,
  1723.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1724.     if(pSessionData->KeyData.usCh!=0)   /* Check if a hotkey is defined */
  1725.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PICB_HOTKEYENABLED, BM_SETCHECK,
  1726.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  1727.                                         /* Simulate the click to update the dialog's child windows */
  1728.     WinSendMsg(nbPINotebookPage[PAGE_2].hwndNBPage, WM_CONTROL,
  1729.         MPFROM2SHORT(PICB_HOTKEYENABLED, BN_CLICKED), (MPARAM)NULL);
  1730.                                         /* Simulate the click to update the PIRB_CTRL or
  1731.                                            PIRB_ALT radiobutton */
  1732.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, (pSessionData->KeyData.usFlags==KC_CTRL) ? PIRB_CTRL : PIRB_ALT,
  1733.         BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  1734.                                         /* This message invalidates pSessionData->KeyData !!! */
  1735.     WinSendMsg(nbPINotebookPage[PAGE_4].hwndNBPage, WM_CONTROL,
  1736.         MPFROM2SHORT((pSessionData->KeyData.usFlags==KC_CTRL) ? PIRB_CTRL : PIRB_ALT, BN_CLICKED), (MPARAM)NULL);
  1737.                                         /* Query the number of entries in window list */
  1738.     ulTemp1=WinQuerySwitchList(pHP->habPc2, NULL, 0);
  1739.                                         /* Allocate space for window list */
  1740.     pSwBlock=(PSWBLOCK)malloc(ulTemp1=(ulTemp1*sizeof(SWENTRY)+sizeof(HSWITCH)));
  1741.                                         /* Load window list into LB */
  1742.     ulTemp1=WinQuerySwitchList(pHP->habPc2, pSwBlock, ulTemp1);
  1743.     for(ulTemp2=0; ulTemp2<=ulTemp1; ulTemp2++)
  1744.         {
  1745.         if(pSwBlock->aswentry[ulTemp2].swctl.fbJump==SWL_JUMPABLE)
  1746.             {
  1747.             strcpy(ucSwName, pSwBlock->aswentry[ulTemp2].swctl.szSwtitle);
  1748.             WinSendDlgItemMsg(
  1749.                 nbPINotebookPage[PAGE_4].hwndNBPage, PILB_WINDOWLIST,
  1750.                 LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(ucSwName));
  1751.             }
  1752.         }
  1753.     free(pSwBlock);                     /* Free allocated space for window list */
  1754.     }
  1755.     break;
  1756.  
  1757. /*                                                                                      *\
  1758.  * Syntax: WM_SETUPPROGRAMPRIORITY, (USHORT PriorityClass), (SHORT PriorityDelta)       *                                           *
  1759. \*                                                                                      */
  1760. case WM_SETUPPROGRAMPRIORITY:
  1761. /*                                                                                      *\
  1762.  * To enable all Priorities to be selected, the checkbox PICB_CHILDPROCESS must be      *
  1763.  * checked and is either checked by the user or by the Priority not equal to the        *
  1764.  * default selection of PRTYC_NOCHANGE and 0.                                           *
  1765. \*                                                                                      */
  1766.     {
  1767.     USHORT      usPriorityClassRBs[]={PIRB_NOCHANGE, PIRB_IDLETIME, PIRB_REGULAR,
  1768.                                       PIRB_TIMECRITICAL, PIRB_FOREGROUNDSERVER};
  1769.     USHORT      usPriorityClass=SHORT1FROMMP(mp1);
  1770.     UCHAR       ucBuffer[4];
  1771.  
  1772.     sPriorityDelta=SHORT1FROMMP(mp2);
  1773.                                         /* Check priority class radiobutton by simulation a
  1774.                                            radiobutton click */
  1775.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, usPriorityClassRBs[usPriorityClass],
  1776.         BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  1777.     WinSendMsg(nbPINotebookPage[PAGE_5].hwndNBPage, WM_CONTROL,
  1778.         MPFROM2SHORT(usPriorityClass, BN_CLICKED), (MPARAM)NULL);
  1779.                                         /* Set priority delta entryfield and scrollbar */
  1780.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA,
  1781.         EM_SETTEXTLIMIT, MPFROMSHORT(3), (MPARAM)NULL);
  1782.     WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA,
  1783.         (CHAR *)_itoa(sPriorityDelta, ucBuffer, 10));
  1784.                                         /* Set scollbar size and position. Caution
  1785.                                            a scrollbar is 0 based */
  1786.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIHSB_PRIORITYDELTA,
  1787.         SBM_SETTHUMBSIZE, MPFROM2SHORT(1, PRTYD_MAXIMUM), (MPARAM)NULL);
  1788.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIHSB_PRIORITYDELTA,
  1789.         SBM_SETSCROLLBAR, MPFROMSHORT(sPriorityDelta),
  1790.         MPFROM2SHORT(0, PRTYD_MAXIMUM));
  1791.     }
  1792.     break;
  1793.  
  1794. case WM_HSCROLL:                        /* Messages generated by horizontal scrollbars */
  1795. /*                                                                                      *\
  1796.  * This message is generated when a horizontal scrollbar is manipulated. See if it is   *
  1797.  * our scrollbar PIHSB_PRIORITYDELTA and process.                                       *
  1798. \*                                                                                      */
  1799.     if(SHORT1FROMMP(mp1)==PIHSB_PRIORITYDELTA)
  1800.         {
  1801.         UCHAR       ucBuffer[4];
  1802.         SHORT       sSliderPosition=SHORT1FROMMP(mp2);;
  1803.  
  1804.         switch(SHORT2FROMMP(mp2))
  1805.         {                               /* All messages contain the new slider position,
  1806.                                            so just use this value to change the priority
  1807.                                            delta entryfield value */
  1808.         case SB_LINELEFT:
  1809.             sPriorityDelta--;
  1810.             break;
  1811.  
  1812.         case SB_PAGELEFT:
  1813.             sPriorityDelta-=10;
  1814.             break;
  1815.  
  1816.         case SB_LINERIGHT:
  1817.             sPriorityDelta++;
  1818.             break;
  1819.  
  1820.         case SB_PAGERIGHT:
  1821.             sPriorityDelta+=10;
  1822.             break;
  1823.  
  1824.         case SB_SLIDERTRACK:
  1825.         case SB_SLIDERPOSITION:
  1826.             sPriorityDelta=sSliderPosition;
  1827.             break;
  1828.         }
  1829.         if(sPriorityDelta<PRTYC_NOCHANGE) sPriorityDelta=PRTYC_NOCHANGE;
  1830.         if(sPriorityDelta>PRTYD_MAXIMUM) sPriorityDelta=PRTYD_MAXIMUM;
  1831.         WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA,
  1832.             (CHAR *)_itoa(sPriorityDelta, ucBuffer, 10));
  1833.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIHSB_PRIORITYDELTA,
  1834.             SBM_SETPOS, MPFROMSHORT(sPriorityDelta), (MPARAM)NULL);
  1835.         }
  1836.     break;
  1837.  
  1838. case WM_CONTROL:                        /* Test for autoradio buttons pressed */
  1839. /*                                                                                      *\
  1840.  * The Size & Position radiobutton must be checked every time it is selected, because   *
  1841.  * only if it is selected, the user may have write access to X, Y, Size X and Size Y    *
  1842.  * entryfields, otherwise they are read only. The DOS Setting MLE is only visible if a  *
  1843.  * DOS window or fullscreen application type is selected.                               *
  1844. \*                                                                                      */
  1845.     {                                   /* Child windows that change with the
  1846.                                            PIRB_WPSOBJECT radiobutton */
  1847.     USHORT      usChild2WPSObject[]={PIRB_MAXIMIZED, PIRB_MINIMIZED, PICB_SIZEPOSITION,
  1848.                                      PICB_INVISIBLE, PICB_NOAUTOCLOSE, PICB_BACKGROUND,
  1849.                                      PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  1850.                                         /* Disable the following if Size & Position is disabled */
  1851.     USHORT      usChild2SizeEnable[]={PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  1852.                                         /* Hide the following for WPS Objects */
  1853.     USHORT      usChild2WPSObjectHide[]={PIEF_DIRECTORY, PIEF_PARAMETERS};
  1854.                                         /* Child window that changes with a DOS radiobutton */
  1855.     USHORT      usChild2DOS[]={PIMLE_DOSSETTINGS, PIPB_SETTINGSDLG};
  1856.     USHORT      usChild2DOSP5[]={PIRB_IDLETIME, PIRB_REGULAR, PIRB_TIMECRITICAL, PIRB_FOREGROUNDSERVER,
  1857.                                  PIEF_PRIORITYDELTA, PIHSB_PRIORITYDELTA};
  1858.                                         /* Child windows that change with a WIN-OS2 radiobutton */
  1859.     USHORT      usChild2WINOS2[]={PIRB_WINREAL, PIRB_WINSTANDARD, PIRB_WIN386ENHANCED, PICB_WINSEPARATE};
  1860.                                         /* Child windows that change witch Hotkey enable checkbox */
  1861.     USHORT      usChild2HotKey[]={PIRB_NONE, PIRB_WSMAXIMIZED, PIRB_WSRESTORE, PIRB_CTRL,
  1862.                                   PIRB_ALT, PICBX_HOTKEY};
  1863.                                         /* Child windows that change with allowance of environment specification */
  1864.     USHORT      usChild2Environment[]={PIMLE_ENVIRONMENT};
  1865.  
  1866.                                         /* Was button class window clicked or double-clicked ? */
  1867.     if((SHORT2FROMMP(mp1)==BN_CLICKED) || (SHORT2FROMMP(mp1)==BN_DBLCLICKED))
  1868.         switch(SHORT1FROMMP(mp1))
  1869.         {
  1870.         case PICB_SIZEPOSITION:         /* Program type: User defined size & position */
  1871.             if((BOOL)WinSendDlgItemMsg( /* Send message to Size & Position radiobutton */
  1872.                                         /* Handle of dialog window */
  1873.                 nbPINotebookPage[PAGE_3].hwndNBPage,
  1874.                 PICB_SIZEPOSITION,      /* Program size: Size & Position radiobutton */
  1875.                 BM_QUERYCHECK,          /* Query the state */
  1876.                 (MPARAM)NULL,
  1877.                 (MPARAM)NULL)==TRUE)
  1878.                 {
  1879.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  1880.                     MPFROMSHORT(TRUE), MPFROMSHORT(FALSE));
  1881.                 DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2SizeEnable,
  1882.                     sizeof(usChild2SizeEnable)/sizeof(USHORT), WS_VISIBLE);
  1883.                 }
  1884.             else
  1885.                 {
  1886.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  1887.                     MPFROMSHORT(FALSE), MPFROMSHORT(FALSE));
  1888.                                         /* Enable and show Size & Position child windows */
  1889.                                         /* Disable and show Size & Position child windows */
  1890.                 DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2SizeEnable,
  1891.                     sizeof(usChild2SizeEnable)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1892.                 }
  1893.             break;
  1894.  
  1895.         case PICB_HOTKEYENABLED:        /* Enable or disable and show Hotkey controls depending
  1896.                                            on Hotkey Enable checkbox */
  1897.             if((BOOL)WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage,
  1898.                 PICB_HOTKEYENABLED, BM_QUERYCHECK, (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  1899.                 {
  1900.                 DisableDialogItem(nbPINotebookPage[PAGE_4].hwndNBPage, usChild2HotKey,
  1901.                     sizeof(usChild2HotKey)/sizeof(USHORT), WS_VISIBLE);
  1902.                 }
  1903.             else
  1904.                 {
  1905.                 DisableDialogItem(nbPINotebookPage[PAGE_4].hwndNBPage, usChild2HotKey,
  1906.                     sizeof(usChild2HotKey)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1907.                 }
  1908.             break;
  1909.  
  1910.         case PIRB_CTRL:
  1911.         case PIRB_ALT:                  /* Set hotkey MLE corresponding to radiobuttons */
  1912.             {
  1913.             KEYDATA     *pKeyDataIndex;
  1914.             UCHAR       ucBuffer[]="0"; /* String to be inserted into combobox */
  1915.             ULONG       ulTemp1;
  1916.             BOOL        bFirst=TRUE;    /* False if first key was inserted */
  1917.  
  1918.                                         /* Point to Hotkey control structure */
  1919.             pKeyDataIndex=pHP->pKeyData;
  1920.                                         /* If a key is defined set it into entryfield of
  1921.                                            combobox. Clear it afterwards that user selections
  1922.                                            to the PIRB_CTRL or PIRB_ALT insert the first free
  1923.                                            available key */
  1924.             if(pSessionData->KeyData.usCh!=0)
  1925.                 {
  1926.                 ucBuffer[0]=(UCHAR)pSessionData->KeyData.usCh;
  1927.                 WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY, ucBuffer);
  1928.                 bFirst=FALSE;
  1929.                 }
  1930.             else bFirst=TRUE;
  1931.                                         /* Delete current entries in hotkey combobox */
  1932.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY,
  1933.                 LM_DELETEALL, (MPARAM)NULL, (MPARAM)NULL);
  1934.                                         /* Loop for all keys and set unused into combobox */
  1935.             for(ulTemp1=0; ulTemp1<KEYDATACOUNT; pKeyDataIndex++, ulTemp1++)
  1936.                 {
  1937.                 ucBuffer[0]=(UCHAR)pKeyDataIndex->usCh;
  1938.                                         /* Clear current key because it may not selected again */
  1939.                 if((pKeyDataIndex->usCh==pSessionData->KeyData.usCh) &&
  1940.                     ((SHORT1FROMMP(mp1)==PIRB_CTRL ? KC_CTRL : KC_ALT)==pKeyDataIndex->usFlags))
  1941.                     {
  1942.                     pSessionData->KeyData.usCh=0;
  1943.                     pKeyDataIndex->bUsed=FALSE;
  1944.                     pKeyDataIndex->pMenuData=NULL;
  1945.                     }
  1946.                                         /* Load unused key of current type into combobox */
  1947.                 if((pKeyDataIndex->bUsed==FALSE) &&
  1948.                     ((SHORT1FROMMP(mp1)==PIRB_CTRL ? KC_CTRL : KC_ALT)==pKeyDataIndex->usFlags))
  1949.                     {
  1950.                     if(bFirst==TRUE)
  1951.                         {               /* The first valid hotkey is loaded into entryfield part
  1952.                                            of combobox */
  1953.                         WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY, ucBuffer);
  1954.                         bFirst=FALSE;
  1955.                         }
  1956.                     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PICBX_HOTKEY,
  1957.                         LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  1958.                     }
  1959.                 }
  1960.             }
  1961.             break;
  1962.  
  1963.         case PIRB_DOSFULLSCREEN:
  1964.         case PIRB_DOSWINDOW:
  1965.                                         /* Disable and show Environment entryfield */
  1966.             DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  1967.                 sizeof(usChild2Environment)/sizeof(USHORT), WS_DISABLED);
  1968.                                         /* Enable and show WPSObject child windows */
  1969.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2WPSObjectHide,
  1970.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  1971.                                         /* Enable and show DOS child windows */
  1972.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2DOS,
  1973.                 sizeof(usChild2DOS)/sizeof(USHORT), WS_VISIBLE);
  1974.                                         /* Set default priority class radiobutton by simulation a
  1975.                                            radiobutton click */
  1976.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_NOCHANGE,
  1977.                 BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  1978.             WinSendMsg(nbPINotebookPage[PAGE_5].hwndNBPage, WM_CONTROL,
  1979.                 MPFROM2SHORT(PIRB_NOCHANGE, BN_CLICKED), (MPARAM)NULL);
  1980.                                         /* Set default priority delta entryfield and scrollbar */
  1981.             WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA, "0");
  1982.                                         /* Set default scollbar position */
  1983.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIHSB_PRIORITYDELTA,
  1984.                 SBM_SETPOS, MPFROMSHORT(0), (MPARAM)NULL);
  1985.                                         /* Now disable non-default priority settings */
  1986.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndNBPage, usChild2DOSP5,
  1987.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1988.                                         /* Enable and show WPSObject child windows */
  1989.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2WPSObject,
  1990.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  1991.                                         /* Disable and show WIN-OS2 child windows */
  1992.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndNBPage, usChild2WINOS2,
  1993.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1994.             break;
  1995.  
  1996.         case PIRB_OS2FULLSCREEN:
  1997.         case PIRB_OS2WINDOW:
  1998.         case PIRB_PM:
  1999.         case PIRB_SHELL:
  2000.                                         /* For all OS/2 and PM sessions enable environment specification */
  2001.             if(SHORT1FROMMP(mp1)==PIRB_SHELL)
  2002.                                         /* Disable and show Environment entryfield */
  2003.                 DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  2004.                     sizeof(usChild2Environment)/sizeof(USHORT), WS_DISABLED);
  2005.             else
  2006.                 DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  2007.                     sizeof(usChild2Environment)/sizeof(USHORT), WS_VISIBLE );
  2008.                                         /* Enable and hide DOS child windows */
  2009.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2DOS,
  2010.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  2011.                                         /* Now enable priority settings */
  2012.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndNBPage, usChild2DOSP5,
  2013.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE);
  2014.                                         /* Enable and show WPSObject child windows */
  2015.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2WPSObject,
  2016.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  2017.                                         /* Enable and show WPSObject child windows */
  2018.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2WPSObjectHide,
  2019.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  2020.                                         /* Disable and show WIN-OS2 child windows */
  2021.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndNBPage, usChild2WINOS2,
  2022.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2023.             break;
  2024.  
  2025.         case PIRB_WPSOBJECT:
  2026.                                         /* Disable and show Environment entryfield */
  2027.             DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  2028.                 sizeof(usChild2Environment)/sizeof(USHORT), WS_DISABLED);
  2029.                                         /* Disable and show WPSObject child windows */
  2030.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2WPSObject,
  2031.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2032.                                         /* Enable and hide DOS child windows */
  2033.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2DOS,
  2034.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  2035.                                         /* Now disable non-default priority settings */
  2036.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndNBPage, usChild2DOSP5,
  2037.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2038.                                         /* Hide but enable WPSObject child windows */
  2039.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2WPSObjectHide,
  2040.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), 0);
  2041.                                         /* Disable and show WIN-OS2 child windows */
  2042.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndNBPage, usChild2WINOS2,
  2043.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2044.                                         /* Only default Style is allowed */
  2045.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndNBPage, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  2046.                 MPFROMSHORT(TRUE), (MPARAM)NULL);
  2047.                                         /* Size and Position is not allowed */
  2048.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndNBPage, PICB_SIZEPOSITION, BM_SETCHECK,
  2049.                 MPFROMSHORT(FALSE), (MPARAM)NULL);
  2050.                                         /* Load empty text in not required fields */
  2051.             WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_DIRECTORY, "");
  2052.             WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndNBPage, PIEF_PARAMETERS, "");
  2053.             break;
  2054.  
  2055.         case PIRB_WINOS2:
  2056.                                         /* Disable and show Environment entryfield */
  2057.             DisableDialogItem(nbPINotebookPage[PAGE_6].hwndNBPage, usChild2Environment,
  2058.                 sizeof(usChild2Environment)/sizeof(USHORT), WS_DISABLED);
  2059.                                         /* Enable and show WPSObject child windows, because
  2060.                                            a WIN-OS2 session is a specail DOS session */
  2061.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2WPSObjectHide,
  2062.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  2063.                                         /* Enable and show DOS child windows, hide priority */
  2064.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndNBPage, usChild2DOS,
  2065.                 sizeof(usChild2DOS)/sizeof(USHORT), WS_VISIBLE);
  2066.                                         /* Set default priority class radiobutton by simulation a
  2067.                                            radiobutton click */
  2068.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIRB_NOCHANGE,
  2069.                 BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  2070.             WinSendMsg(nbPINotebookPage[PAGE_5].hwndNBPage, WM_CONTROL,
  2071.                 MPFROM2SHORT(PIRB_NOCHANGE, BN_CLICKED), (MPARAM)NULL);
  2072.                                         /* Set default priority delta entryfield and scrollbar */
  2073.             WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndNBPage, PIEF_PRIORITYDELTA, "0");
  2074.                                         /* Set default scollbar position */
  2075.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndNBPage, PIHSB_PRIORITYDELTA,
  2076.                 SBM_SETPOS, MPFROMSHORT(0), (MPARAM)NULL);
  2077.                                         /* Now disable non-default priority settings */
  2078.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndNBPage, usChild2DOSP5,
  2079.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2080.                                         /* Enable and show WPSObject child windows */
  2081.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndNBPage, usChild2WPSObject,
  2082.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  2083.                                         /* Enable and show WIN-OS2 child windows */
  2084.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndNBPage, usChild2WINOS2,
  2085.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE);
  2086.             break;
  2087.         }
  2088.     if(SHORT1FROMMP(mp1)==PILB_WINDOWLIST)
  2089.         switch(SHORT2FROMMP(mp1))       /* Events of Window List listbox */
  2090.         {
  2091.         case LN_ENTER:                  /* When selected, copy selected item into session title entryfield */
  2092.             {
  2093.             UCHAR   ucTemp[MAXNAMEL];
  2094.             USHORT  usSelection;
  2095.  
  2096.             usSelection=(USHORT)WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PILB_WINDOWLIST,
  2097.                 LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  2098.                                         /* Copy selected item */
  2099.             if(usSelection!=(USHORT)LIT_NONE)
  2100.                 {
  2101.                 WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndNBPage, PILB_WINDOWLIST,
  2102.                     LM_QUERYITEMTEXT, MPFROM2SHORT(usSelection, MAXNAMEL), MPFROMP(ucTemp));
  2103.                 WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndNBPage, PIEF_SESSIONTITLE, ucTemp);
  2104.                 }
  2105.             break;
  2106.             }
  2107.         }
  2108.     }
  2109.     break;
  2110.  
  2111. case WM_COMMAND:                        /* Button pressed */
  2112.     switch(SHORT1FROMMP(mp1))
  2113.     {
  2114.     case DID_CANCEL:                    /* Cancel key pressed on a dialog within a notebook page,
  2115.                                            ignore it within dialog but post it to parent dialog */
  2116.         {
  2117.         HWND    hwndNotebook;
  2118.  
  2119.                                         /* Query parent of current notebook page window,
  2120.                                            Query parent of this, which is the notebook */
  2121.         hwndNotebook=WinQueryWindow(WinQueryWindow(hwndDlg, QW_PARENT), QW_PARENT);
  2122.                                         /* Post CANCEL to parent of notebook which is the dialog */
  2123.         WinPostMsg(WinQueryWindow(hwndNotebook, QW_PARENT), WM_COMMAND,
  2124.             MPFROMSHORT(DID_CANCEL), MPFROM2SHORT(CMDSRC_ACCELERATOR, FALSE));
  2125.                                         /* We have handled the message */
  2126.         return((MRESULT)TRUE);
  2127.         }
  2128.  
  2129.     case PIPB_WINFILEDLG:               /* Locate file by standard file dialog */
  2130. /*                                                                                      *\
  2131.  * The user selected the File Find pushbutton to get the standard file dialog to find   *
  2132.  * the program he wants to install.                                                     *
  2133. \*                                                                                      */
  2134.         {
  2135.         FILEDLG fdFileDlg;              /* Standard file dialog control */
  2136.         HWND    hwndFileDlg;            /* Handle of standard file dialog */
  2137.  
  2138.                                         /* Clear out structure */
  2139.         memset(&fdFileDlg, 0, sizeof(FILEDLG));
  2140.                                         /* Structure size */
  2141.         fdFileDlg.cbSize=sizeof(FILEDLG);
  2142.                                         /* FDS_* flags */
  2143.         fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG | FDS_PRELOAD_VOLINFO;
  2144.                                         /* Dialog title string */
  2145.         fdFileDlg.pszTitle="PC/2 File Search";
  2146.                                         /* Initial path, filename or file filter */
  2147.         strcpy(fdFileDlg.szFullFile, "C:\\*");
  2148.                                         /* Open the standard file dialog ...*/
  2149.         hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwndDlg, &fdFileDlg);
  2150.         if(hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
  2151.             {
  2152.                                         /* Load the values of the standard file dialog to
  2153.                                            the corresponding entryfield in the Program
  2154.                                            installation dialog. It is a file not an object. */
  2155.             UCHAR   ucBuffer[20];
  2156.  
  2157.             WinQueryWindowText(WinWindowFromID(hwndDlg, PIEF_PROGRAMTITLE),
  2158.                 sizeof(ucBuffer), ucBuffer);
  2159.             if(!strcmp(ucBuffer, "Insert here please"))
  2160.                 WinSetWindowText(WinWindowFromID(hwndDlg, PIEF_PROGRAMTITLE), "");
  2161.             InstallFilename2Dialog(hwndDlg, fdFileDlg.szFullFile, FALSE);
  2162.             }
  2163.         }
  2164.         break;
  2165.  
  2166.     case PIPB_SETTINGSDLG:              /* Locate file by standard file dialog */
  2167. /*                                                                                      *\
  2168.  * The user selected the Settings pushbutton to get the standard OS/2 DOS settings      *
  2169.  * dialog. Special thanks to Monte Copeland for giving me a sample source code on how   *
  2170.  * using this built-in but undocumented OS/2 feature.                                   *
  2171. \*                                                                                      */
  2172.         {
  2173.                                         /* PMVDMP.DLL export @11 WINDOWS32PROPERTYDIALOG */
  2174.         PFFUNCPTR4  *pWindows32PropertyDialog;
  2175.         HMODULE     hDllPMVDMP;         /* PMVDMP.DLL module handle */
  2176.         UCHAR       ucBuffer[80];       /* Buffer for possible return codes from DLL loading */
  2177.         UCHAR       *pucSettingsIn;
  2178.         UCHAR       *pucSettingsOut;
  2179.         USHORT      usLength, usWinMode=0;
  2180.         ULONG       ulLength;
  2181.  
  2182.                                         /* Get ordinal 11 function pointer of PMVDMP.DLL which
  2183.                                            contains the DOS settings dialog */
  2184.         if((DosLoadModule(ucBuffer, sizeof(ucBuffer)-1, "PMVDMP", &hDllPMVDMP)!=NO_ERROR) ||
  2185.             (DosQueryProcAddr(hDllPMVDMP, 11, NULL, (PFN *)(&pWindows32PropertyDialog))
  2186.             !=NO_ERROR))
  2187.             {                           /* An error occured */
  2188.             pWindows32PropertyDialog=NULL;
  2189.             DosFreeModule(hDllPMVDMP);  /* Free DLL reference */
  2190.             USR_ERR(pHP->hwndFrame, HELP_PC2INI, MB_INFORMATION|MB_OK|MB_MOVEABLE|MB_DEFBUTTON1,
  2191.                 "Can't load VDM support from PMVDMP.DLL. You have either not installed the "\
  2192.                 "DOS support of OS/2, or your DOS support is not setup correctly. The DOS settings "\
  2193.                 "dialog of PC/2 will not be available until you correct this problem - continuing...");
  2194.             }
  2195.                                         /* Without VDM support installed DOS support is not available */
  2196.         if(pWindows32PropertyDialog==NULL) break;
  2197.                                         /* Get current listbox data length */
  2198.         ulLength=(ULONG)WinQueryWindowTextLength(WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage,
  2199.             PIMLE_DOSSETTINGS));
  2200.         pucSettingsOut=malloc(ulLength);
  2201.         WinQueryWindowText(             /* Query data entered in DOS Settings MLE */
  2202.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndNBPage, PIMLE_DOSSETTINGS),
  2203.             ulLength, pucSettingsOut);
  2204.                                         /* Convert to format used by WINDOWS32PROPERTYDIALOG */
  2205.         pucSettingsIn=ImportDosSettings(pucSettingsOut, &ulLength, FALSE);
  2206.                                         /* Free data read from DOS Settings MLE */
  2207.         free(pucSettingsOut);
  2208.                                         /* Call DOS Settings dialog by passing DOS Settings MLE
  2209.                                            data \0\0 terminated and expect a \0\0 terminated
  2210.                                            shared memory address containing the user changes */
  2211.         pucSettingsOut=pWindows32PropertyDialog(
  2212.             hwndDlg,                    /* Parent window handle ? */
  2213.             hwndDlg,                    /* Owner window handle ? */
  2214.             pucSettingsIn,              /* In-buffer containing DOS settings */
  2215.             (USHORT)ulLength,           /* Length of in-buffer containing DOS settings */
  2216.             &usLength,                  /* Length of out-buffer containing modified DOS settings,
  2217.                                            allocated by DosAllocateMem() */
  2218.             &usWinMode);                /* 0 if no WIN-OS2 settings are included
  2219.                                            ? if WIN-OS2 settings are included */
  2220.         if(pucSettingsIn) free(pucSettingsIn);
  2221.         if(pucSettingsOut!=NULL)        /* NULL returned when Cancel was pressed */
  2222.             {
  2223.             ulLength=(ULONG)usLength;
  2224.                                         /* Convert to format used PC/2 configuration file and
  2225.                                            Program Installation dialog */
  2226.             pucSettingsIn=ImportDosSettings(pucSettingsOut, &ulLength, TRUE);
  2227.             DosFreeMem(pucSettingsOut);
  2228.                                         /* Insert data in DOS Settings MLE */
  2229.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_1].hwndNBPage, PIMLE_DOSSETTINGS,
  2230.                 MLM_DELETE, MPFROMLONG(0), MPFROMLONG(LENDOSSETTINGS));
  2231.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_1].hwndNBPage, PIMLE_DOSSETTINGS,
  2232.                 MLM_INSERT, MPFROMP(pucSettingsIn), (MPARAM)NULL);
  2233.             free(pucSettingsIn);
  2234.             }
  2235.         DosFreeModule(hDllPMVDMP);      /* Free DLL reference */
  2236.         }
  2237.         break;
  2238.  
  2239.     default:
  2240.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2241.     }
  2242.     break;
  2243.  
  2244.                                         /* Call function instead of subclassing notebook page 1
  2245.                                            notebook dialogs */
  2246. case DM_DRAGOVER:
  2247. case DM_DROP:
  2248.                                         /* Only on first page allow Drag'n Drop */
  2249.     if(hwndDlg==nbPINotebookPage[PAGE_1].hwndNBPage)
  2250.         return(PI_SubclassedDialogProcedure(hwndDlg, msg, mp1, mp2));
  2251.     break;
  2252.  
  2253. default:                                /* Default window procedure must be called */
  2254.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2255. }
  2256. return((MRESULT)FALSE);                 /* We have handled the message */
  2257. }
  2258.  
  2259. /*--------------------------------------------------------------------------------------*\
  2260.  * This dialog procedure handles the Drag'n Drop support - Program Installation dialog. *
  2261.  * Req:                                                                                 *
  2262.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  2263. \*--------------------------------------------------------------------------------------*/
  2264. MRESULT  EXPENTRY PI_SubclassedDialogProcedure(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  2265. {
  2266. PDRAGINFO       pDraginfo;              /* Pointer to DRAGINFO structure */
  2267. PDRAGITEM       pDragitem;              /* Pointer to DRAGITEM structure */
  2268.  
  2269. switch(msg)
  2270. {
  2271. /*                                                                                      *\
  2272.  * Allow objects to be dropped on dialog box to add first dragitem as an application.   *
  2273. \*                                                                                      */
  2274. case DM_DRAGOVER:
  2275.     pDraginfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  2276.                                         /* Access the structure */
  2277.     if(DrgAccessDraginfo(pDraginfo)==FALSE) break;
  2278.                                         /* Get the first itemp of the item(s) dragged
  2279.                                            onto dialog window */
  2280.     pDragitem = DrgQueryDragitemPtr(pDraginfo, 0);
  2281.     if((pDraginfo->cditem==1) &&
  2282.         ((DrgVerifyRMF(pDragitem, "DRM_OS2FILE", "DRF_UNKNOWN")) ||
  2283.         (DrgVerifyRMF(pDragitem, "DRM_OS2FILE", "DRF_TEXT"))))
  2284.                                         /* Allow drop of undefined operation onto dialog window */
  2285.         return(MPFROM2SHORT(DOR_DROP, DO_UNKNOWN));
  2286.                                         /* Don't allow dropping of more than one or unknown item */
  2287.     return(MPFROM2SHORT(DOR_NODROP, DO_UNKNOWN));
  2288.  
  2289. case DM_DROP:
  2290.     {
  2291.     UCHAR       ucBuffer[256];
  2292.     UCHAR       ucFileName[256];
  2293.     UCHAR       ucObjectType[256];
  2294.     UCHAR       *pucBuffer;
  2295.  
  2296.     pDraginfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  2297.                                         /* Access the structure */
  2298.     if(DrgAccessDraginfo(pDraginfo)==FALSE) break;
  2299.                                         /* Get the first itemp of the item(s) dragged
  2300.                                            onto dialog window */
  2301.     pDragitem = DrgQueryDragitemPtr(pDraginfo, 0);
  2302.                                         /* Query the rendering format */
  2303.     DrgQueryStrName(pDragitem->hstrRMF, sizeof(ucObjectType), ucObjectType);
  2304.                                         /* Scan for an file object */
  2305.     if((DrgVerifyRMF(pDragitem, "DRM_OS2FILE", "DRF_UNKNOWN")) ||
  2306.         (DrgVerifyRMF(pDragitem, "DRM_OS2FILE", "DRF_TEXT")))
  2307.         {                               /* It is an application to get path and filename */
  2308.                                         /* Query path (container) */
  2309.         DrgQueryStrName(pDragitem->hstrContainerName, sizeof(ucBuffer), ucBuffer);
  2310.                                         /* Position to \0 of path */
  2311.         pucBuffer=ucBuffer+strlen(ucBuffer);
  2312.                                         /* Query filename and append it to path */
  2313.         DrgQueryStrName(pDragitem->hstrSourceName, sizeof(ucBuffer)-strlen(pucBuffer), pucBuffer);
  2314.                                         /* Copy filename of file object dropped and uppercase it */
  2315.         strcpy(ucFileName, ucBuffer);
  2316.         strupr(ucFileName);
  2317.                                         /* If it is an executable or batch file PC/2 can start it
  2318.                                            otherwise it must be an WPS object like a filder */
  2319.         if(strstr(ucFileName, "EXE") || strstr(ucFileName, "COM") ||
  2320.             strstr(ucFileName, "CMD") || strstr(ucFileName, "BAT"))
  2321.                                         /* Now change the entryfields to the dropped object
  2322.                                            which is not a WPS object */
  2323.             InstallFilename2Dialog(hwnd, ucBuffer, FALSE);
  2324.         else
  2325.                                         /* Now change the entryfields to the dropped object
  2326.                                            which is a WPS object */
  2327.             InstallFilename2Dialog(hwnd, ucBuffer, TRUE);
  2328.         break;
  2329.         }
  2330.     }
  2331.     break;
  2332. }
  2333. return((MRESULT)FALSE);                 /* We have handled the message */
  2334. }
  2335.  
  2336. /*--------------------------------------------------------------------------------------*\
  2337.  * This dialog procedure handles the PC/2 - Menu Installation dialog.                   *
  2338.  * Req:                                                                                 *
  2339.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  2340.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  2341.  *                      is used to start the session.                                   *
  2342. \*--------------------------------------------------------------------------------------*/
  2343. MRESULT  EXPENTRY MI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2344. {
  2345. static SESSIONDATA   *pSessionData;     /* Pointer to SESSIONDATA structure for current instance */
  2346.  
  2347. switch(msg)
  2348. {
  2349. case WM_INITDLG:
  2350.     {
  2351.     SWP         swp;
  2352.  
  2353.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2354.                                         /* Access parameters passed */
  2355.     pSessionData=(SESSIONDATA *)PVOIDFROMMP(mp2);
  2356.     WinQueryWindowPos(                  /* Query position of dialog window */
  2357.         hwndDlg,                        /* Handle of dialog window */
  2358.         &swp);                          /* Fill with position */
  2359.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  2360.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  2361.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  2362.     swp.cx=swp.cy=0;
  2363.     swp.hwndInsertBehind=NULLHANDLE;
  2364.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  2365. /*                                                                                      *\
  2366.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  2367.  * default number of 63.                                                                *
  2368. \*                                                                                      */
  2369.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  2370.         hwndDlg,                        /* Handle of dialog window */
  2371.         MIEF_MENUTITLE,                 /* Program submenu title entryfield */
  2372.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  2373.         MPFROMSHORT(MAXNAMEL),
  2374.         (MPARAM)NULL);                  /* No additional parameter */
  2375.     WinSetDlgItemText(                  /* Set text of title entryfield */
  2376.         hwndDlg, MIEF_MENUTITLE, pSessionData->PgmTitle);
  2377.     break;
  2378.     }
  2379.  
  2380. case WM_HELP:                           /* Help pressed */
  2381.     if(pHP->hwndHelp!=NULLHANDLE)
  2382.         WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  2383.             MPFROMSHORT(MIID_MENUDIALOG), HM_RESOURCEID);
  2384.     break;
  2385.  
  2386. case WM_COMMAND:                        /* Button pressed */
  2387.     switch(SHORT1FROMMP(mp1))
  2388.     {
  2389.     case DID_OK:                        /* Enter key pressed */
  2390. /*                                                                                      *\
  2391.  * Query the Submenu Title and copy it to the corresponding entry in the StartSession   *
  2392.  * structure.                                                                           *
  2393. \*                                                                                      */
  2394.         WinQueryWindowText(             /* Query data entered in Submenu title entry */
  2395.             WinWindowFromID(hwndDlg, MIEF_MENUTITLE),
  2396.                                         /* into SessionData structure */
  2397.             sizeof(pSessionData->PgmTitle),
  2398.             pSessionData->PgmTitle);
  2399.                                         /* Dialog terminated with DID_OK */
  2400.         WinDismissDlg(hwndDlg, DID_OK);
  2401.         break;
  2402.  
  2403.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  2404.                                         /* Dialog terminated with DID_CANCEL */
  2405.         WinDismissDlg(hwndDlg, DID_CANCEL);
  2406.         break;
  2407.  
  2408.     default:
  2409.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2410.     }
  2411.     break;
  2412.  
  2413. default:                                /* Default window procedure must be called */
  2414.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2415. }
  2416. return((MRESULT)FALSE);                 /* We have handled the message */
  2417. }
  2418.  
  2419.  
  2420. /*--------------------------------------------------------------------------------------*\
  2421.  * This dialog procedure handles the PC/2 - Control Addition dialog.                    *
  2422.  * Req:                                                                                 *
  2423.  *      SessionData ... a structure of type SESSIONDATA where the control style         *
  2424.  *                      selected in the dialog is entered. If DID_OK is pressed this    *
  2425.  *                      structure is used to add the control entries to the Popup-menu. *
  2426. \*--------------------------------------------------------------------------------------*/
  2427. MRESULT  EXPENTRY MD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2428. {
  2429. static SESSIONDATA   *pSessionData;     /* Pointer to SESSIONDATA structure for current instance */
  2430.  
  2431. switch(msg)
  2432. {
  2433. case WM_INITDLG:
  2434.     {
  2435.     SWP         swp;
  2436.     ULONG       ulid;
  2437.     ULONG       ulidCopy;
  2438.                                         /* Sort radiobuttons as the Menuentry IDs are
  2439.                                            sorted in PC2.h as ID_* */
  2440.     USHORT      usChild2Control[]={MDRB_CTRL_CONFIGMENU, MDRB_CTRL_ABOUT, MDRB_CTRL_EXIT,
  2441.                                    MDRB_CTRL_SHUTDOWN, MDRB_CTRL_CONFIGDESKTOP,
  2442.                                    MDRB_CTRL_HELP, MDRB_CTRL_SPOOLER};
  2443.  
  2444.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2445.                                         /* Access parameters passed */
  2446.     pSessionData=(SESSIONDATA *)PVOIDFROMMP(mp2);
  2447.     WinQueryWindowPos(                  /* Query position of dialog window */
  2448.         hwndDlg,                        /* Handle of dialog window */
  2449.         &swp);                          /* Fill with position */
  2450.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  2451.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  2452.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  2453.     swp.cx=swp.cy=0;
  2454.     swp.hwndInsertBehind=NULLHANDLE;
  2455.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  2456.     for(ulid=0; ulid<=(sizeof(usChild2Control)/sizeof(usChild2Control[0])); ulid++)
  2457.         {
  2458.         ulidCopy=ulid+ID_CONFIGDIALOG;  /* Copy because SearchItem() changes passed ID */
  2459.                                         /* Search in the linked list for entry ulid */
  2460.         if((SearchItem(pHP->pPopupMenu, &ulidCopy))!=NULL)
  2461.                                         /* Disable and show 1 Control child windows
  2462.                                            according to its id if id was found */
  2463.             DisableDialogItem(hwndDlg, &usChild2Control[ulid],
  2464.                 1, WS_VISIBLE | WS_DISABLED);
  2465.         }
  2466.                                         /* Select Separator RB because this is the only
  2467.                                            one selectable all times */
  2468.     WinSendDlgItemMsg(hwndDlg, MDRB_CTRL_SEPARATOR, BM_SETCHECK,
  2469.         MPFROMSHORT(TRUE), (MPARAM)NULL);
  2470.     break;
  2471.     }
  2472.  
  2473. case WM_HELP:                           /* Help pressed */
  2474.     if(pHP->hwndHelp!=NULLHANDLE)
  2475.         WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  2476.             MPFROMSHORT(MDID_CONTROLDIALOG), HM_RESOURCEID);
  2477.     break;
  2478.  
  2479. case WM_COMMAND:                        /* Button pressed */
  2480.     switch(SHORT1FROMMP(mp1))
  2481.     {
  2482.     case DID_OK:                        /* Enter key pressed */
  2483. /*                                                                                      *\
  2484.  * Query through all radiabuttons for the control style the user has selected. Write    *
  2485.  * the corresponding string name into the  pSessionData->PgmTitle field.                *
  2486. \*                                                                                      */
  2487.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_CONFIGMENU))
  2488.             strcpy(pSessionData->PgmTitle, CTRL_CONFIGMENU);
  2489.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_CONFIGDESKTOP))
  2490.             strcpy(pSessionData->PgmTitle, CTRL_CONFIGDESKTOP);
  2491.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_ABOUT))
  2492.             strcpy(pSessionData->PgmTitle, CTRL_ABOUT);
  2493.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_SHUTDOWN))
  2494.             strcpy(pSessionData->PgmTitle, CTRL_SHUTDOWN);
  2495.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_HELP))
  2496.             strcpy(pSessionData->PgmTitle, CTRL_HELP);
  2497.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_EXIT))
  2498.             strcpy(pSessionData->PgmTitle, CTRL_EXIT);
  2499.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_SPOOLER))
  2500.             strcpy(pSessionData->PgmTitle, CTRL_SPOOLER);
  2501.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_SEPARATOR))
  2502.             strcpy(pSessionData->PgmTitle, CTRL_SEPARATOR);
  2503.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_BRKSEPARATOR))
  2504.             strcpy(pSessionData->PgmTitle, CTRL_BREAKSEPARATOR);
  2505.                                         /* Dialog terminated with DID_OK */
  2506.         WinDismissDlg(hwndDlg, DID_OK);
  2507.         break;
  2508.  
  2509.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  2510.                                         /* Dialog terminated with DID_CANCEL */
  2511.         WinDismissDlg(hwndDlg, DID_CANCEL);
  2512.         break;
  2513.  
  2514.     default:
  2515.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2516.     }
  2517.     break;
  2518.  
  2519. default:                                /* Default window procedure must be called */
  2520.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2521. }
  2522. return((MRESULT)FALSE);                 /* We have handled the message */
  2523. }
  2524.  
  2525.  
  2526. /*--------------------------------------------------------------------------------------*\
  2527.  * This dialog procedure handles the PC/2 - ShutDown OS/2 dialog.                       *
  2528.  * Req: none                                                                            *
  2529. \*--------------------------------------------------------------------------------------*/
  2530. MRESULT  EXPENTRY SD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2531. {
  2532. switch(msg)
  2533. {
  2534. case WM_INITDLG:
  2535.     {
  2536.     SWP         swp;
  2537.  
  2538.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2539.     WinQueryWindowPos(                  /* Query position of dialog window */
  2540.         hwndDlg,                        /* Handle of dialog window */
  2541.         &swp);                          /* Fill with position */
  2542.                                         /* Load before ShutDown info */
  2543.     WinSetDlgItemText(hwndDlg, SDID_SHUTDOWNMESSAGE,
  2544.         "All disk activity will be suspended. After all disk activity has been stopped, "\
  2545.         "it is safe to power off or reset your system.");
  2546.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  2547.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  2548.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  2549.     swp.cx=swp.cy=0;
  2550.     swp.hwndInsertBehind=NULLHANDLE;
  2551.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  2552.     WinPostMsg(hwndDlg, WM_SHUTDOWN, NULL, NULL);
  2553.     break;
  2554.     }
  2555.  
  2556. /*                                                                                      *\
  2557.  * Syntax: WM_SHUTDOWN, NULL, NULL                                                      *
  2558. \*                                                                                      */
  2559. case WM_SHUTDOWN:
  2560. /*                                                                                      *\
  2561.  * Wait for 1 seconds and then shut down OS/2.                                          *
  2562. \*                                                                                      */
  2563.     DosSleep(01000);
  2564.     DosShutdown(0);
  2565.                                         /* Load after ShutDown info */
  2566.     WinSetDlgItemText(hwndDlg, SDID_SHUTDOWNMESSAGE,
  2567.         "All disk activity has been stopped. It is now safe to power off or reset "\
  2568.         "your system. ");
  2569.     break;
  2570.  
  2571. case WM_COMMAND:                        /* Eat up keys to avoid dismission of dialog with
  2572.                                            ESC key */
  2573.     return((MRESULT)TRUE);
  2574.  
  2575. default:                                /* Default window procedure must be called */
  2576.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2577. }
  2578. return((MRESULT)FALSE);                 /* We have handled the message */
  2579. }
  2580.  
  2581. /*--------------------------------------------------------------------------------------*\
  2582.  * This dialog procedure handles the PC/2 - Startup Parameters dialog.                  *
  2583.  * Req: *PgmInputs .....A pointer to a string of commandline params of an application   *
  2584.  *                      via mp2                                                         *
  2585. \*--------------------------------------------------------------------------------------*/
  2586. MRESULT  EXPENTRY SU_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2587. {
  2588. static COMMANDLINEPARAMS        *pCLPParams;
  2589.  
  2590. switch(msg)
  2591. {
  2592. case WM_INITDLG:
  2593.     {
  2594.     UCHAR       ucBuffer[EF_SIZE255+1];
  2595.  
  2596.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2597.     pCLPParams=PVOIDFROMMP(mp2);
  2598. /*                                                                                      *\
  2599.  * Load text from CLPParams into the dialog box text fields, and set the text limit of  *
  2600.  * the entryfield to 127.                                                               *
  2601. \*                                                                                      */
  2602.                                         /* Program to be started information text field */
  2603.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPPROGRAM, pCLPParams->ucPgmTitle);
  2604.     sprintf(ucBuffer, "%s[...] %s", pCLPParams->ucPBefore, pCLPParams->ucPAfter);
  2605.                                         /* User information text field */
  2606.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPINFO, pCLPParams->ucPUser);
  2607.                                         /* Current parameters text field */
  2608.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPPARAMETERS, ucBuffer);
  2609.     WinSendDlgItemMsg(hwndDlg, SUEF_STARTUPPARAMETERS, EM_SETTEXTLIMIT,
  2610.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  2611.     break;
  2612.     }
  2613.  
  2614. case WM_HELP:                           /* Help pressed */
  2615.     if(pHP->hwndHelp!=NULLHANDLE)
  2616.         WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  2617.             MPFROMSHORT(SUID_STARTUPDIALOG), HM_RESOURCEID);
  2618.     break;
  2619.  
  2620. case WM_COMMAND:                        /* Button pressed */
  2621.     switch(SHORT1FROMMP(mp1))
  2622.     {
  2623.     case DID_OK:                        /* Enter key pressed */
  2624.         WinQueryWindowText(WinWindowFromID(hwndDlg, SUEF_STARTUPPARAMETERS),
  2625.             sizeof(pCLPParams->ucPUser), pCLPParams->ucPUser);
  2626.                                         /* Dialog terminated with DID_OK */
  2627.         WinDismissDlg(hwndDlg, DID_OK);
  2628.         break;
  2629.  
  2630.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  2631.                                         /* Dialog terminated with DID_CANCEL */
  2632.         WinDismissDlg(hwndDlg, DID_CANCEL);
  2633.         break;
  2634.  
  2635.     default:
  2636.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2637.     }
  2638.     break;
  2639.  
  2640. default:                                /* Default window procedure must be called */
  2641.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2642. }
  2643. return((MRESULT)FALSE);                 /* We have handled the message */
  2644. }
  2645.  
  2646. /*--------------------------------------------------------------------------------------*\
  2647.  * This dialog procedure handles the PC/2 - Resort dialog.                              *
  2648. \*--------------------------------------------------------------------------------------*/
  2649. MRESULT  EXPENTRY RD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2650. {
  2651. static MENUDATA *pSortedMenuData;       /* Pointer to the first element of the resorted
  2652.                                            linked list */
  2653. static MENUDATA *pParentMenuData;       /* Menuitem, which current level is a child of */
  2654. static USHORT   usChild2InitPBs[]={DID_OK};
  2655. static USHORT   usChild2MovePBs[]={DID_CANCEL};
  2656. static USHORT   usChild2OKPBs[]={RDPB_MOVE};
  2657. static BOOL     bFirstMove;
  2658. switch(msg)
  2659. {
  2660. case WM_INITDLG:
  2661.     {
  2662.     SWP         swp;
  2663.     MENUDATA    *pMDSource;             /* Pointer withing the current linked list */
  2664.  
  2665.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2666.     WinQueryWindowPos(                  /* Query position of dialog window */
  2667.         hwndDlg,                        /* Handle of dialog window */
  2668.         &swp);                          /* Fill with position */
  2669.     swp.fl=SWP_MOVE;                    /* Center dialog window */
  2670.     swp.x=(pHP->swpScreen.cx-swp.cx)>>1;
  2671.     swp.y=(pHP->swpScreen.cy-swp.cy)>>1;
  2672.     swp.cx=swp.cy=0;
  2673.     swp.hwndInsertBehind=NULLHANDLE;
  2674.     WinSetMultWindowPos(pHP->habPc2, &swp, 1);
  2675. /*                                                                                      *\
  2676.  * Disable OK pushbutton, until all items have been moved. Get the first element of the *
  2677.  * current level of the linked list which will be resorted. Add all Menuitems of the    *
  2678.  * current level of the linked list to the source listbox. Save the parent Menuitem,    *
  2679.  * from where the current level is a child of.                                          *
  2680. \*                                                                                      */
  2681.     bFirstMove=FALSE;                   /* We didn't make any sort before */
  2682.     pSortedMenuData=NULL;               /* Pointer of resorted linked list points to a non
  2683.                                            available Menuitem */
  2684.                                         /* Disable and show OK pushbutton */
  2685.     DisableDialogItem(hwndDlg, usChild2InitPBs,
  2686.         sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2687.                                         /* Is current level is the root of all levels ? */
  2688.     if(pHP->pMenuData==pHP->pPopupMenu)
  2689.         pParentMenuData=NULL;           /* Yes, then parent Menuitem is NULL */
  2690.     else                                /* No, then get parent Menuitem */
  2691.         pParentMenuData=pHP->pMenuData->Back;
  2692.                                         /* Get first element of linked list */
  2693.     pMDSource=pHP->pMenuData;
  2694.     do                                  /* Add current level of Menuitems to the source listbox */
  2695.     {
  2696.         if(pMDSource->Item==ENTRYSUBMENU) /* It is a Submenu */
  2697.             {
  2698.             UCHAR       ucBuffer[MAXNAMEL+4];
  2699.                                         /* Add >> for a Submenu */
  2700.             sprintf(ucBuffer, "%s >>", pMDSource->PgmTitle);
  2701.                                         /* Insert Menuitem at the end of the listbox */
  2702.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  2703.                 MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  2704.             }
  2705.                                         /* It's a Menuitem or Control */
  2706.         if((pMDSource->Item==ENTRYMENUITEM) || (pMDSource->Item==ENTRYCONTROL))
  2707.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  2708.                 MPFROMSHORT(LIT_END), MPFROMP(pMDSource->PgmTitle));
  2709.                                         /* It may also be an empty entry, but then we
  2710.                                            ignore it, because it must be filled with
  2711.                                            Menuitem or Submenu data first */
  2712.         if(pMDSource->Next!=NULL)       /* Get through linked list without diving into
  2713.                                            Submenus */
  2714.                 pMDSource=pMDSource->Next;
  2715.         else break;                     /* We're at the end of the linked list */
  2716.     } while(TRUE);
  2717.     break;
  2718.     }
  2719.  
  2720. case WM_HELP:                           /* Help pressed */
  2721.     if(pHP->hwndHelp!=NULLHANDLE)
  2722.         WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
  2723.             MPFROMSHORT(RDID_RESORTDIALOG), HM_RESOURCEID);
  2724.     break;
  2725.  
  2726. case WM_CONTROL:
  2727.     switch(SHORT1FROMMP(mp1))
  2728.     {
  2729.     case RDLB_SOURCEMENU:
  2730.         if(SHORT2FROMMP(mp1)==LN_ENTER)
  2731.                                         /* Simulate clicking the Resort pushbutton */
  2732.             WinPostMsg(hwndDlg, WM_COMMAND,
  2733.                 MPFROM2SHORT(RDPB_MOVE, CMDSRC_PUSHBUTTON), MPFROMSHORT(TRUE));
  2734.         break;
  2735.     }
  2736.     break;
  2737.  
  2738. case WM_COMMAND:                        /* Button pressed */
  2739.     switch(SHORT1FROMMP(mp1))
  2740.     {
  2741.     case RDPB_MOVE:                     /* Move pushbutton */
  2742.         {
  2743.         MENUDATA        *pMDSource;     /* Walk through current linked list */
  2744.         MENUDATA        *pMDSourceNext; /* Next menuentry after pMDSource */
  2745.                                         /* Walk through destination linked list */
  2746.         MENUDATA        *pMDDestination;
  2747.         SHORT           sCount;
  2748.         SHORT           sCountSave;
  2749.  
  2750. /*                                                                                      *\
  2751.  * Now get the selected Menuitem of the source listbox, delete it from the listbox. If  *
  2752.  * the source listbox is now empty, reenable the OK pushbutton again.                   *
  2753. \*                                                                                      */
  2754.                                         /* Query the selected Menuitem from the source listbox */
  2755.         sCountSave=sCount=(SHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYSELECTION,
  2756.             MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  2757.         while(sCount!=LIT_NONE)
  2758.             {
  2759.                                         /* Point to the first element of the linked list */
  2760.             pMDSource=pHP->pMenuData;
  2761.             for( ; sCount>0; sCount--)  /* Walk through the linked list to the selected
  2762.                                            item */
  2763.                 pMDSource=pMDSource->Next;
  2764.                                         /* Point to the first element of the resorted linked list */
  2765.             pMDDestination=pSortedMenuData;
  2766.             if(pMDDestination!=NULL)    /* Walk through the resorted linked list to the
  2767.                                            last Menuitem, if there's at least one element */
  2768.                 for( ; pMDDestination->Next!=NULL; /* pMDDestination=pMDDestination->Next */)
  2769.                     pMDDestination=pMDDestination->Next;
  2770.                                         /* If the current menuitem is followed by a break
  2771.                                            separator, also resort the break separator because
  2772.                                            is is just a style of the current menuitem */
  2773.                                         /* A break separator can't be resorted, because
  2774.                                            it is only a style flag of the previous menu entry
  2775.                                            and is therefor moved only together with the
  2776.                                            menu entry */
  2777.             if(!strcmp(pMDSource->PgmTitle, CTRL_BREAKSEPARATOR))
  2778.                 {
  2779.                 return((MRESULT)FALSE);
  2780.                 }
  2781.             {
  2782.             UCHAR   ucBuffer[MAXNAMEL+4];
  2783.             SHORT   usItems;
  2784.                                         /* Query the text of the selected Menuitem from the
  2785.                                            source listbox */
  2786.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMTEXT,
  2787.                 MPFROM2SHORT(sCountSave, sizeof(ucBuffer)), MPFROMP(ucBuffer));
  2788.                                         /* Delete the selected Menuitem from the source listbox */
  2789.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_DELETEITEM,
  2790.                 MPFROMSHORT(sCountSave), (MPARAM)NULL);
  2791.                                         /* Insert the text of the selected Menuitem into the
  2792.                                            destination listbox */
  2793.             WinSendDlgItemMsg(hwndDlg, RDLB_DESTINATIONMENU, LM_INSERTITEM,
  2794.                 MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  2795.                                         /* Query the number of Menuitems from the source
  2796.                                            listbox */
  2797.             usItems=(USHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMCOUNT,
  2798.                 (MPARAM)NULL, (MPARAM)NULL);
  2799. /*                                                                                      *\
  2800.  * For the first resort operation, disable the Cancel pushbutton, after all items have  *
  2801.  * been resorted enable OK pushbutton.                                                  *
  2802. \*                                                                                      */
  2803.             if(bFirstMove==FALSE)       /* After the first move operation, disable the
  2804.                                            Cancel pushbutton */
  2805.                 {
  2806.                 bFirstMove=TRUE;        /* We make now the first move */
  2807.                 DisableDialogItem(hwndDlg, usChild2MovePBs,
  2808.                     sizeof(usChild2MovePBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2809.                 }
  2810.             if(usItems==0)              /* If now more items left, reenable OK pushbutton
  2811.                                            and disable Resort pushbutton */
  2812.                 {
  2813.                 DisableDialogItem(hwndDlg, usChild2InitPBs,
  2814.                     sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE);
  2815.                 DisableDialogItem(hwndDlg, usChild2OKPBs,
  2816.                     sizeof(usChild2OKPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2817.                 }
  2818.             }
  2819. /*                                                                                      *\
  2820.  * Now remove the selected Menuitem from the current linked list, by updating the       *
  2821.  * pointers according to previous or following Menuitems.                               *
  2822. \*                                                                                      */
  2823.                                         /* Get menu entry that follows pMDSource */
  2824.             if(((pMDSourceNext=pMDSource->Next)!=NULL) &&
  2825.                 (!strcmp(pMDSource->Next->PgmTitle, CTRL_BREAKSEPARATOR)))
  2826.                 {                       /* Same as above */
  2827.                 UCHAR   ucBuffer[MAXNAMEL+4];
  2828.                 SHORT   usItems;
  2829.     
  2830.                                         /* Get menu entry that follows (pMDSource->Break Separator) */
  2831.                 pMDSourceNext=pMDSource->Next->Next;
  2832.                 WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMTEXT,
  2833.                     MPFROM2SHORT(sCountSave, sizeof(ucBuffer)), MPFROMP(ucBuffer));
  2834.                 WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_DELETEITEM,
  2835.                     MPFROMSHORT(sCountSave), (MPARAM)NULL);
  2836.                 WinSendDlgItemMsg(hwndDlg, RDLB_DESTINATIONMENU, LM_INSERTITEM,
  2837.                     MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  2838.                 usItems=(USHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMCOUNT,
  2839.                     (MPARAM)NULL, (MPARAM)NULL);
  2840.                 if(usItems==0)
  2841.                     {
  2842.                     DisableDialogItem(hwndDlg, usChild2InitPBs,
  2843.                         sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE);
  2844.                     DisableDialogItem(hwndDlg, usChild2OKPBs,
  2845.                         sizeof(usChild2OKPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  2846.                     }
  2847.                 }
  2848.             else
  2849.                                         /* Point to menu entry following current selection */
  2850.                 pMDSourceNext=pMDSource->Next;
  2851. /*                                                                                      *\
  2852.  * Now update the Popup-Menu, by moving the selected Menuitem. Break separators are     *
  2853.  * moved automatically by moving 2 menu entries, because they are only style flags of   *
  2854.  * a functional menu entry.                                                             *
  2855. \*                                                                                      */
  2856.             if((pMDDestination==NULL) && (pParentMenuData==NULL))
  2857.                 SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pHP->pPopupMenu));
  2858.             if((pMDDestination==NULL) && (pParentMenuData!=NULL))
  2859.                 SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pParentMenuData));
  2860.             if(pMDDestination!=NULL)
  2861.                 SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pMDDestination));
  2862.             if((pMDSource->Back!=NULL) && (pMDSourceNext!=NULL))
  2863.                 {                       /* Current element follows another and is followed
  2864.                                            by another element, so simple remove it by
  2865.                                            updating the pointers. Be carefull if the
  2866.                                            parent element is a Submenu where the current
  2867.                                            level is a leaf of. */
  2868.                 if((pMDSource->Back)->Submenu==pMDSource)
  2869.                     {
  2870.                     (pMDSource->Back)->Submenu=pMDSourceNext;
  2871.                     pHP->pMenuData=pMDSourceNext;
  2872.                     }
  2873.                 else
  2874.                     (pMDSource->Back)->Next=pMDSourceNext;
  2875.                 (pMDSourceNext)->Back=pMDSource->Back;
  2876.                 }
  2877.             if((pMDSource->Back!=NULL) && (pMDSourceNext==NULL))
  2878.                 {                       /* Current element follows another but is the last
  2879.                                            one of the current linked list.  Be carefull if
  2880.                                            the parent element is a Submenu where the current
  2881.                                            level is a leaf of. */
  2882.                                         /* Next element of course is NULL */
  2883.                 if((pMDSource->Back)->Submenu==pMDSource)
  2884.                     {
  2885.                     (pMDSource->Back)->Submenu=pMDSourceNext;
  2886.                     pHP->pMenuData=pMDSourceNext;
  2887.                     }
  2888.                 else
  2889.                     (pMDSource->Back)->Next=pMDSourceNext;
  2890.                 }
  2891.             if((pMDSource->Back==NULL) && (pMDSourceNext!=NULL))
  2892.                 {                       /* Current element is the first one of the complete
  2893.                                            linked list, but is followed by another */
  2894.                 (pMDSourceNext)->Back=NULL;
  2895.                 pHP->pMenuData=pMDSourceNext;
  2896.                 pHP->pPopupMenu=pMDSourceNext;
  2897.                 }
  2898.             if((pMDSource->Back==NULL) && (pMDSourceNext==NULL))
  2899.                 {                       /* Current element is the first one of the complete
  2900.                                            linked list, and isn't followed by another */
  2901.                 pHP->pPopupMenu=pSortedMenuData;
  2902.                 pHP->pMenuData=pHP->pPopupMenu;
  2903.                 }
  2904. /*                                                                                      *\
  2905.  * Now add the deleted Menuitem at the end of the resorted linked list, by updating the *
  2906.  * pointer of the last element to point to the deleted one.                             *
  2907. \*                                                                                      */
  2908.             if(pMDDestination==NULL)
  2909.                 {                       /* If the resorted linked list is empty, add
  2910.                                            deleted element and update pointers */
  2911.                 pSortedMenuData=pMDSource;
  2912.                 pMDDestination=pMDSource;
  2913.                 pMDDestination->Next=NULL;
  2914.                 pMDDestination->Back=NULL;
  2915.                 }
  2916.             else
  2917.                 {                       /* If the resorted linked list isn't empty, add
  2918.                                            deleted element at the end and update pointers */
  2919.                 pMDDestination->Next=pMDSource;
  2920.                 pMDSource->Back=pMDDestination;
  2921.                 if((pMDSource->Next!=NULL) && (!strcmp(pMDSource->Next->PgmTitle, CTRL_BREAKSEPARATOR)))
  2922.                     pMDSource->Next->Next=NULL;
  2923.                 else
  2924.                     pMDSource->Next=NULL;
  2925.                 }
  2926.                                 /* Query the next selected Menuitem from the source listbox */
  2927.             sCountSave=sCount=(SHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYSELECTION,
  2928.                 MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  2929.             }
  2930.         }
  2931.         return((MRESULT)FALSE);         /* We don't want to close the dialog by breaking
  2932.                                            out of the switch statement */
  2933.  
  2934.     case DID_OK:                        /* Enter key pressed */
  2935. /*                                                                                      *\
  2936.  * Now replace the current linked list, which is empty as all Menuitems have been re-   *
  2937.  * moved, with the resorted linked list.                                                *
  2938. \*                                                                                      */
  2939.         if(pParentMenuData==NULL)
  2940.             {                           /* If the root of the complete linked list has been
  2941.                                            resorted, update the root pointers */
  2942.             pHP->pPopupMenu=pSortedMenuData;
  2943.             pHP->pMenuData=pHP->pPopupMenu;
  2944.             }
  2945.         else
  2946.             {                           /* If the current level has a parent Menuitem, a
  2947.                                            Submenu of course, update the current level pointers */
  2948.             pHP->pMenuData=pSortedMenuData;
  2949.             pSortedMenuData->Back=pParentMenuData;
  2950.             pParentMenuData->Submenu=pHP->pMenuData;
  2951.             }
  2952.                                         /* Dialog terminated with DID_OK */
  2953.         WinDismissDlg(hwndDlg, DID_OK);
  2954.         break;
  2955.  
  2956.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  2957.         if(bFirstMove==TRUE)            /* If first resort operation was made, don't dismiss
  2958.                                            dialog */
  2959.             return((MRESULT)TRUE);
  2960.         else
  2961.                                         /* Dialog terminated with DID_CANCEL */
  2962.             WinDismissDlg(hwndDlg, DID_CANCEL);
  2963.         break;
  2964.  
  2965.     default:
  2966.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2967.     }
  2968.     break;
  2969.  
  2970. default:                                /* Default window procedure must be called */
  2971.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2972. }
  2973. return((MRESULT)FALSE);                 /* We have handled the message */
  2974. }
  2975.  
  2976.  
  2977.