Ignore:
Timestamp:
Aug 21, 2001, 7:29:38 PM (24 years ago)
Author:
umoeller
Message:

Misc updates.

File:
1 edited

Legend:

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

    r95 r98  
    100100    LINKLIST    llTables;
    101101
    102     HWND        hwndFirstFocus;
     102    HWND        hwndFirstFocus,
     103                hwndDefPushbutton;      // V0.9.14 (2001-08-21) [umoeller]
    103104
    104105    POINTL      ptlTotalOfs;
     
    719720                       )
    720721                        pDlgData->hwndFirstFocus = pColumnDef->hwndControl;
     722
     723                    // if this is the first default push button,
     724                    // go store it too
     725                    // V0.9.14 (2001-08-21) [umoeller]
     726                    if (    (!pDlgData->hwndDefPushbutton)
     727                         && ((ULONG)pControlDef->pcszClass == 0xffff0003L)
     728                         && (pControlDef->flStyle & BS_DEFAULT)
     729                       )
     730                        pDlgData->hwndDefPushbutton = pColumnDef->hwndControl;
    721731                }
    722732                else
     
    10481058 *      This does NOT use regular dialog templates from
    10491059 *      module resources. Instead, you pass in an array
    1050  *      of _DLGHITEM structures, which define the controls
     1060 *      of DLGHITEM structures, which define the controls
    10511061 *      and how they are to be formatted.
     1062 *
     1063 *      The main advantage compared to dialog resources is
     1064 *      that with this  function, you will never have to
     1065 *      define control _positions_. Instead, you only specify
     1066 *      the control _sizes_, and all positions are computed
     1067 *      automatically here. Even better, for many controls,
     1068 *      auto-sizing is supported according to the control's
     1069 *      text (e.g. for statics and checkboxes).
    10521070 *
    10531071 *      A regular standard dialog would use something like
     
    10681086 *      your dlg proc, use WinDefDlgProc as usual.
    10691087 *
    1070  *      There is NO run-time overhead after creation; after this
    1071  *      function returns, the dialog is a standard dialog as if
    1072  *      loaded from WinLoadDlg.
    1073  *
    1074  *      The array of _DLGHITEM structures defines how the
     1088 *      There is NO run-time overhead for either code or memory
     1089 *      after dialog creation; after this function returns, the
     1090 *      dialog is a standard dialog as if loaded from WinLoadDlg.
     1091 *      The array of DLGHITEM structures defines how the
    10751092 *      dialog is set up. All this is ONLY used by this function
    10761093 *      and NOT needed after the dialog has been created.
    10771094 *
    1078  *      In _DLGHITEM, the "Type" field determines what this
     1095 *      In DLGHITEM, the "Type" field determines what this
    10791096 *      structure defines. A number of handy macros have been
    10801097 *      defined to make this easier and to provide type-checking
    1081  *      at compile time.
     1098 *      at compile time. See dialog.h for more.
    10821099 *
    10831100 *      Essentially, such a dialog item operates similarly to
     
    11111128 *
    11121129 *      --  CONTROL_DEF(pDef) defines a control in a table row.
    1113  *          pDef must point to a _CONTROLDEF structure.
    1114  *
    1115  *          The main difference (and advantage) of this
    1116  *          function is that there is NO information in
    1117  *          _CONTROLDEF about a control's _position_.
     1130 *          pDef must point to a CONTROLDEF structure.
     1131 *
     1132 *          Again, there is is NO information in
     1133 *          CONTROLDEF about a control's _position_.
    11181134 *          Instead, the structure only contains the _size_
    11191135 *          of the control. All positions are computed by
     
    12511267 +                                        DlgTemplate,      // DLGHITEM array
    12521268 +                                        ARRAYITEMCOUNT(DlgTemplate),
    1253  +                                        NULL))
     1269 +                                        NULL,             // mp2 for WM_INITDLG
     1270 +                                        "9.WarpSans"))    // default font
    12541271 +          {
    12551272 +              ULONG idReturn = WinProcessDlg(hwndDlg);
     
    12591276 *@@changed V0.9.14 (2001-07-07) [umoeller]: fixed disabled mouse with hwndOwner == HWND_DESKTOP
    12601277 *@@changed V0.9.14 (2001-08-01) [umoeller]: fixed major memory leaks with nested tables
     1278 *@@changed V0.9.14 (2001-08-21) [umoeller]: fixed default push button problems
    12611279 */
    12621280
     
    13171335
    13181336                // push the current table on the stack
    1319                 PSTACKITEM pStackItem = NEW(STACKITEM);
    1320                 if (pStackItem)
     1337                PSTACKITEM pStackItem;
     1338                if (!(pStackItem = NEW(STACKITEM)))
     1339                {
     1340                    arc = ERROR_NOT_ENOUGH_MEMORY;
     1341                    break;
     1342                }
     1343                else
    13211344                {
    13221345                    pStackItem->pLastTable = pCurrentTable;
     
    13261349
    13271350                // create new table
    1328                 pCurrentTable = NEW(TABLEDEF);
    1329                 if (!pCurrentTable)
     1351                if (!(pCurrentTable = NEW(TABLEDEF)))
    13301352                    arc = ERROR_NOT_ENOUGH_MEMORY;
    13311353                else
     
    13721394                {
    13731395                    // create new row
    1374                     pCurrentRow = NEW(ROWDEF);
    1375                     if (!pCurrentRow)
     1396                    if (!(pCurrentRow = NEW(ROWDEF)))
    13761397                        arc = ERROR_NOT_ENOUGH_MEMORY;
    13771398                    else
     
    14651486            hwndOwner = NULLHANDLE;
    14661487
    1467         pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP,
    1468                                             WC_FRAME,
    1469                                             (PSZ)pcszDlgTitle,
    1470                                             flStyle,        // style; invisible for now
    1471                                             0, 0, 0, 0,
    1472                                             hwndOwner,
    1473                                             HWND_TOP,
    1474                                             0,              // ID
    1475                                             &fcData,
    1476                                             NULL);          // presparams
    1477 
    1478         if (!pDlgData->hwndDlg)
     1488        if (!(pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP,
     1489                                                  WC_FRAME,
     1490                                                  (PSZ)pcszDlgTitle,
     1491                                                  flStyle,        // style; invisible for now
     1492                                                  0, 0, 0, 0,
     1493                                                  hwndOwner,
     1494                                                  HWND_TOP,
     1495                                                  0,              // ID
     1496                                                  &fcData,
     1497                                                  NULL)))          // presparams
    14791498            arc = DLGERR_CANNOT_CREATE_FRAME;
    14801499        else
     
    14931512                       &szlClient,
    14941513                       PROCESS_CALC_SIZES);
    1495 
     1514                // this goes into major recursions...
     1515
     1516            // free the cached font resources that
     1517            // might have been created here
    14961518            if (pDlgData->lcidLast)
    14971519            {
     
    15011523            if (pDlgData->hps)
    15021524                WinReleasePS(pDlgData->hps);
     1525
     1526            WinSubclassWindow(hwndDlg, pfnwpDialogProc);
    15031527
    15041528            /*
     
    15061530             *     size of all controls
    15071531             */
    1508 
    1509             WinSubclassWindow(hwndDlg, pfnwpDialogProc);
    15101532
    15111533            // calculate the frame size from the client size
     
    15461568                       &szlClient,
    15471569                       PROCESS_CREATE_CONTROLS);
     1570
     1571            if (pDlgData->hwndDefPushbutton)
     1572                // we had a default pushbutton:
     1573                // go set it V0.9.14 (2001-08-21) [umoeller]
     1574                WinSetWindowULong(pDlgData->hwndDlg,
     1575                                  QWL_DEFBUTTON,
     1576                                  pDlgData->hwndDefPushbutton);
    15481577
    15491578            /*
Note: See TracChangeset for help on using the changeset viewer.