Index: trunk/src/helpers/dialog.c
===================================================================
--- trunk/src/helpers/dialog.c	(revision 234)
+++ trunk/src/helpers/dialog.c	(revision 235)
@@ -92,4 +92,5 @@
 #include "helpers\gpih.h"
 #include "helpers\linklist.h"
+#include "helpers\nlscache.h"
 #include "helpers\standards.h"
 #include "helpers\stringh.h"
@@ -1497,7 +1498,10 @@
                     strhncpy0(szText2, pcszText, sizeof(szText2));
 
+                #ifdef DEBUG_DIALOG_WINDOWS
                 _Pmpf(("Crash creating control of class 0x%lX (%s), title 0x%lX (%s)",
                         szClass2,
                         szText2));
+                #endif
+
                 arc = ERROR_PROTECTION_VIOLATION;
             } END_CATCH();
@@ -1761,6 +1765,8 @@
                         LONG        cxWidestRowsMinBox = pOwningTable->cxMinBox; // pWidestRow->cxMinBox;
 
+                        #ifdef DEBUG_DIALOG_WINDOWS
                         _Pmpf(("  pWidestRow->cxMinBox %d", pWidestRow->cxMinBox));
                         _Pmpf(("  pOwningTable->cxMinBox %d", pOwningTable->cxMinBox));
+                        #endif
 
                         // now, since we're supposed to set our own CONTENT
@@ -1860,7 +1866,10 @@
                                     strhncpy0(szTemp, pControlDef->pcszText, sizeof(szTemp));
                                     strcpy(szTemp + 35, "...");
+
+                                    #ifdef DEBUG_DIALOG_WINDOWS
                                     _PmpfF(("   widest column is [%s] cxMinContent %d",
                                             szTemp,
                                             pCorrespondingColumn->cxMinContent));
+                                    #endif
                                 }
                             }
@@ -2242,5 +2251,7 @@
                     }
 
+                    #ifdef DEBUG_DIALOG_WINDOWS
                     _Pmpf(("    cxMax found is %d", cxMax));
+                    #endif
 
                     pTableDef->cxMinBox =   cxMax
@@ -2394,4 +2405,5 @@
  *
  *@@changed V1.0.0 (2002-08-18) [umoeller]: mostly rewritten for new algorithm
+ *@@changed V1.0.1 (2002-12-11) [umoeller]: added interface into nlsGetString
  */
 
@@ -2446,5 +2458,11 @@
                 // copy control fields
                 pColumn->pcszClass = pControlDef->pcszClass;
-                pColumn->pcszText = pControlDef->pcszText;
+
+                if (pControlDef->pcszText == LOAD_STRING)
+                    pColumn->pcszText = nlsGetString(pControlDef->usID);
+                            // V1.0.1 (2002-12-11) [umoeller]
+                else
+                    pColumn->pcszText = pControlDef->pcszText;
+
                 pColumn->flStyle = pControlDef->flStyle;
                 pColumn->usID = pControlDef->usID;
@@ -2569,5 +2587,5 @@
 
     if (!(pDlgData = NEW(DLGPRIVATE)))
-        return (ERROR_NOT_ENOUGH_MEMORY);
+        return ERROR_NOT_ENOUGH_MEMORY;
 
     ZERO(pDlgData);
@@ -3894,5 +3912,5 @@
         }
 
-    return (MBID_CANCEL);
+    return MBID_CANCEL;
 }
 
@@ -3966,7 +3984,7 @@
     {
         // SHOW DIALOG
-        return (dlghProcessMessageBox(hwndDlg,
-                                      ulAlarmFlag,
-                                      flFlags));
+        return dlghProcessMessageBox(hwndDlg,
+                                     ulAlarmFlag,
+                                     flFlags);
     }
 
@@ -3979,5 +3997,5 @@
                   MB_CANCEL | MB_MOVEABLE);
 
-    return (DID_CANCEL);
+    return DID_CANCEL;
 }
 
@@ -4119,5 +4137,5 @@
     xstrClear(&strTitle);
 
-    return (pszReturn);
+    return pszReturn;
 }
 
@@ -4313,5 +4331,5 @@
     }
 
-    return (hwndFound);
+    return hwndFound;
 }
 
@@ -4346,5 +4364,5 @@
                                (MPARAM)TRUE,        // upclick
                                0);
-                    return (TRUE);
+                    return TRUE;
                 }
             }
@@ -4354,5 +4372,5 @@
     }
 
-    return (FALSE);
+    return FALSE;
 }
 
Index: trunk/src/helpers/nlscache.c
===================================================================
--- trunk/src/helpers/nlscache.c	(revision 234)
+++ trunk/src/helpers/nlscache.c	(revision 235)
@@ -83,11 +83,16 @@
 STATIC ULONG               G_cEntities = 0;
 
-/*
- *@@ ReplaceEntities:
+STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
+STATIC TREE        *G_StringsCache;
+STATIC LONG        G_cStringsInCache = 0;
+
+
+/*
+ *@@ nlsReplaceEntities:
  *
  *@@added V0.9.16 (2001-09-29) [umoeller]
  */
 
-STATIC ULONG ReplaceEntities(PXSTRING pstr)
+ULONG nlsReplaceEntities(PXSTRING pstr)
 {
     ULONG ul,
@@ -107,16 +112,22 @@
     }
 
-    return (rc);
-}
-
-/*
- *@@ LoadString:
- *
- *@@added V0.9.18 (2002-03-08) [umoeller]
- */
-
-STATIC void LoadString(ULONG ulID,
-                       PSZ *ppsz,
-                       PULONG pulLength)        // out: length of new string (ptr can be NULL)
+    return rc;
+}
+
+/*
+ *@@ nlsLoadString:
+ *
+ *@@changed V0.9.0 [umoeller]: "string not found" is now re-allocated using strdup (avoids crashes)
+ *@@changed V0.9.0 (99-11-28) [umoeller]: added more meaningful error message
+ *@@changed V0.9.2 (2000-02-26) [umoeller]: made temporary buffer larger
+ *@@changed V0.9.16 (2001-09-29) [umoeller]: added entities support
+ *@@changed V0.9.16 (2002-01-26) [umoeller]: added pulLength param
+ *@@changed V1.0.0 (2002-09-17) [umoeller]: optimized
+ *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
+ */
+
+VOID nlsLoadString(ULONG ulID,
+                   PSZ *ppsz,
+                   PULONG pulLength)        // out: length of new string (ptr can be NULL)
 {
     CHAR szBuf[500];
@@ -138,5 +149,5 @@
 
     xstrInitCopy(&str, szBuf, 0);
-    ReplaceEntities(&str);
+    nlsReplaceEntities(&str);
     *ppsz = str.psz;
     if (pulLength)
@@ -144,8 +155,4 @@
     // do not free string
 }
-
-STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
-STATIC TREE        *G_StringsCache;
-STATIC LONG        G_cStringsInCache = 0;
 
 /*
@@ -202,4 +209,41 @@
 
 /*
+ *@@ Unload:
+ *      removes all loaded strings from memory.
+ *
+ *@@added V0.9.9 (2001-04-04) [umoeller]
+ *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
+ */
+
+STATIC VOID Unload(VOID)
+{
+    // to delete all nodes, build a temporary
+    // array of all string node pointers;
+    // we don't want to rebalance the tree
+    // for each node
+    LONG            cNodes = G_cStringsInCache;
+    PSTRINGTREENODE *papNodes
+        = (PSTRINGTREENODE*)treeBuildArray(G_StringsCache,
+                                           &cNodes);
+    if (papNodes)
+    {
+        // delete all nodes in array
+        ULONG ul;
+        for (ul = 0;
+             ul < cNodes;
+             ul++)
+        {
+            free(papNodes[ul]);
+        }
+
+        free(papNodes);
+    }
+
+    // reset the tree to "empty"
+    treeInit(&G_StringsCache,
+             &G_cStringsInCache);
+}
+
+/*
  *@@ nlsInitStrings:
  *      initializes the NLS strings cache. Call this
@@ -214,8 +258,24 @@
                     ULONG cEntities)            // in: array item count of paEntities or 0
 {
-    G_hab = hab;
-    G_hmod = hmod;
-    G_paEntities = paEntities;
-    G_cEntities = cEntities;
+    BOOL    fLocked = FALSE;
+
+    TRY_LOUD(excpt1)
+    {
+        if (fLocked = LockStrings())
+        {
+            if (G_cStringsInCache)
+                // not first call:
+                Unload();
+
+            G_hab = hab;
+            G_hmod = hmod;
+            G_paEntities = paEntities;
+            G_cEntities = cEntities;
+        }
+    }
+    CATCH(excpt1) {} END_CATCH();
+
+    if (fLocked)
+        UnlockStrings();
 }
 
@@ -275,4 +335,5 @@
  *@@changed V0.9.16 (2001-10-19) [umoeller]: fixed bad string count which was never set
  *@@changed V0.9.16 (2002-01-26) [umoeller]: optimized heap locality
+ *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
  */
 
@@ -299,7 +360,7 @@
                 ULONG   ulLength = 0;
 
-                LoadString(ulStringID,
-                           &psz,
-                           &ulLength);
+                nlsLoadString(ulStringID,
+                              &psz,
+                              &ulLength);
 
                 if (    (!psz)
@@ -336,6 +397,6 @@
         UnlockStrings();
 
-    return (pszReturn);
-}
-
-
+    return pszReturn;
+}
+
+
Index: trunk/src/helpers/winh.c
===================================================================
--- trunk/src/helpers/winh.c	(revision 234)
+++ trunk/src/helpers/winh.c	(revision 235)
@@ -345,4 +345,26 @@
 }
 
+/*
+ *@@ winhDestroyWindow:
+ *      wrapper around WinDestroyWindow that also sets
+ *      *phwnd to NULLHANDLE to avoid loose window
+ *      handles lying around.
+ *
+ *@@added V1.0.1 (2002-12-11) [umoeller]
+ */
+
+BOOL winhDestroyWindow(HWND *phwnd)
+{
+    if (    (*phwnd)
+         && (WinDestroyWindow(*phwnd))
+       )
+    {
+        *phwnd = NULLHANDLE;
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
 
 /*
