Index: trunk/src/helpers/cctl_checkcnr.c
===================================================================
--- trunk/src/helpers/cctl_checkcnr.c	(revision 144)
+++ trunk/src/helpers/cctl_checkcnr.c	(revision 146)
@@ -187,26 +187,4 @@
 
 /*
- *@@ CHECKBOXCNROWNER:
- *
- *
- *@@added V0.9.0 (99-11-28) [umoeller]
- */
-
-typedef struct _CHECKBOXCNROWNER
-{
-    HWND        hwndCnr;            // container window handle
-    USHORT      usCnrID;            // container item ID
-    HWND        hwndOwner;          // owner of that container
-    PFNWP       pfnwpCnrOrig;       // original window proc of hwndCnr
-    PFNWP       pfnwpOwnerOrig;     // original window proc of hwndOwner
-
-    HAB         habCnr;
-
-    PCHECKBOXRECORDCORE preccClicked;   // != NULL if mb1 is currently down on recc
-    PCHECKBOXRECORDCORE preccSpace;     // != NULL if space key is down with recc
-    RECTL       rclReccClicked;     // rectangle of that record
-} CHECKBOXCNROWNER, *PCHECKBOXCNROWNER;
-
-/*
  *@@ CnrCheckboxClicked:
  *
@@ -249,12 +227,137 @@
 
 /*
- *@@ ctl_fnwpSubclCheckboxCnr:
+ *@@ ctlDrawCheckBoxRecord:
+ *
+ *@@added V0.9.18 (2002-03-03) [umoeller]
+ */
+
+MRESULT ctlDrawCheckBoxRecord(MPARAM mp2)
+{
+    MRESULT mrc = 0;
+
+    // get generic DRAWITEM structure
+    POWNERITEM poi = (POWNERITEM)mp2;
+
+    // _Pmpf(("WM_DRAWITEM poi->idItem %d", poi->idItem));
+
+    // check if we're to draw the icon
+    // (and not the text)
+    if (poi->idItem == CMA_ICON)
+    {
+        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
+        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
+
+        if (precc->ulStyle & WS_VISIBLE)
+        {
+            USHORT usRow,
+                   usColumn;
+
+            switch (precc->usCheckState)
+            {
+                case 0: // unchecked
+                    usRow = 2;
+                    usColumn = 0;
+                break;
+
+                case 1: // checked
+                    usRow = 2;
+                    usColumn = 1;
+                break;
+
+                case 2: // indeterminate
+                    usRow = 0;
+                    usColumn = 1;
+                break;
+            }
+
+            if (precc->ulStyle & BS_BITMAP)
+                // button currently depressed:
+                // add two to column
+                usColumn += 2;
+
+            ctlDrawCheckbox(poi->hps,
+                            poi->rclItem.xLeft,
+                            poi->rclItem.yBottom,
+                            usRow,
+                            usColumn,
+                            // halftoned?
+                            ((precc->recc.flRecordAttr & CRA_DISABLED) != 0));
+            mrc = (MPARAM)FALSE;
+                        // we still need the cnr to draw the
+                        // emphasis
+        }
+        else
+            mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item;
+                    // don't even draw emphasis
+    }
+    else if (poi->idItem == CMA_TEXT)
+    {
+        // for text, buttons etc.:
+        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
+        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
+        if (precc->recc.flRecordAttr & CRA_DISABLED)
+        {
+            RECTL rcl2;
+            LONG lBackground, lForeground;
+            ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
+            if ((pcdi->pRecord->flRecordAttr) & CRA_SELECTED)
+            {
+                // disabled and selected:
+                lBackground = WinQuerySysColor(HWND_DESKTOP,
+                                               SYSCLR_SHADOWTEXT, 0);
+                lForeground = winhQueryPresColor(poi->hwnd,
+                                                 PP_BACKGROUNDCOLOR,
+                                                 FALSE, // no inherit
+                                                 SYSCLR_WINDOW);
+            }
+            else
+            {
+                // disabled and not selected:
+                lBackground = winhQueryPresColor(poi->hwnd,
+                                                 PP_BACKGROUNDCOLOR,
+                                                 FALSE,
+                                                 SYSCLR_WINDOW);
+                lForeground = winhQueryPresColor(poi->hwnd,
+                                                 PP_FOREGROUNDCOLOR,
+                                                 FALSE, // no inherit
+                                                 SYSCLR_WINDOWTEXT);
+                flCmd |= DT_HALFTONE;
+            }
+
+            // _Pmpf(("back: 0x%lX, fore: 0x%lX", lBackground, lForeground));
+
+            GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
+            GpiSetBackColor(poi->hps, lBackground);
+            GpiSetColor(poi->hps, lForeground);
+
+            memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
+
+            winhDrawFormattedText(poi->hps,
+                                  &rcl2,
+                                  precc->recc.pszTree,
+                                  flCmd);
+            mrc = (MPARAM)TRUE;
+        }
+        else
+            // tell cnr to draw the item
+            mrc = (MPARAM)FALSE;
+    }
+    else
+        // tell cnr to draw the item
+        mrc = (MPARAM)FALSE;
+
+    return mrc;
+}
+
+/*
+ *@@ fnwpSubclCheckboxCnr:
  *      window proc for subclassed containers.
  *      See ctlMakeCheckboxContainer for details.
  *
  *@@added V0.9.0 (99-11-29) [umoeller]
- */
-
-MRESULT EXPENTRY ctl_fnwpSubclCheckboxCnr(HWND hwndCnr, ULONG msg, MPARAM mp1, MPARAM mp2)
+ *@@changed V0.9.18 (2002-03-03) [umoeller]: fixed bad orig win msg, other optimizations
+ */
+
+static MRESULT EXPENTRY fnwpSubclCheckboxCnr(HWND hwndCnr, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
     MRESULT             mrc = 0;
@@ -270,5 +373,5 @@
             if (pcbco->hwndCnr == hwndCnr)
             {
-                pfnwpOrig = pcbco->pfnwpOwnerOrig;
+                pfnwpOrig = pcbco->pfnwpCnrOrig; // fixed V0.9.18 (2002-03-03) [umoeller]
                 break;
             }
@@ -314,5 +417,6 @@
                 mrc = pfnwpOrig(hwndCnr, msg, mp1, mp2);
                         // apperently, the cnr captures the mouse
-            break; }
+            }
+            break;
 
             case WM_MOUSEMOVE:
@@ -438,5 +542,6 @@
 
                 mrc = pfnwpOrig(hwndCnr, msg, mp1, mp2);
-            break; }
+            }
+            break;
 
             /*
@@ -452,5 +557,12 @@
                 if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
                 {
+                    if (WinIsWindow(pcbco->habCnr,
+                                    pcbco->hwndOwner))
+                        // un-subclass the owner
+                        WinSubclassWindow(pcbco->hwndOwner,
+                                          pcbco->pfnwpOwnerOrig);
+
                     lstRemoveItem(G_pllCnrOwners, pcbco);
+
                     if (lstCountItems(G_pllCnrOwners) == 0)
                     {
@@ -475,5 +587,5 @@
 
 /*
- *@@ ctl_fnwpSubclCheckboxCnrOwner:
+ *@@ fnwpSubclCheckboxCnrOwner:
  *      window proc for subclassed container owners.
  *      See ctlMakeCheckboxContainer for details.
@@ -482,5 +594,5 @@
  */
 
-MRESULT EXPENTRY ctl_fnwpSubclCheckboxCnrOwner(HWND hwndOwner, ULONG msg, MPARAM mp1, MPARAM mp2)
+static MRESULT EXPENTRY fnwpSubclCheckboxCnrOwner(HWND hwndOwner, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
     MRESULT             mrc = 0;
@@ -531,10 +643,12 @@
                                                    precc,
                                                    TRUE);
-                        break; }
+                        }
+                        break;
                     }
                 }
 
                 mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2);
-            break; }
+            }
+            break;
 
             /*
@@ -546,121 +660,10 @@
             case WM_DRAWITEM:
             {
-                USHORT usID = SHORT1FROMMP(mp1);
-                if (usID == pcbco->usCnrID)
-                {
-                    // get generic DRAWITEM structure
-                    POWNERITEM poi = (POWNERITEM)mp2;
-
-                    // _Pmpf(("WM_DRAWITEM poi->idItem %d", poi->idItem));
-
-                    // check if we're to draw the icon
-                    // (and not the text)
-                    if (poi->idItem == CMA_ICON)
-                    {
-                        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
-                        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
-
-                        if (precc->ulStyle & WS_VISIBLE)
-                        {
-                            USHORT usRow,
-                                   usColumn;
-
-                            switch (precc->usCheckState)
-                            {
-                                case 0: // unchecked
-                                    usRow = 2;
-                                    usColumn = 0;
-                                break;
-
-                                case 1: // checked
-                                    usRow = 2;
-                                    usColumn = 1;
-                                break;
-
-                                case 2: // indeterminate
-                                    usRow = 0;
-                                    usColumn = 1;
-                                break;
-                            }
-
-                            if (precc->ulStyle & BS_BITMAP)
-                                // button currently depressed:
-                                // add two to column
-                                usColumn += 2;
-
-                            ctlDrawCheckbox(poi->hps,
-                                            poi->rclItem.xLeft,
-                                            poi->rclItem.yBottom,
-                                            usRow,
-                                            usColumn,
-                                            // halftoned?
-                                            ((precc->recc.flRecordAttr & CRA_DISABLED) != 0));
-                            mrc = (MPARAM)FALSE;
-                                        // we still need the cnr to draw the
-                                        // emphasis
-                        }
-                        else
-                            mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item;
-                                    // don't even draw emphasis
-                    }
-                    else if (poi->idItem == CMA_TEXT)
-                    {
-                        // for text, buttons etc.:
-                        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
-                        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
-                        if (precc->recc.flRecordAttr & CRA_DISABLED)
-                        {
-                            RECTL rcl2;
-                            LONG lBackground, lForeground;
-                            ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
-                            if ((pcdi->pRecord->flRecordAttr) & CRA_SELECTED)
-                            {
-                                // disabled and selected:
-                                lBackground = WinQuerySysColor(HWND_DESKTOP,
-                                                               SYSCLR_SHADOWTEXT, 0);
-                                lForeground = winhQueryPresColor(poi->hwnd,
-                                                                 PP_BACKGROUNDCOLOR,
-                                                                 FALSE, // no inherit
-                                                                 SYSCLR_WINDOW);
-                            }
-                            else
-                            {
-                                // disabled and not selected:
-                                lBackground = winhQueryPresColor(poi->hwnd,
-                                                                 PP_BACKGROUNDCOLOR,
-                                                                 FALSE,
-                                                                 SYSCLR_WINDOW);
-                                lForeground = winhQueryPresColor(poi->hwnd,
-                                                                 PP_FOREGROUNDCOLOR,
-                                                                 FALSE, // no inherit
-                                                                 SYSCLR_WINDOWTEXT);
-                                flCmd |= DT_HALFTONE;
-                            }
-
-                            // _Pmpf(("back: 0x%lX, fore: 0x%lX", lBackground, lForeground));
-
-                            GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
-                            GpiSetBackColor(poi->hps, lBackground);
-                            GpiSetColor(poi->hps, lForeground);
-
-                            memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
-
-                            winhDrawFormattedText(poi->hps,
-                                                  &rcl2,
-                                                  precc->recc.pszTree,
-                                                  flCmd);
-                            mrc = (MPARAM)TRUE;
-                        }
-                        else
-                            // tell cnr to draw the item
-                            mrc = (MPARAM)FALSE;
-                    }
-                    else
-                        // tell cnr to draw the item
-                        mrc = (MPARAM)FALSE;
-                }
+                if (SHORT1FROMMP(mp1) == pcbco->usCnrID)
+                    mrc = ctlDrawCheckBoxRecord(mp2);
                 else
                     mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2);
-            break; }
+            }
+            break;
 
             default:
@@ -672,4 +675,68 @@
 
     return (mrc);
+}
+
+/*
+ *@@ ctlInitCheckboxContainer:
+ *
+ *@@added V0.9.18 (2002-03-03) [umoeller]
+ */
+
+VOID ctlInitCheckboxContainer(HWND hwndCnr)
+{
+    if (G_hbmCheckboxes == NULLHANDLE)
+    {
+        // first call:
+        BITMAPINFOHEADER bmih;
+        // load checkboxes bitmap
+        G_hbmCheckboxes = WinGetSysBitmap(HWND_DESKTOP,
+                                          SBMP_CHECKBOXES);
+
+        // _Pmpf(("hbmCheckboxes: 0x%lX", G_hbmCheckboxes));
+
+        // and compute size of one checkbox
+        // (4 columns, 3 rows)
+        GpiQueryBitmapParameters(G_hbmCheckboxes,
+                                 &bmih);
+        G_cxCheckbox = bmih.cx / 4;
+    }
+
+    BEGIN_CNRINFO()
+    {
+        cnrhSetView(CV_TREE | CV_ICON | CA_TREELINE | CA_OWNERDRAW | CV_MINI);
+        cnrhSetTreeIndent(20);
+        cnrhSetBmpOrIconSize(G_cxCheckbox, G_cxCheckbox);
+    } END_CNRINFO(hwndCnr);
+}
+
+/*
+ *@@ ctlSubclassCheckboxContainer:
+ *
+ *@@added V0.9.18 (2002-03-03) [umoeller]
+ */
+
+PCHECKBOXCNROWNER ctlSubclassCheckboxContainer(HWND hwndCnr)
+{
+    PFNWP pfnwpCnrOrig;
+    if (pfnwpCnrOrig = WinSubclassWindow(hwndCnr, fnwpSubclCheckboxCnr))
+    {
+        // cnr successfully subclassed:
+        // create storage for both subclassed cnr and owner
+        PCHECKBOXCNROWNER pcbco;
+        if (pcbco = (PCHECKBOXCNROWNER)malloc(sizeof(CHECKBOXCNROWNER)))
+        {
+            memset(pcbco, 0, sizeof(CHECKBOXCNROWNER));
+            pcbco->hwndCnr = hwndCnr;
+            pcbco->usCnrID = WinQueryWindowUShort(hwndCnr, QWS_ID);
+            pcbco->hwndOwner = WinQueryWindow(hwndCnr, QW_OWNER);
+            pcbco->pfnwpCnrOrig = pfnwpCnrOrig;
+
+            pcbco->habCnr = WinQueryAnchorBlock(hwndCnr);
+
+            return (pcbco);
+        }
+    }
+
+    return NULL;
 }
 
@@ -749,28 +816,5 @@
     if (hwndCnr)
     {
-        if (G_hbmCheckboxes == NULLHANDLE)
-        {
-            // first call:
-            BITMAPINFOHEADER bmih;
-            // load checkboxes bitmap
-            G_hbmCheckboxes = WinGetSysBitmap(HWND_DESKTOP,
-                                              SBMP_CHECKBOXES);
-
-            // _Pmpf(("hbmCheckboxes: 0x%lX", G_hbmCheckboxes));
-
-            // and compute size of one checkbox
-            // (4 columns, 3 rows)
-            GpiQueryBitmapParameters(G_hbmCheckboxes,
-                                     &bmih);
-            G_cxCheckbox = bmih.cx / 4;
-        }
-
-        BEGIN_CNRINFO()
-        {
-            cnrhSetView(CV_TREE | CV_ICON | CA_TREELINE | CA_OWNERDRAW | CV_MINI);
-            cnrhSetTreeIndent(20);
-            cnrhSetBmpOrIconSize(G_cxCheckbox, G_cxCheckbox);
-            // cnrhSetSortFunc(fnCompareName);
-        } END_CNRINFO(hwndCnr);
+        ctlInitCheckboxContainer(hwndCnr);
 
         if (    (hwndCnrOwner)
@@ -779,5 +823,5 @@
         {
             // subclass container owner
-            PFNWP pfnwpOwnerOrig = WinSubclassWindow(hwndCnrOwner, ctl_fnwpSubclCheckboxCnrOwner);
+            PFNWP pfnwpOwnerOrig = WinSubclassWindow(hwndCnrOwner, fnwpSubclCheckboxCnrOwner);
             /* _Pmpf(("Subclassed hwnd 0x%lX: orig 0x%lX",
                     hwndCnrOwner, pfnwpOwnerOrig)); */
@@ -786,37 +830,16 @@
                 // owner successfully subclassed:
                 // subclass container too
-                PFNWP pfnwpCnrOrig = WinSubclassWindow(hwndCnr, ctl_fnwpSubclCheckboxCnr);
-                if (pfnwpCnrOrig)
+                PCHECKBOXCNROWNER pcbco;
+                if (pcbco = ctlSubclassCheckboxContainer(hwndCnr))
                 {
-                    // cnr successfully subclassed:
-                    // create storage for both subclassed cnr and owner
-                    PCHECKBOXCNROWNER pcbco = (PCHECKBOXCNROWNER)malloc(sizeof(CHECKBOXCNROWNER));
-                    if (pcbco)
+                    if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
                     {
-                        memset(pcbco, 0, sizeof(CHECKBOXCNROWNER));
-                        pcbco->hwndCnr = hwndCnr;
-                        pcbco->usCnrID = usCnrID;
-                        pcbco->hwndOwner = hwndCnrOwner;
-                        pcbco->pfnwpCnrOrig = pfnwpCnrOrig;
+                        lstAppendItem(G_pllCnrOwners, pcbco);
+                        DosReleaseMutexSem(G_hmtxCnrOwnersList);
+                        brc = TRUE;
+
                         pcbco->pfnwpOwnerOrig = pfnwpOwnerOrig;
-
-                        pcbco->habCnr = WinQueryAnchorBlock(hwndCnr);
-
-                        if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
-                        {
-                            lstAppendItem(G_pllCnrOwners, pcbco);
-                            DosReleaseMutexSem(G_hmtxCnrOwnersList);
-                            brc = TRUE;
-                        }
                     }
-
-                    if (!brc)
-                        // failed: unsubclass cnr
-                        WinSubclassWindow(hwndCnr, pfnwpCnrOrig);
                 }
-
-                if (!brc)
-                    // failed: unsubclass owner
-                    WinSubclassWindow(hwndCnrOwner, pfnwpOwnerOrig);
             }
         }
@@ -956,5 +979,5 @@
  *      ID and updates that record enablement. If
  *      the record is disabled, it's painted halftoned
- *      by ctl_fnwpSubclCheckboxCnr.
+ *      by fnwpSubclCheckboxCnr.
  *
  *@@added V0.9.1 (99-12-03) [umoeller]
Index: trunk/src/helpers/dialog.c
===================================================================
--- trunk/src/helpers/dialog.c	(revision 144)
+++ trunk/src/helpers/dialog.c	(revision 146)
@@ -109,7 +109,7 @@
     POINTL      ptlTotalOfs;
 
-    LINKLIST    llControls;     // linked list of all PCOLUMNDEF structs,
-                                 // in the order in which windows were
-                                 // created
+    PLINKLIST   pllControls;            // linked list of HWNDs in the order
+                                        // in which controls were created;
+                                        // ptr can be NULL
 
     PCSZ        pcszControlsFont;  // from dlghCreateDlg
@@ -910,6 +910,9 @@
                                       pcszFont);
 
-            lstAppendItem(&pDlgData->llControls,
-                          pColumnDef);
+            // append window that was created
+            // V0.9.18 (2002-03-03) [umoeller]
+            if (pDlgData->pllControls)
+                lstAppendItem(pDlgData->pllControls,
+                              (PVOID)pColumnDef->hwndControl);
 
             // if this is the first control with WS_TABSTOP,
@@ -1455,8 +1458,10 @@
  *
  *@@added V0.9.15 (2001-08-26) [umoeller]
+ *@@changed V0.9.18 (2002-03-03) [umoeller]: aded pllWindows
  */
 
 static APIRET Dlg0_Init(PDLGPRIVATE *ppDlgData,
-                        PCSZ pcszControlsFont)
+                        PCSZ pcszControlsFont,
+                        PLINKLIST pllControls)
 {
     PDLGPRIVATE pDlgData;
@@ -1465,5 +1470,7 @@
     ZERO(pDlgData);
     lstInit(&pDlgData->llTables, FALSE);
-    lstInit(&pDlgData->llControls, FALSE);
+
+    if (pllControls)
+        pDlgData->pllControls = pllControls;
 
     pDlgData->pcszControlsFont = pcszControlsFont;
@@ -1756,5 +1763,4 @@
 
         lstClear(&pDlgData->llTables);
-        lstClear(&pDlgData->llControls);
 
         free(pDlgData);
@@ -2040,5 +2046,6 @@
 
     if (!(arc = Dlg0_Init(&pDlgData,
-                          pcszControlsFont)))
+                          pcszControlsFont,
+                          NULL)))
     {
         if (!(arc = Dlg1_ParseTables(pDlgData,
@@ -2204,11 +2211,11 @@
  *          except that the frame is already created.
  *
- *      --  DFFL_RESIZEFRAME: hwndDlg should be resized so
- *          that it will properly surround the controls.
- *
- *          This can only be used in conjunction with
- *          DFFL_RESIZEFRAME.
+ *      If pszlClient is specified, it receives the required
+ *      size of the client to surround all controls properly.
+ *      You can then use dlghResizeFrame to resize the frame
+ *      with a bit of spacing, if desired.
  *
  *@@added V0.9.16 (2001-09-29) [umoeller]
+ *@@changed V0.9.18 (2002-03-03) [umoeller]: added pszlClient, fixed output
  */
 
@@ -2217,5 +2224,7 @@
                      ULONG cDlgItems,           // in: array item count (NOT array size)
                      PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
-                     ULONG flFlags)             // in: DFFL_* flags
+                     ULONG flFlags,             // in: DFFL_* flags
+                     PSIZEL pszlClient,         // out: size of all controls (ptr can be NULL)
+                     PVOID *ppllControls)   // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
 {
     APIRET      arc = NO_ERROR;
@@ -2224,4 +2233,5 @@
 
     PDLGPRIVATE  pDlgData = NULL;
+    PLINKLIST   pllControls = NULL;
 
     /*
@@ -2230,6 +2240,10 @@
      */
 
+    if (ppllControls)
+        pllControls = *(PLINKLIST*)ppllControls = lstCreate(FALSE);
+
     if (!(arc = Dlg0_Init(&pDlgData,
-                          pcszControlsFont)))
+                          pcszControlsFont,
+                          pllControls)))
     {
         if (!(arc = Dlg1_ParseTables(pDlgData,
@@ -2237,4 +2251,6 @@
                                      cDlgItems)))
         {
+            HWND hwndFocusItem;
+
             /*
              *  2) create empty dialog frame
@@ -2242,8 +2258,4 @@
              */
 
-            HWND    hwndFocusItem = NULLHANDLE;
-            SIZEL   szlClient = {0};
-            RECTL   rclClient;
-
             pDlgData->hwndDlg = hwndDlg;
 
@@ -2255,29 +2267,8 @@
             Dlg2_CalcSizes(pDlgData);
 
-            // WinSubclassWindow(hwndDlg, pfnwpDialogProc);
-
-            /*
-             *  4) compute size of dialog client from total
-             *     size of all controls
-             */
-
-            if (flFlags & DFFL_RESIZEFRAME)
+            if (pszlClient)
             {
-                // calculate the frame size from the client size
-                rclClient.xLeft = 10;
-                rclClient.yBottom = 10;
-                rclClient.xRight = szlClient.cx + 2 * SPACING;
-                rclClient.yTop = szlClient.cy + 2 * SPACING;
-                WinCalcFrameRect(hwndDlg,
-                                 &rclClient,
-                                 FALSE);            // frame from client
-
-                WinSetWindowPos(hwndDlg,
-                                0,
-                                10,
-                                10,
-                                rclClient.xRight,
-                                rclClient.yTop,
-                                SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
+                pszlClient->cx = pDlgData->szlClient.cx + 2 * SPACING;
+                pszlClient->cy = pDlgData->szlClient.cy + 2 * SPACING;
             }
 
@@ -2303,4 +2294,32 @@
 
     return (arc);
+}
+
+/*
+ *@@ dlghResizeFrame:
+ *
+ *@@added V0.9.18 (2002-03-03) [umoeller]
+ */
+
+VOID dlghResizeFrame(HWND hwndDlg,
+                     PSIZEL pszlClient)
+{
+    // calculate the frame size from the client size
+    RECTL   rclClient;
+    rclClient.xLeft = 10;
+    rclClient.yBottom = 10;
+    rclClient.xRight = pszlClient->cx;
+    rclClient.yTop = pszlClient->cy;
+    WinCalcFrameRect(hwndDlg,
+                     &rclClient,
+                     FALSE);            // frame from client
+
+    WinSetWindowPos(hwndDlg,
+                    0,
+                    10,
+                    10,
+                    rclClient.xRight,
+                    rclClient.yTop,
+                    SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
 }
 
Index: trunk/src/helpers/dosh.c
===================================================================
--- trunk/src/helpers/dosh.c	(revision 144)
+++ trunk/src/helpers/dosh.c	(revision 146)
@@ -2916,4 +2916,8 @@
  *      is _not_ converted WRT the line format.
  *
+ *      If CTRL-Z (ASCII 26) is encountered in the
+ *      content, it is set to the null character
+ *      instead (V0.9.18).
+ *
  *      This returns the APIRET of DosOpen and DosRead.
  *      If any error occured, no buffer was allocated.
@@ -2924,4 +2928,5 @@
  *@@changed V0.9.16 (2002-01-05) [umoeller]: added pcbRead
  *@@changed V0.9.16 (2002-01-05) [umoeller]: rewritten using doshOpen
+ *@@changed V0.9.18 (2002-03-08) [umoeller]: fixed ctrl-z (EOF) bug
  */
 
@@ -2955,5 +2960,17 @@
                 else
                 {
+                    PSZ p;
                     pszContent[cbRead] = '\0';
+
+                    // check if we have a ctrl-z (EOF) marker
+                    // this is present, for example, in config.sys
+                    // after install
+                    // V0.9.18 (2002-03-08) [umoeller]
+                    if (p = strchr(pszContent, '\26'))
+                    {
+                        *p = '\0';
+                        cbRead = p - pszContent;
+                    }
+
                     *ppszContent = pszContent;
                     if (pcbRead)
@@ -2968,54 +2985,4 @@
         doshClose(&pFile);
     }
-
-    /*
-    ULONG   ulSize,
-            ulBytesRead = 0,
-            ulAction, ulLocal;
-    HFILE   hFile;
-    PSZ     pszContent = NULL;
-
-    APIRET arc;
-
-    *ppszContent = 0;
-
-    if (!(arc = DosOpen((PSZ)pcszFile,
-                        &hFile,
-                        &ulAction,                      // action taken
-                        5000L,                          // primary allocation size
-                        FILE_ARCHIVED | FILE_NORMAL,    // file attribute
-                        OPEN_ACTION_OPEN_IF_EXISTS,     // open flags
-                        OPEN_FLAGS_NOINHERIT
-                           | OPEN_SHARE_DENYNONE
-                           | OPEN_ACCESS_READONLY,      // read-only mode
-                        NULL)))                         // no EAs
-    {
-        if (!(arc = doshQueryFileSize(hFile, &ulSize)))
-        {
-            pszContent = (PSZ)malloc(ulSize+1);
-
-            if (!(arc = DosSetFilePtr(hFile,
-                                      0L,
-                                      FILE_BEGIN,
-                                      &ulLocal)))
-                if (!(arc = DosRead(hFile,
-                                    pszContent,
-                                    ulSize,
-                                    &ulBytesRead)))
-                {
-                    *(pszContent+ulBytesRead) = 0;
-                    // set output buffer pointer
-                    *ppszContent = pszContent;
-
-                    if (pcbRead)
-                        *pcbRead = ulBytesRead + 1;
-                }
-
-            if (arc)
-                free(pszContent);
-        }
-        DosClose(hFile);
-    }
-    */
 
     return (arc);
Index: trunk/src/helpers/winh.c
===================================================================
--- trunk/src/helpers/winh.c	(revision 144)
+++ trunk/src/helpers/winh.c	(revision 146)
@@ -2390,6 +2390,6 @@
                  ul++)
             {
-                HWND hwndThis = WinWindowFromID(hwndDlg, SHORT1FROMMP(*pmpThis));
-                if (hwndThis)
+                HWND hwndThis;
+                if (hwndThis = WinWindowFromID(hwndDlg, SHORT1FROMMP(*pmpThis)))
                 {
                     WinQueryWindowPos(hwndThis, pswpThis);
@@ -3591,5 +3591,5 @@
 
 HWND winhCreateStdWindow(HWND hwndFrameParent,      // in: normally HWND_DESKTOP
-                         PSWP pswpFrame,            // in: frame wnd pos
+                         PSWP pswpFrame,            // in: frame wnd pos (ptr can be NULL)
                          ULONG flFrameCreateFlags,  // in: FCF_* flags
                          ULONG ulFrameStyle,        // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE)
