Changeset 146


Ignore:
Timestamp:
Mar 6, 2002, 6:34:48 PM (23 years ago)
Author:
umoeller
Message:

misc fixes

Location:
trunk/src/helpers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/cctl_checkcnr.c

    r142 r146  
    187187
    188188/*
    189  *@@ CHECKBOXCNROWNER:
    190  *
    191  *
    192  *@@added V0.9.0 (99-11-28) [umoeller]
    193  */
    194 
    195 typedef struct _CHECKBOXCNROWNER
    196 {
    197     HWND        hwndCnr;            // container window handle
    198     USHORT      usCnrID;            // container item ID
    199     HWND        hwndOwner;          // owner of that container
    200     PFNWP       pfnwpCnrOrig;       // original window proc of hwndCnr
    201     PFNWP       pfnwpOwnerOrig;     // original window proc of hwndOwner
    202 
    203     HAB         habCnr;
    204 
    205     PCHECKBOXRECORDCORE preccClicked;   // != NULL if mb1 is currently down on recc
    206     PCHECKBOXRECORDCORE preccSpace;     // != NULL if space key is down with recc
    207     RECTL       rclReccClicked;     // rectangle of that record
    208 } CHECKBOXCNROWNER, *PCHECKBOXCNROWNER;
    209 
    210 /*
    211189 *@@ CnrCheckboxClicked:
    212190 *
     
    249227
    250228/*
    251  *@@ ctl_fnwpSubclCheckboxCnr:
     229 *@@ ctlDrawCheckBoxRecord:
     230 *
     231 *@@added V0.9.18 (2002-03-03) [umoeller]
     232 */
     233
     234MRESULT ctlDrawCheckBoxRecord(MPARAM mp2)
     235{
     236    MRESULT mrc = 0;
     237
     238    // get generic DRAWITEM structure
     239    POWNERITEM poi = (POWNERITEM)mp2;
     240
     241    // _Pmpf(("WM_DRAWITEM poi->idItem %d", poi->idItem));
     242
     243    // check if we're to draw the icon
     244    // (and not the text)
     245    if (poi->idItem == CMA_ICON)
     246    {
     247        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
     248        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
     249
     250        if (precc->ulStyle & WS_VISIBLE)
     251        {
     252            USHORT usRow,
     253                   usColumn;
     254
     255            switch (precc->usCheckState)
     256            {
     257                case 0: // unchecked
     258                    usRow = 2;
     259                    usColumn = 0;
     260                break;
     261
     262                case 1: // checked
     263                    usRow = 2;
     264                    usColumn = 1;
     265                break;
     266
     267                case 2: // indeterminate
     268                    usRow = 0;
     269                    usColumn = 1;
     270                break;
     271            }
     272
     273            if (precc->ulStyle & BS_BITMAP)
     274                // button currently depressed:
     275                // add two to column
     276                usColumn += 2;
     277
     278            ctlDrawCheckbox(poi->hps,
     279                            poi->rclItem.xLeft,
     280                            poi->rclItem.yBottom,
     281                            usRow,
     282                            usColumn,
     283                            // halftoned?
     284                            ((precc->recc.flRecordAttr & CRA_DISABLED) != 0));
     285            mrc = (MPARAM)FALSE;
     286                        // we still need the cnr to draw the
     287                        // emphasis
     288        }
     289        else
     290            mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item;
     291                    // don't even draw emphasis
     292    }
     293    else if (poi->idItem == CMA_TEXT)
     294    {
     295        // for text, buttons etc.:
     296        PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
     297        PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
     298        if (precc->recc.flRecordAttr & CRA_DISABLED)
     299        {
     300            RECTL rcl2;
     301            LONG lBackground, lForeground;
     302            ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
     303            if ((pcdi->pRecord->flRecordAttr) & CRA_SELECTED)
     304            {
     305                // disabled and selected:
     306                lBackground = WinQuerySysColor(HWND_DESKTOP,
     307                                               SYSCLR_SHADOWTEXT, 0);
     308                lForeground = winhQueryPresColor(poi->hwnd,
     309                                                 PP_BACKGROUNDCOLOR,
     310                                                 FALSE, // no inherit
     311                                                 SYSCLR_WINDOW);
     312            }
     313            else
     314            {
     315                // disabled and not selected:
     316                lBackground = winhQueryPresColor(poi->hwnd,
     317                                                 PP_BACKGROUNDCOLOR,
     318                                                 FALSE,
     319                                                 SYSCLR_WINDOW);
     320                lForeground = winhQueryPresColor(poi->hwnd,
     321                                                 PP_FOREGROUNDCOLOR,
     322                                                 FALSE, // no inherit
     323                                                 SYSCLR_WINDOWTEXT);
     324                flCmd |= DT_HALFTONE;
     325            }
     326
     327            // _Pmpf(("back: 0x%lX, fore: 0x%lX", lBackground, lForeground));
     328
     329            GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
     330            GpiSetBackColor(poi->hps, lBackground);
     331            GpiSetColor(poi->hps, lForeground);
     332
     333            memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
     334
     335            winhDrawFormattedText(poi->hps,
     336                                  &rcl2,
     337                                  precc->recc.pszTree,
     338                                  flCmd);
     339            mrc = (MPARAM)TRUE;
     340        }
     341        else
     342            // tell cnr to draw the item
     343            mrc = (MPARAM)FALSE;
     344    }
     345    else
     346        // tell cnr to draw the item
     347        mrc = (MPARAM)FALSE;
     348
     349    return mrc;
     350}
     351
     352/*
     353 *@@ fnwpSubclCheckboxCnr:
    252354 *      window proc for subclassed containers.
    253355 *      See ctlMakeCheckboxContainer for details.
    254356 *
    255357 *@@added V0.9.0 (99-11-29) [umoeller]
    256  */
    257 
    258 MRESULT EXPENTRY ctl_fnwpSubclCheckboxCnr(HWND hwndCnr, ULONG msg, MPARAM mp1, MPARAM mp2)
     358 *@@changed V0.9.18 (2002-03-03) [umoeller]: fixed bad orig win msg, other optimizations
     359 */
     360
     361static MRESULT EXPENTRY fnwpSubclCheckboxCnr(HWND hwndCnr, ULONG msg, MPARAM mp1, MPARAM mp2)
    259362{
    260363    MRESULT             mrc = 0;
     
    270373            if (pcbco->hwndCnr == hwndCnr)
    271374            {
    272                 pfnwpOrig = pcbco->pfnwpOwnerOrig;
     375                pfnwpOrig = pcbco->pfnwpCnrOrig; // fixed V0.9.18 (2002-03-03) [umoeller]
    273376                break;
    274377            }
     
    314417                mrc = pfnwpOrig(hwndCnr, msg, mp1, mp2);
    315418                        // apperently, the cnr captures the mouse
    316             break; }
     419            }
     420            break;
    317421
    318422            case WM_MOUSEMOVE:
     
    438542
    439543                mrc = pfnwpOrig(hwndCnr, msg, mp1, mp2);
    440             break; }
     544            }
     545            break;
    441546
    442547            /*
     
    452557                if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
    453558                {
     559                    if (WinIsWindow(pcbco->habCnr,
     560                                    pcbco->hwndOwner))
     561                        // un-subclass the owner
     562                        WinSubclassWindow(pcbco->hwndOwner,
     563                                          pcbco->pfnwpOwnerOrig);
     564
    454565                    lstRemoveItem(G_pllCnrOwners, pcbco);
     566
    455567                    if (lstCountItems(G_pllCnrOwners) == 0)
    456568                    {
     
    475587
    476588/*
    477  *@@ ctl_fnwpSubclCheckboxCnrOwner:
     589 *@@ fnwpSubclCheckboxCnrOwner:
    478590 *      window proc for subclassed container owners.
    479591 *      See ctlMakeCheckboxContainer for details.
     
    482594 */
    483595
    484 MRESULT EXPENTRY ctl_fnwpSubclCheckboxCnrOwner(HWND hwndOwner, ULONG msg, MPARAM mp1, MPARAM mp2)
     596static MRESULT EXPENTRY fnwpSubclCheckboxCnrOwner(HWND hwndOwner, ULONG msg, MPARAM mp1, MPARAM mp2)
    485597{
    486598    MRESULT             mrc = 0;
     
    531643                                                   precc,
    532644                                                   TRUE);
    533                         break; }
     645                        }
     646                        break;
    534647                    }
    535648                }
    536649
    537650                mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2);
    538             break; }
     651            }
     652            break;
    539653
    540654            /*
     
    546660            case WM_DRAWITEM:
    547661            {
    548                 USHORT usID = SHORT1FROMMP(mp1);
    549                 if (usID == pcbco->usCnrID)
    550                 {
    551                     // get generic DRAWITEM structure
    552                     POWNERITEM poi = (POWNERITEM)mp2;
    553 
    554                     // _Pmpf(("WM_DRAWITEM poi->idItem %d", poi->idItem));
    555 
    556                     // check if we're to draw the icon
    557                     // (and not the text)
    558                     if (poi->idItem == CMA_ICON)
    559                     {
    560                         PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
    561                         PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
    562 
    563                         if (precc->ulStyle & WS_VISIBLE)
    564                         {
    565                             USHORT usRow,
    566                                    usColumn;
    567 
    568                             switch (precc->usCheckState)
    569                             {
    570                                 case 0: // unchecked
    571                                     usRow = 2;
    572                                     usColumn = 0;
    573                                 break;
    574 
    575                                 case 1: // checked
    576                                     usRow = 2;
    577                                     usColumn = 1;
    578                                 break;
    579 
    580                                 case 2: // indeterminate
    581                                     usRow = 0;
    582                                     usColumn = 1;
    583                                 break;
    584                             }
    585 
    586                             if (precc->ulStyle & BS_BITMAP)
    587                                 // button currently depressed:
    588                                 // add two to column
    589                                 usColumn += 2;
    590 
    591                             ctlDrawCheckbox(poi->hps,
    592                                             poi->rclItem.xLeft,
    593                                             poi->rclItem.yBottom,
    594                                             usRow,
    595                                             usColumn,
    596                                             // halftoned?
    597                                             ((precc->recc.flRecordAttr & CRA_DISABLED) != 0));
    598                             mrc = (MPARAM)FALSE;
    599                                         // we still need the cnr to draw the
    600                                         // emphasis
    601                         }
    602                         else
    603                             mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item;
    604                                     // don't even draw emphasis
    605                     }
    606                     else if (poi->idItem == CMA_TEXT)
    607                     {
    608                         // for text, buttons etc.:
    609                         PCNRDRAWITEMINFO pcdi = (PCNRDRAWITEMINFO)poi->hItem;
    610                         PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)pcdi->pRecord;
    611                         if (precc->recc.flRecordAttr & CRA_DISABLED)
    612                         {
    613                             RECTL rcl2;
    614                             LONG lBackground, lForeground;
    615                             ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
    616                             if ((pcdi->pRecord->flRecordAttr) & CRA_SELECTED)
    617                             {
    618                                 // disabled and selected:
    619                                 lBackground = WinQuerySysColor(HWND_DESKTOP,
    620                                                                SYSCLR_SHADOWTEXT, 0);
    621                                 lForeground = winhQueryPresColor(poi->hwnd,
    622                                                                  PP_BACKGROUNDCOLOR,
    623                                                                  FALSE, // no inherit
    624                                                                  SYSCLR_WINDOW);
    625                             }
    626                             else
    627                             {
    628                                 // disabled and not selected:
    629                                 lBackground = winhQueryPresColor(poi->hwnd,
    630                                                                  PP_BACKGROUNDCOLOR,
    631                                                                  FALSE,
    632                                                                  SYSCLR_WINDOW);
    633                                 lForeground = winhQueryPresColor(poi->hwnd,
    634                                                                  PP_FOREGROUNDCOLOR,
    635                                                                  FALSE, // no inherit
    636                                                                  SYSCLR_WINDOWTEXT);
    637                                 flCmd |= DT_HALFTONE;
    638                             }
    639 
    640                             // _Pmpf(("back: 0x%lX, fore: 0x%lX", lBackground, lForeground));
    641 
    642                             GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
    643                             GpiSetBackColor(poi->hps, lBackground);
    644                             GpiSetColor(poi->hps, lForeground);
    645 
    646                             memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
    647 
    648                             winhDrawFormattedText(poi->hps,
    649                                                   &rcl2,
    650                                                   precc->recc.pszTree,
    651                                                   flCmd);
    652                             mrc = (MPARAM)TRUE;
    653                         }
    654                         else
    655                             // tell cnr to draw the item
    656                             mrc = (MPARAM)FALSE;
    657                     }
    658                     else
    659                         // tell cnr to draw the item
    660                         mrc = (MPARAM)FALSE;
    661                 }
     662                if (SHORT1FROMMP(mp1) == pcbco->usCnrID)
     663                    mrc = ctlDrawCheckBoxRecord(mp2);
    662664                else
    663665                    mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2);
    664             break; }
     666            }
     667            break;
    665668
    666669            default:
     
    672675
    673676    return (mrc);
     677}
     678
     679/*
     680 *@@ ctlInitCheckboxContainer:
     681 *
     682 *@@added V0.9.18 (2002-03-03) [umoeller]
     683 */
     684
     685VOID ctlInitCheckboxContainer(HWND hwndCnr)
     686{
     687    if (G_hbmCheckboxes == NULLHANDLE)
     688    {
     689        // first call:
     690        BITMAPINFOHEADER bmih;
     691        // load checkboxes bitmap
     692        G_hbmCheckboxes = WinGetSysBitmap(HWND_DESKTOP,
     693                                          SBMP_CHECKBOXES);
     694
     695        // _Pmpf(("hbmCheckboxes: 0x%lX", G_hbmCheckboxes));
     696
     697        // and compute size of one checkbox
     698        // (4 columns, 3 rows)
     699        GpiQueryBitmapParameters(G_hbmCheckboxes,
     700                                 &bmih);
     701        G_cxCheckbox = bmih.cx / 4;
     702    }
     703
     704    BEGIN_CNRINFO()
     705    {
     706        cnrhSetView(CV_TREE | CV_ICON | CA_TREELINE | CA_OWNERDRAW | CV_MINI);
     707        cnrhSetTreeIndent(20);
     708        cnrhSetBmpOrIconSize(G_cxCheckbox, G_cxCheckbox);
     709    } END_CNRINFO(hwndCnr);
     710}
     711
     712/*
     713 *@@ ctlSubclassCheckboxContainer:
     714 *
     715 *@@added V0.9.18 (2002-03-03) [umoeller]
     716 */
     717
     718PCHECKBOXCNROWNER ctlSubclassCheckboxContainer(HWND hwndCnr)
     719{
     720    PFNWP pfnwpCnrOrig;
     721    if (pfnwpCnrOrig = WinSubclassWindow(hwndCnr, fnwpSubclCheckboxCnr))
     722    {
     723        // cnr successfully subclassed:
     724        // create storage for both subclassed cnr and owner
     725        PCHECKBOXCNROWNER pcbco;
     726        if (pcbco = (PCHECKBOXCNROWNER)malloc(sizeof(CHECKBOXCNROWNER)))
     727        {
     728            memset(pcbco, 0, sizeof(CHECKBOXCNROWNER));
     729            pcbco->hwndCnr = hwndCnr;
     730            pcbco->usCnrID = WinQueryWindowUShort(hwndCnr, QWS_ID);
     731            pcbco->hwndOwner = WinQueryWindow(hwndCnr, QW_OWNER);
     732            pcbco->pfnwpCnrOrig = pfnwpCnrOrig;
     733
     734            pcbco->habCnr = WinQueryAnchorBlock(hwndCnr);
     735
     736            return (pcbco);
     737        }
     738    }
     739
     740    return NULL;
    674741}
    675742
     
    749816    if (hwndCnr)
    750817    {
    751         if (G_hbmCheckboxes == NULLHANDLE)
    752         {
    753             // first call:
    754             BITMAPINFOHEADER bmih;
    755             // load checkboxes bitmap
    756             G_hbmCheckboxes = WinGetSysBitmap(HWND_DESKTOP,
    757                                               SBMP_CHECKBOXES);
    758 
    759             // _Pmpf(("hbmCheckboxes: 0x%lX", G_hbmCheckboxes));
    760 
    761             // and compute size of one checkbox
    762             // (4 columns, 3 rows)
    763             GpiQueryBitmapParameters(G_hbmCheckboxes,
    764                                      &bmih);
    765             G_cxCheckbox = bmih.cx / 4;
    766         }
    767 
    768         BEGIN_CNRINFO()
    769         {
    770             cnrhSetView(CV_TREE | CV_ICON | CA_TREELINE | CA_OWNERDRAW | CV_MINI);
    771             cnrhSetTreeIndent(20);
    772             cnrhSetBmpOrIconSize(G_cxCheckbox, G_cxCheckbox);
    773             // cnrhSetSortFunc(fnCompareName);
    774         } END_CNRINFO(hwndCnr);
     818        ctlInitCheckboxContainer(hwndCnr);
    775819
    776820        if (    (hwndCnrOwner)
     
    779823        {
    780824            // subclass container owner
    781             PFNWP pfnwpOwnerOrig = WinSubclassWindow(hwndCnrOwner, ctl_fnwpSubclCheckboxCnrOwner);
     825            PFNWP pfnwpOwnerOrig = WinSubclassWindow(hwndCnrOwner, fnwpSubclCheckboxCnrOwner);
    782826            /* _Pmpf(("Subclassed hwnd 0x%lX: orig 0x%lX",
    783827                    hwndCnrOwner, pfnwpOwnerOrig)); */
     
    786830                // owner successfully subclassed:
    787831                // subclass container too
    788                 PFNWP pfnwpCnrOrig = WinSubclassWindow(hwndCnr, ctl_fnwpSubclCheckboxCnr);
    789                 if (pfnwpCnrOrig)
     832                PCHECKBOXCNROWNER pcbco;
     833                if (pcbco = ctlSubclassCheckboxContainer(hwndCnr))
    790834                {
    791                     // cnr successfully subclassed:
    792                     // create storage for both subclassed cnr and owner
    793                     PCHECKBOXCNROWNER pcbco = (PCHECKBOXCNROWNER)malloc(sizeof(CHECKBOXCNROWNER));
    794                     if (pcbco)
     835                    if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
    795836                    {
    796                         memset(pcbco, 0, sizeof(CHECKBOXCNROWNER));
    797                         pcbco->hwndCnr = hwndCnr;
    798                         pcbco->usCnrID = usCnrID;
    799                         pcbco->hwndOwner = hwndCnrOwner;
    800                         pcbco->pfnwpCnrOrig = pfnwpCnrOrig;
     837                        lstAppendItem(G_pllCnrOwners, pcbco);
     838                        DosReleaseMutexSem(G_hmtxCnrOwnersList);
     839                        brc = TRUE;
     840
    801841                        pcbco->pfnwpOwnerOrig = pfnwpOwnerOrig;
    802 
    803                         pcbco->habCnr = WinQueryAnchorBlock(hwndCnr);
    804 
    805                         if (WinRequestMutexSem(G_hmtxCnrOwnersList, 5000) == NO_ERROR)
    806                         {
    807                             lstAppendItem(G_pllCnrOwners, pcbco);
    808                             DosReleaseMutexSem(G_hmtxCnrOwnersList);
    809                             brc = TRUE;
    810                         }
    811842                    }
    812 
    813                     if (!brc)
    814                         // failed: unsubclass cnr
    815                         WinSubclassWindow(hwndCnr, pfnwpCnrOrig);
    816843                }
    817 
    818                 if (!brc)
    819                     // failed: unsubclass owner
    820                     WinSubclassWindow(hwndCnrOwner, pfnwpOwnerOrig);
    821844            }
    822845        }
     
    956979 *      ID and updates that record enablement. If
    957980 *      the record is disabled, it's painted halftoned
    958  *      by ctl_fnwpSubclCheckboxCnr.
     981 *      by fnwpSubclCheckboxCnr.
    959982 *
    960983 *@@added V0.9.1 (99-12-03) [umoeller]
  • trunk/src/helpers/dialog.c

    r142 r146  
    109109    POINTL      ptlTotalOfs;
    110110
    111     LINKLIST    llControls;     // linked list of all PCOLUMNDEF structs,
    112                                  // in the order in which windows were
    113                                  // created
     111    PLINKLIST   pllControls;            // linked list of HWNDs in the order
     112                                        // in which controls were created;
     113                                        // ptr can be NULL
    114114
    115115    PCSZ        pcszControlsFont;  // from dlghCreateDlg
     
    910910                                      pcszFont);
    911911
    912             lstAppendItem(&pDlgData->llControls,
    913                           pColumnDef);
     912            // append window that was created
     913            // V0.9.18 (2002-03-03) [umoeller]
     914            if (pDlgData->pllControls)
     915                lstAppendItem(pDlgData->pllControls,
     916                              (PVOID)pColumnDef->hwndControl);
    914917
    915918            // if this is the first control with WS_TABSTOP,
     
    14551458 *
    14561459 *@@added V0.9.15 (2001-08-26) [umoeller]
     1460 *@@changed V0.9.18 (2002-03-03) [umoeller]: aded pllWindows
    14571461 */
    14581462
    14591463static APIRET Dlg0_Init(PDLGPRIVATE *ppDlgData,
    1460                         PCSZ pcszControlsFont)
     1464                        PCSZ pcszControlsFont,
     1465                        PLINKLIST pllControls)
    14611466{
    14621467    PDLGPRIVATE pDlgData;
     
    14651470    ZERO(pDlgData);
    14661471    lstInit(&pDlgData->llTables, FALSE);
    1467     lstInit(&pDlgData->llControls, FALSE);
     1472
     1473    if (pllControls)
     1474        pDlgData->pllControls = pllControls;
    14681475
    14691476    pDlgData->pcszControlsFont = pcszControlsFont;
     
    17561763
    17571764        lstClear(&pDlgData->llTables);
    1758         lstClear(&pDlgData->llControls);
    17591765
    17601766        free(pDlgData);
     
    20402046
    20412047    if (!(arc = Dlg0_Init(&pDlgData,
    2042                           pcszControlsFont)))
     2048                          pcszControlsFont,
     2049                          NULL)))
    20432050    {
    20442051        if (!(arc = Dlg1_ParseTables(pDlgData,
     
    22042211 *          except that the frame is already created.
    22052212 *
    2206  *      --  DFFL_RESIZEFRAME: hwndDlg should be resized so
    2207  *          that it will properly surround the controls.
    2208  *
    2209  *          This can only be used in conjunction with
    2210  *          DFFL_RESIZEFRAME.
     2213 *      If pszlClient is specified, it receives the required
     2214 *      size of the client to surround all controls properly.
     2215 *      You can then use dlghResizeFrame to resize the frame
     2216 *      with a bit of spacing, if desired.
    22112217 *
    22122218 *@@added V0.9.16 (2001-09-29) [umoeller]
     2219 *@@changed V0.9.18 (2002-03-03) [umoeller]: added pszlClient, fixed output
    22132220 */
    22142221
     
    22172224                     ULONG cDlgItems,           // in: array item count (NOT array size)
    22182225                     PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
    2219                      ULONG flFlags)             // in: DFFL_* flags
     2226                     ULONG flFlags,             // in: DFFL_* flags
     2227                     PSIZEL pszlClient,         // out: size of all controls (ptr can be NULL)
     2228                     PVOID *ppllControls)   // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
    22202229{
    22212230    APIRET      arc = NO_ERROR;
     
    22242233
    22252234    PDLGPRIVATE  pDlgData = NULL;
     2235    PLINKLIST   pllControls = NULL;
    22262236
    22272237    /*
     
    22302240     */
    22312241
     2242    if (ppllControls)
     2243        pllControls = *(PLINKLIST*)ppllControls = lstCreate(FALSE);
     2244
    22322245    if (!(arc = Dlg0_Init(&pDlgData,
    2233                           pcszControlsFont)))
     2246                          pcszControlsFont,
     2247                          pllControls)))
    22342248    {
    22352249        if (!(arc = Dlg1_ParseTables(pDlgData,
     
    22372251                                     cDlgItems)))
    22382252        {
     2253            HWND hwndFocusItem;
     2254
    22392255            /*
    22402256             *  2) create empty dialog frame
     
    22422258             */
    22432259
    2244             HWND    hwndFocusItem = NULLHANDLE;
    2245             SIZEL   szlClient = {0};
    2246             RECTL   rclClient;
    2247 
    22482260            pDlgData->hwndDlg = hwndDlg;
    22492261
     
    22552267            Dlg2_CalcSizes(pDlgData);
    22562268
    2257             // WinSubclassWindow(hwndDlg, pfnwpDialogProc);
    2258 
    2259             /*
    2260              *  4) compute size of dialog client from total
    2261              *     size of all controls
    2262              */
    2263 
    2264             if (flFlags & DFFL_RESIZEFRAME)
     2269            if (pszlClient)
    22652270            {
    2266                 // calculate the frame size from the client size
    2267                 rclClient.xLeft = 10;
    2268                 rclClient.yBottom = 10;
    2269                 rclClient.xRight = szlClient.cx + 2 * SPACING;
    2270                 rclClient.yTop = szlClient.cy + 2 * SPACING;
    2271                 WinCalcFrameRect(hwndDlg,
    2272                                  &rclClient,
    2273                                  FALSE);            // frame from client
    2274 
    2275                 WinSetWindowPos(hwndDlg,
    2276                                 0,
    2277                                 10,
    2278                                 10,
    2279                                 rclClient.xRight,
    2280                                 rclClient.yTop,
    2281                                 SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
     2271                pszlClient->cx = pDlgData->szlClient.cx + 2 * SPACING;
     2272                pszlClient->cy = pDlgData->szlClient.cy + 2 * SPACING;
    22822273            }
    22832274
     
    23032294
    23042295    return (arc);
     2296}
     2297
     2298/*
     2299 *@@ dlghResizeFrame:
     2300 *
     2301 *@@added V0.9.18 (2002-03-03) [umoeller]
     2302 */
     2303
     2304VOID dlghResizeFrame(HWND hwndDlg,
     2305                     PSIZEL pszlClient)
     2306{
     2307    // calculate the frame size from the client size
     2308    RECTL   rclClient;
     2309    rclClient.xLeft = 10;
     2310    rclClient.yBottom = 10;
     2311    rclClient.xRight = pszlClient->cx;
     2312    rclClient.yTop = pszlClient->cy;
     2313    WinCalcFrameRect(hwndDlg,
     2314                     &rclClient,
     2315                     FALSE);            // frame from client
     2316
     2317    WinSetWindowPos(hwndDlg,
     2318                    0,
     2319                    10,
     2320                    10,
     2321                    rclClient.xRight,
     2322                    rclClient.yTop,
     2323                    SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
    23052324}
    23062325
  • trunk/src/helpers/dosh.c

    r142 r146  
    29162916 *      is _not_ converted WRT the line format.
    29172917 *
     2918 *      If CTRL-Z (ASCII 26) is encountered in the
     2919 *      content, it is set to the null character
     2920 *      instead (V0.9.18).
     2921 *
    29182922 *      This returns the APIRET of DosOpen and DosRead.
    29192923 *      If any error occured, no buffer was allocated.
     
    29242928 *@@changed V0.9.16 (2002-01-05) [umoeller]: added pcbRead
    29252929 *@@changed V0.9.16 (2002-01-05) [umoeller]: rewritten using doshOpen
     2930 *@@changed V0.9.18 (2002-03-08) [umoeller]: fixed ctrl-z (EOF) bug
    29262931 */
    29272932
     
    29552960                else
    29562961                {
     2962                    PSZ p;
    29572963                    pszContent[cbRead] = '\0';
     2964
     2965                    // check if we have a ctrl-z (EOF) marker
     2966                    // this is present, for example, in config.sys
     2967                    // after install
     2968                    // V0.9.18 (2002-03-08) [umoeller]
     2969                    if (p = strchr(pszContent, '\26'))
     2970                    {
     2971                        *p = '\0';
     2972                        cbRead = p - pszContent;
     2973                    }
     2974
    29582975                    *ppszContent = pszContent;
    29592976                    if (pcbRead)
     
    29682985        doshClose(&pFile);
    29692986    }
    2970 
    2971     /*
    2972     ULONG   ulSize,
    2973             ulBytesRead = 0,
    2974             ulAction, ulLocal;
    2975     HFILE   hFile;
    2976     PSZ     pszContent = NULL;
    2977 
    2978     APIRET arc;
    2979 
    2980     *ppszContent = 0;
    2981 
    2982     if (!(arc = DosOpen((PSZ)pcszFile,
    2983                         &hFile,
    2984                         &ulAction,                      // action taken
    2985                         5000L,                          // primary allocation size
    2986                         FILE_ARCHIVED | FILE_NORMAL,    // file attribute
    2987                         OPEN_ACTION_OPEN_IF_EXISTS,     // open flags
    2988                         OPEN_FLAGS_NOINHERIT
    2989                            | OPEN_SHARE_DENYNONE
    2990                            | OPEN_ACCESS_READONLY,      // read-only mode
    2991                         NULL)))                         // no EAs
    2992     {
    2993         if (!(arc = doshQueryFileSize(hFile, &ulSize)))
    2994         {
    2995             pszContent = (PSZ)malloc(ulSize+1);
    2996 
    2997             if (!(arc = DosSetFilePtr(hFile,
    2998                                       0L,
    2999                                       FILE_BEGIN,
    3000                                       &ulLocal)))
    3001                 if (!(arc = DosRead(hFile,
    3002                                     pszContent,
    3003                                     ulSize,
    3004                                     &ulBytesRead)))
    3005                 {
    3006                     *(pszContent+ulBytesRead) = 0;
    3007                     // set output buffer pointer
    3008                     *ppszContent = pszContent;
    3009 
    3010                     if (pcbRead)
    3011                         *pcbRead = ulBytesRead + 1;
    3012                 }
    3013 
    3014             if (arc)
    3015                 free(pszContent);
    3016         }
    3017         DosClose(hFile);
    3018     }
    3019     */
    30202987
    30212988    return (arc);
  • trunk/src/helpers/winh.c

    r137 r146  
    23902390                 ul++)
    23912391            {
    2392                 HWND hwndThis = WinWindowFromID(hwndDlg, SHORT1FROMMP(*pmpThis));
    2393                 if (hwndThis)
     2392                HWND hwndThis;
     2393                if (hwndThis = WinWindowFromID(hwndDlg, SHORT1FROMMP(*pmpThis)))
    23942394                {
    23952395                    WinQueryWindowPos(hwndThis, pswpThis);
     
    35913591
    35923592HWND winhCreateStdWindow(HWND hwndFrameParent,      // in: normally HWND_DESKTOP
    3593                          PSWP pswpFrame,            // in: frame wnd pos
     3593                         PSWP pswpFrame,            // in: frame wnd pos (ptr can be NULL)
    35943594                         ULONG flFrameCreateFlags,  // in: FCF_* flags
    35953595                         ULONG ulFrameStyle,        // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE)
Note: See TracChangeset for help on using the changeset viewer.