Index: trunk/src/helpers/procstat.c
===================================================================
--- trunk/src/helpers/procstat.c	(revision 217)
+++ trunk/src/helpers/procstat.c	(revision 218)
@@ -558,4 +558,5 @@
  *
  *@@added V0.9.2 (2000-03-05) [umoeller]
+ *@@changed V0.9.21 (2002-08-16) [pr]: optimized
  */
 
@@ -566,5 +567,4 @@
     while (pProcThis && pProcThis->ulRecType == 1)
     {
-        int i;
         PQTHREAD32  t = pProcThis->pThreads;
         PQMODULE32  pModule;
@@ -589,9 +589,5 @@
         // the next process block comes after the
         // threads
-        for (i=0;
-             i < pProcThis->usThreadCount;
-             i++,t++)
-            ;
-
+        t += pProcThis->usThreadCount;
         pProcThis = (PQPROCESS32)t;
     }
@@ -607,4 +603,5 @@
  *
  *@@added V0.9.21 (2002-08-12) [umoeller]
+ *@@changed V0.9.21 (2002-08-16) [pr]: optimized
  */
 
@@ -615,5 +612,4 @@
     while (pProcThis && pProcThis->ulRecType == 1)
     {
-        int i;
         PQTHREAD32  t = pProcThis->pThreads;
 
@@ -624,9 +620,5 @@
         // the next process block comes after the
         // threads
-        for (i=0;
-             i < pProcThis->usThreadCount;
-             i++, t++)
-            ;
-
+        t += pProcThis->usThreadCount;
         pProcThis = (PQPROCESS32)t;
     }
Index: trunk/src/helpers/winh.c
===================================================================
--- trunk/src/helpers/winh.c	(revision 217)
+++ trunk/src/helpers/winh.c	(revision 218)
@@ -283,5 +283,5 @@
 ULONG winhQueryWindowStyle(HWND hwnd)
 {
-    return (WinQueryWindowULong(hwnd, QWL_STYLE));
+    return WinQueryWindowULong(hwnd, QWL_STYLE);
 }
 
@@ -296,5 +296,5 @@
                        BOOL fEnable)
 {
-    return (WinEnableWindow(WinWindowFromID(hwndDlg, id), fEnable));
+    return WinEnableWindow(WinWindowFromID(hwndDlg, id), fEnable);
 }
 
@@ -308,5 +308,5 @@
                           SHORT id)
 {
-    return (WinIsWindowEnabled(WinWindowFromID(hwndDlg, id)));
+    return WinIsWindowEnabled(WinWindowFromID(hwndDlg, id));
 }
 
@@ -334,8 +334,8 @@
                        PMENUITEM pmi)           // out: MENUITEM data
 {
-    return ((BOOL)WinSendMsg(hwndMenu,
-                             MM_QUERYITEM,
-                             MPFROM2SHORT(usItemID, fSearchSubmenus),
-                             (MPARAM)pmi));
+    return (BOOL)WinSendMsg(hwndMenu,
+                            MM_QUERYITEM,
+                            MPFROM2SHORT(usItemID, fSearchSubmenus),
+                            (MPARAM)pmi);
 }
 
@@ -427,5 +427,4 @@
 {
     MENUITEM mi;
-    SHORT    src = MIT_ERROR;
 
     mi.iPosition = iPosition;
@@ -435,9 +434,9 @@
     mi.hwndSubMenu = 0;
     mi.hItem = 0;
-    src = SHORT1FROMMR(WinSendMsg(hwndMenu,
-                                  MM_INSERTITEM,
-                                  (MPARAM)&mi,
-                                  (MPARAM)pcszItemTitle));
-    return (src);
+
+    return SHORT1FROMMR(WinSendMsg(hwndMenu,
+                                   MM_INSERTITEM,
+                                   (MPARAM)&mi,
+                                   (MPARAM)pcszItemTitle));
 }
 
@@ -511,5 +510,5 @@
         }
     }
-    return (hwndNewMenu);
+    return hwndNewMenu;
 }
 
@@ -621,8 +620,8 @@
     mi.hItem = 0;
 
-    return (SHORT1FROMMR(WinSendMsg(hMenu,
-                                    MM_INSERTITEM,
-                                    (MPARAM)&mi,
-                                    (MPARAM)"")));
+    return SHORT1FROMMR(WinSendMsg(hMenu,
+                                   MM_INSERTITEM,
+                                   (MPARAM)&mi,
+                                   (MPARAM)""));
 }
 
@@ -856,5 +855,5 @@
     }
 
-    return (hwndNewSubmenu);
+    return hwndNewSubmenu;
 }
 
@@ -892,5 +891,5 @@
         SHORT id = SHORT1FROMMR(WinSendMsg(hmenuSource,
                                            MM_ITEMIDFROMPOSITION,
-                                           MPFROMSHORT(i),
+                                           MPFROM2SHORT(i, 0),
                                            0));
         winhCopyMenuItem2(hmenuTarget,
@@ -905,4 +904,47 @@
 
 /*
+ *@@ winhClearMenu:
+ *      removes all menu items from the given (sub)menu.
+ *      The menu itself is not destroyed, but is empty
+ *      after calling this function.
+ *
+ *@@added V0.9.21 (2002-08-31) [umoeller]
+ */
+
+ULONG winhClearMenu(HWND hwndMenu)
+{
+    ULONG   cDeleted = 0;
+    SHORT   sID;
+
+    // what we do is getting the menu item count
+    // and then delete the first item in the menu
+    // x times because there is no "delete menu item
+    // from position" message, and there might be
+    // duplicate IDs in the menu... this should
+    // work always
+
+    SHORT   cMenuItems = SHORT1FROMMR(WinSendMsg(hwndMenu,
+                                                 MM_QUERYITEMCOUNT,
+                                                 0,
+                                                 0));
+    while (cMenuItems-- > 0)
+    {
+        sID = (SHORT)WinSendMsg(hwndMenu,
+                                MM_ITEMIDFROMPOSITION,
+                                MPFROMSHORT(0),
+                                MPNULL);
+
+        WinSendMsg(hwndMenu,
+                   MM_DELETEITEM,
+                   MPFROM2SHORT(sID, FALSE),
+                   0);
+
+        ++cDeleted;
+    }
+
+    return cDeleted;
+}
+
+/*
  *@@ winhQueryMenuItemText:
  *      this returns a menu item text as a PSZ
@@ -940,5 +982,5 @@
     }
 
-    return (prc);
+    return prc;
 }
 
@@ -1036,9 +1078,10 @@
                    (MPARAM)prtlItem);
         if (WinPtInRect(habDesktop, prtlItem, pptlMouse))
-            return (sItemId);
+            return sItemId;
     }
     /* sItemId = (SHORT)WinSendMsg(hwndMenu, MM_ITEMIDFROMPOSITION, (MPARAM)(sItemCount-1), MPNULL);
     return (sItemId); */
-    return (-1); // error: no valid menu item
+
+    return -1; // error: no valid menu item
 }
 
@@ -1218,5 +1261,5 @@
     }
 
-    return (hwndSlider);
+    return hwndSlider;
 }
 
@@ -1482,5 +1525,5 @@
     }
 
-    return (hwndSlider);
+    return hwndSlider;
 }
 
@@ -1619,5 +1662,5 @@
                    MPNULL);
     }
-    return (lValue);
+    return lValue;
 }
 
@@ -1662,5 +1705,5 @@
     }
 
-    return (pszReturn);
+    return pszReturn;
 }
 
@@ -1750,5 +1793,5 @@
     }
 
-    return (lItemCount);
+    return lItemCount;
 }
 
@@ -1779,9 +1822,9 @@
             if (ulHandle == winhQueryLboxItemHandle(hwndListBox,
                                                     ul))
-                return (ul);
+                return ul;
         }
     }
 
-    return (-1);
+    return -1;
 }
 
@@ -2119,5 +2162,5 @@
     // _Pmpf(("End of winhHandleScrollMsg"));
 
-    return (TRUE);
+    return TRUE;
 }
 
@@ -2274,5 +2317,5 @@
     // _Pmpf(("End of  winhProcessScrollChars"));
 
-    return (fProcessed);
+    return fProcessed;
 }
 
@@ -2712,5 +2755,5 @@
     ulReply = WinProcessDlg(hwndDlg);
     WinDestroyWindow(hwndDlg);
-    return (ulReply);
+    return ulReply;
 }
 
@@ -2818,5 +2861,5 @@
     }
 
-    return (hwnd);
+    return hwnd;
 }
 
@@ -2853,5 +2896,5 @@
                       QPF_NOINHERIT);
     if (szNewFont[0] != 0)
-        return (strdup(szNewFont));
+        return strdup(szNewFont);
 
     return NULL;
@@ -2888,8 +2931,8 @@
         strhncpy0(szFont, pcszFont, sizeof(szFont));
 
-    return (WinSetPresParam(hwnd,
-                            PP_FONTNAMESIZE,
-                            strlen(szFont)+1,
-                            szFont));
+    return WinSetPresParam(hwnd,
+                           PP_FONTNAMESIZE,
+                           strlen(szFont)+1,
+                           szFont);
 }
 
@@ -2928,5 +2971,6 @@
     else
         strhncpy0(szFont, pcszFont, sizeof(szFont));
-    cbFont = strlen(szFont)+1;
+
+    cbFont = strlen(szFont) + 1;
 
     // set font for all the dialog controls
@@ -2946,5 +2990,6 @@
     }
     WinEndEnumWindows(henum);
-    return (ulrc);
+
+    return ulrc;
 }
 
@@ -3190,8 +3235,8 @@
                       LONG lColor)
 {
-    return (WinSetPresParam(hwnd,
-                            ulIndex,
-                            sizeof(LONG),
-                            &lColor));
+    return WinSetPresParam(hwnd,
+                           ulIndex,
+                           sizeof(LONG),
+                           &lColor);
 }
 
@@ -3277,5 +3322,5 @@
     }
 
-    return (hwndHelp);
+    return hwndHelp;
 }
 
@@ -3297,10 +3342,10 @@
                            ULONG ulHelpPanel)       // in: help panel ID
 {
-    return (ULONG)(WinSendMsg(hwndHelpInstance,
-                              HM_DISPLAY_HELP,
-                              (MPARAM)ulHelpPanel,
-                              (MPARAM)(    (ulHelpPanel != 0)
-                                           ? HM_RESOURCEID
-                                           : 0)));
+    return (ULONG)WinSendMsg(hwndHelpInstance,
+                             HM_DISPLAY_HELP,
+                             (MPARAM)ulHelpPanel,
+                             (MPARAM)(    (ulHelpPanel != 0)
+                                          ? HM_RESOURCEID
+                                          : 0));
 }
 
@@ -3371,5 +3416,5 @@
         // semapore created: this doesn't happen if the semaphore
         // exists already, so no other instance is running
-        return (FALSE);
+        return FALSE;
 
     // else: instance running
@@ -3399,5 +3444,5 @@
     }
 
-    return (TRUE);      // another instance exists
+    return TRUE;      // another instance exists
 }
 
@@ -3438,5 +3483,5 @@
                    NULL);
 
-    return (hswitch);
+    return hswitch;
 }
 
@@ -3481,5 +3526,5 @@
     }
 
-    return (hab);
+    return hab;
 }
 
@@ -3676,8 +3721,8 @@
         strcpy(pszFile, fd.szFullFile);
 
-        return (TRUE);
-    }
-
-    return (FALSE);
+        return TRUE;
+    }
+
+    return FALSE;
 }
 
@@ -3700,5 +3745,5 @@
                                      SPTR_WAIT,
                                      FALSE));   // no copy
-    return (hptr);
+    return hptr;
 }
 
@@ -3724,5 +3769,5 @@
                                pszText);
     }
-    return (pszText);
+    return pszText;
 }
 
@@ -3749,6 +3794,6 @@
     va_end(args);
 
-    return (WinSetWindowText(hwnd,
-                             szBuf));
+    return WinSetWindowText(hwnd,
+                            szBuf);
 }
 
@@ -3841,5 +3886,6 @@
     }
     WinEndEnumWindows(henum1);
-    return (ulCount);
+
+    return ulCount;
 }
 
@@ -3972,5 +4018,6 @@
         }
     }
-    return (hwndFrame);
+
+    return hwndFrame;
 }
 
@@ -3992,14 +4039,14 @@
                             PVOID pvCreateParam)            // in: create param
 {
-    return (WinCreateWindow(HWND_OBJECT,
-                            (PSZ)pcszWindowClass,
-                            (PSZ)"",
-                            0,
-                            0,0,0,0,
-                            0,
-                            HWND_BOTTOM,
-                            0,
-                            pvCreateParam,
-                            NULL));
+    return WinCreateWindow(HWND_OBJECT,
+                           (PSZ)pcszWindowClass,
+                           (PSZ)"",
+                           0,
+                           0,0,0,0,
+                           0,
+                           HWND_BOTTOM,
+                           0,
+                           pvCreateParam,
+                           NULL);
 }
 
@@ -4096,5 +4143,5 @@
     WinEndEnumWindows(henum);
 
-    return (rc);
+    return rc;
 }
 
@@ -4220,16 +4267,16 @@
     background.rgb.bRed  = (CHAR3FROMMP(lDesktopColor));
 
-    return (WinCreateWindow(HWND_DESKTOP,  // parent window
-                            WC_FRAME,      // class name
-                            "",            // window text
-                            WS_VISIBLE,    // window style
-                            0, 0,          // position and size
-                            WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN),
-                            WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN),
-                            NULLHANDLE,    // owner window
-                            hwndSibling,   // sibling window
-                            1,             // window id
-                            NULL,          // control data
-                            &background)); // presentation parms
+    return WinCreateWindow(HWND_DESKTOP,  // parent window
+                           WC_FRAME,      // class name
+                           "",            // window text
+                           WS_VISIBLE,    // window style
+                           0, 0,          // position and size
+                           WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN),
+                           WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN),
+                           NULLHANDLE,    // owner window
+                           hwndSibling,   // sibling window
+                           1,             // window id
+                           NULL,          // control data
+                           &background); // presentation parms
 }
 
@@ -4452,5 +4499,5 @@
     prcl->yTop = lOrigYTop;
 
-    return (lLineCount);
+    return lLineCount;
 }
 
@@ -4487,5 +4534,5 @@
     }
 
-    return (pSwBlock);
+    return pSwBlock;
 }
 
@@ -4527,8 +4574,9 @@
 {
     SWBLOCK  swblock;
-    // HWND     hwndTasklist = winhQueryTasklistWindow();
+
     // the tasklist has entry #0 in the SWBLOCK
     WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK));
-    return (swblock.aswentry[0].swctl.hwnd);
+
+    return swblock.aswentry[0].swctl.hwnd;
 }
 
@@ -4638,5 +4686,5 @@
     } // end if Q level given
 
-    return (ulTotalJobCount);
+    return ulTotalJobCount;
 }
 
@@ -4760,4 +4808,55 @@
 
 /*
+ *@@ winhCalcExtFrameRect:
+ *      implementation for WM_CALCFRAMERECT in fnwpSubclExtFrame.
+ *      This is exported so it can be used independently
+ *      (XWorkplace status bars).
+ *
+ *@@added V0.9.21 (2002-08-28) [umoeller]
+ */
+
+VOID winhCalcExtFrameRect(MPARAM mp1,
+                          MPARAM mp2,
+                          LONG lStatusBarHeight)
+{
+    PRECTL prclPassed = (PRECTL)mp1;
+
+    // mp2 == TRUE:  Frame rectangle provided, calculate client
+    // mp2 == FALSE: Client area rectangle provided, calculate frame
+    if (mp2)
+    {
+        //  TRUE: calculate the rectl of the client;
+        //  call default window procedure to subtract child frame
+        //  controls from the rectangle's height
+        LONG lClientHeight;
+
+        //  position the static text frame extension below the client
+        lClientHeight = prclPassed->yTop - prclPassed->yBottom;
+        if (lStatusBarHeight > lClientHeight)
+            // extension is taller than client, so set client height to 0
+            prclPassed->yTop = prclPassed->yBottom;
+        else
+        {
+            //  set the origin of the client and shrink it based upon the
+            //  static text control's height
+            prclPassed->yBottom += lStatusBarHeight;
+            prclPassed->yTop -= lStatusBarHeight;
+        }
+    }
+    else
+    {
+        //  FALSE: calculate the rectl of the frame;
+        //  call default window procedure to subtract child frame
+        //  controls from the rectangle's height;
+        //  set the origin of the frame and increase it based upon the
+        //  static text control's height
+        prclPassed->yBottom -= lStatusBarHeight;
+        prclPassed->yTop += lStatusBarHeight;
+    }
+}
+
+#define STATUS_BAR_HEIGHT       20
+
+/*
  *@@ fnwpSubclExtFrame:
  *      subclassed frame window proc.
@@ -4798,9 +4897,8 @@
             for (ul = 0; ul < ulCount; ul++)
             {
-                if (WinQueryWindowUShort( swpArr[ul].hwnd, QWS_ID ) == 0x8008 )
+                if (WinQueryWindowUShort(swpArr[ul].hwnd, QWS_ID) == 0x8008)
                                                                  // FID_CLIENT
                 {
                     POINTL      ptlBorderSizes;
-                    ULONG       ulStatusBarHeight = 20;
                     WinSendMsg(hwndFrame,
                                WM_QUERYBORDERSIZE,
@@ -4817,5 +4915,5 @@
                     swpArr[ulCount].y  = ptlBorderSizes.y;
                     swpArr[ulCount].cx = swpArr[ul].cx;  // same as cnr's width
-                    swpArr[ulCount].cy = ulStatusBarHeight;
+                    swpArr[ulCount].cy = STATUS_BAR_HEIGHT;
                     swpArr[ulCount].hwndInsertBehind = HWND_BOTTOM; // HWND_TOP;
                     swpArr[ulCount].hwnd = WinWindowFromID(hwndFrame, FID_STATUSBAR);
@@ -4835,10 +4933,10 @@
 
         case WM_CALCFRAMERECT:
-        {
             mrc = pData->pfnwpOrig(hwndFrame, msg, mp1, mp2);
 
             // we have a status bar: calculate its rectangle
-            // CalcFrameRect(mp1, mp2);
-        }
+            winhCalcExtFrameRect(mp1,
+                                 mp2,
+                                 STATUS_BAR_HEIGHT);
         break;
 
@@ -4876,9 +4974,24 @@
     HWND        hwndReturn = NULLHANDLE;
     PPRESPARAMS ppp = NULL;
-    winhStorePresParam(&ppp, PP_FONTNAMESIZE, strlen(pcszFont)+1, (PVOID)pcszFont);
-    lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
-    winhStorePresParam(&ppp, PP_BACKGROUNDCOLOR, sizeof(lColor), &lColor);
+
+    winhStorePresParam(&ppp,
+                       PP_FONTNAMESIZE,
+                       strlen(pcszFont) + 1,
+                       (PVOID)pcszFont);
+
+    lColor = WinQuerySysColor(HWND_DESKTOP,
+                              SYSCLR_DIALOGBACKGROUND,
+                              0);
+    winhStorePresParam(&ppp,
+                       PP_BACKGROUNDCOLOR,
+                       sizeof(lColor),
+                       &lColor);
+
     lColor = CLR_BLACK;
-    winhStorePresParam(&ppp, PP_FOREGROUNDCOLOR, sizeof(lColor), &lColor);
+    winhStorePresParam(&ppp,
+                       PP_FOREGROUNDCOLOR,
+                       sizeof(lColor),
+                       &lColor);
+
     hwndReturn = WinCreateWindow(hwndFrame,
                                  WC_STATIC,
@@ -4892,5 +5005,6 @@
                                  ppp);
     free(ppp);
-    return (hwndReturn);
+
+    return hwndReturn;
 }
 
@@ -4958,5 +5072,5 @@
     }
 
-    return (hwndFrame);
+    return hwndFrame;
 }
 
@@ -5051,5 +5165,5 @@
     } // end while (pocThis)
 
-    return (pbReturn);
+    return pbReturn;
 }
 
@@ -5215,4 +5329,4 @@
         ulrc = 4;
 
-    return (ulrc);
-}
+    return ulrc;
+}
