Changeset 98 for trunk/src/helpers/dialog.c
- Timestamp:
- Aug 21, 2001, 7:29:38 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r95 r98 100 100 LINKLIST llTables; 101 101 102 HWND hwndFirstFocus; 102 HWND hwndFirstFocus, 103 hwndDefPushbutton; // V0.9.14 (2001-08-21) [umoeller] 103 104 104 105 POINTL ptlTotalOfs; … … 719 720 ) 720 721 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; 721 731 } 722 732 else … … 1048 1058 * This does NOT use regular dialog templates from 1049 1059 * module resources. Instead, you pass in an array 1050 * of _DLGHITEM structures, which define the controls1060 * of DLGHITEM structures, which define the controls 1051 1061 * 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). 1052 1070 * 1053 1071 * A regular standard dialog would use something like … … 1068 1086 * your dlg proc, use WinDefDlgProc as usual. 1069 1087 * 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 1075 1092 * dialog is set up. All this is ONLY used by this function 1076 1093 * and NOT needed after the dialog has been created. 1077 1094 * 1078 * In _DLGHITEM, the "Type" field determines what this1095 * In DLGHITEM, the "Type" field determines what this 1079 1096 * structure defines. A number of handy macros have been 1080 1097 * defined to make this easier and to provide type-checking 1081 * at compile time. 1098 * at compile time. See dialog.h for more. 1082 1099 * 1083 1100 * Essentially, such a dialog item operates similarly to … … 1111 1128 * 1112 1129 * -- 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_. 1118 1134 * Instead, the structure only contains the _size_ 1119 1135 * of the control. All positions are computed by … … 1251 1267 + DlgTemplate, // DLGHITEM array 1252 1268 + ARRAYITEMCOUNT(DlgTemplate), 1253 + NULL)) 1269 + NULL, // mp2 for WM_INITDLG 1270 + "9.WarpSans")) // default font 1254 1271 + { 1255 1272 + ULONG idReturn = WinProcessDlg(hwndDlg); … … 1259 1276 *@@changed V0.9.14 (2001-07-07) [umoeller]: fixed disabled mouse with hwndOwner == HWND_DESKTOP 1260 1277 *@@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 1261 1279 */ 1262 1280 … … 1317 1335 1318 1336 // 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 1321 1344 { 1322 1345 pStackItem->pLastTable = pCurrentTable; … … 1326 1349 1327 1350 // create new table 1328 pCurrentTable = NEW(TABLEDEF); 1329 if (!pCurrentTable) 1351 if (!(pCurrentTable = NEW(TABLEDEF))) 1330 1352 arc = ERROR_NOT_ENOUGH_MEMORY; 1331 1353 else … … 1372 1394 { 1373 1395 // create new row 1374 pCurrentRow = NEW(ROWDEF); 1375 if (!pCurrentRow) 1396 if (!(pCurrentRow = NEW(ROWDEF))) 1376 1397 arc = ERROR_NOT_ENOUGH_MEMORY; 1377 1398 else … … 1465 1486 hwndOwner = NULLHANDLE; 1466 1487 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 1479 1498 arc = DLGERR_CANNOT_CREATE_FRAME; 1480 1499 else … … 1493 1512 &szlClient, 1494 1513 PROCESS_CALC_SIZES); 1495 1514 // this goes into major recursions... 1515 1516 // free the cached font resources that 1517 // might have been created here 1496 1518 if (pDlgData->lcidLast) 1497 1519 { … … 1501 1523 if (pDlgData->hps) 1502 1524 WinReleasePS(pDlgData->hps); 1525 1526 WinSubclassWindow(hwndDlg, pfnwpDialogProc); 1503 1527 1504 1528 /* … … 1506 1530 * size of all controls 1507 1531 */ 1508 1509 WinSubclassWindow(hwndDlg, pfnwpDialogProc);1510 1532 1511 1533 // calculate the frame size from the client size … … 1546 1568 &szlClient, 1547 1569 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); 1548 1577 1549 1578 /*
Note:
See TracChangeset
for help on using the changeset viewer.