Changeset 159 for trunk/src/helpers/dialog.c
- Timestamp:
- Apr 25, 2002, 7:25:16 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r156 r159 11 11 * dialog behavior in regular window procs (see 12 12 * dlghSetPrevFocus and others). 13 * 14 * If you are out to find all workarounds to get certain 15 * buggy PM controls aligned right, this file is definitely 16 * the place. 13 17 * 14 18 * Usage: All PM programs. … … 42 46 // as unsigned char 43 47 48 #define INCL_DOSPROCESS 49 #define INCL_DOSEXCEPTIONS 44 50 #define INCL_DOSERRORS 45 51 … … 52 58 #define INCL_WINBUTTONS 53 59 #define INCL_WINENTRYFIELDS 60 #define INCL_WINSTDCNR 54 61 #define INCL_WINSYS 55 62 … … 62 69 #include <string.h> 63 70 #include <stdio.h> 71 #include <setjmp.h> 64 72 65 73 #include "setup.h" // code generation and debugging options … … 67 75 #include "helpers\comctl.h" 68 76 #include "helpers\dialog.h" 77 #include "helpers\except.h" 69 78 #include "helpers\gpih.h" 70 79 #include "helpers\linklist.h" … … 128 137 cyBorder; // cached now V0.9.19 (2002-04-17) [umoeller] 129 138 139 double dFactorX, // correlation factors for dialog units 140 dFactorY; // V0.9.19 (2002-04-24) [umoeller] 141 130 142 } DLGPRIVATE, *PDLGPRIVATE; 143 144 // macros for the dlg units conversion; 145 #define FACTOR_X (pDlgData->dFactorX) 146 #ifdef USE_SQUARE_CORRELATION 147 #define FACTOR_Y (pDlgData->dFactorX) 148 #else 149 #define FACTOR_Y (pDlgData->dFactorY) 150 #endif 131 151 132 152 typedef struct _COLUMNDEF *PCOLUMNDEF; … … 167 187 PVOID pvDefinition; // either a PTABLEDEF or a PCONTROLDEF 168 188 169 CONTROLPOS cpControl, // real pos and size of control 170 cpColumn; // pos and size of column; can be wider, spacings applied 189 CONTROLPOS cpControl, // real pos and size of control; if the control is 190 // a subtable, this receives the size of the table 191 // without spacings 192 cpColumn; // pos and size of column; this is the size of the 193 // column plus the spacing from the CONTROLDEF 194 // applied 195 // For PM group controls around tables, this is 196 // receives the following spacings: 197 // x += GROUP_INNER_SPACING_X + CONTROLDEF.ulSpacing 198 // y += GROUP_INNER_SPACING_Y + CONTROLDEF.ulSpacing 199 // cx += 2 * GROUP_INNER_SPACING_X + 2 * CONTROLDEF.ulSpacing 200 // cy += 2 * GROUP_INNER_SPACING_Y 201 // + GROUP_INNER_SPACING_EXTRA_TOP 202 // + 2 * CONTROLDEF.duSpacing 171 203 172 204 HWND hwndControl; // created control; NULLHANDLE for tables always … … 338 370 */ 339 371 rcl.xRight = ulWidth; 340 if (pControlDef->szlControlProposed.cy > 0) 341 rcl.yTop = pControlDef->szlControlProposed.cy; // V0.9.12 (2001-05-31) [umoeller] 372 if (pControlDef->szlDlgUnits.cy > 0) 373 rcl.yTop = pControlDef->szlDlgUnits.cy * FACTOR_Y; 374 // V0.9.12 (2001-05-31) [umoeller] 342 375 else 343 376 rcl.yTop = winhQueryScreenCY() * 2 / 3; … … 402 435 { 403 436 // give a little extra width for the box bitmap 404 pszlAuto->cx += 20; // @@todo 437 // V0.9.19 (2002-04-24) [umoeller] 438 pszlAuto->cx += ctlQueryCheckboxSize() + 4; 405 439 // and height 406 440 pszlAuto->cy += 2; … … 476 510 *@@changed V0.9.16 (2002-02-02) [umoeller]: added support for explicit group size 477 511 *@@changed V0.9.19 (2002-04-17) [umoeller]: fixes for the STUPID drop-down comboboxes 512 *@@changed V0.9.19 (2002-04-24) [umoeller]: fixed PM groups alignment 513 *@@changed V0.9.19 (2002-04-24) [umoeller]: added resolution correlation 478 514 */ 479 515 … … 484 520 APIRET arc = NO_ERROR; 485 521 PCONTROLDEF pControlDef = NULL; 486 ULONG ulExtraCX= 0,487 ulExtraCY= 0;522 ULONG xExtraColumn = 0, 523 yExtraColumn = 0; 488 524 489 525 if (pColumnDef->fIsNestedTable) … … 501 537 502 538 // should we create a PM control around the table? 503 if (p TableDef->pCtlDef)539 if (pControlDef = pTableDef->pCtlDef) 504 540 { 505 541 // yes: 542 LONG cxCalc = pControlDef->szlDlgUnits.cx * FACTOR_X, 543 cyCalc = pControlDef->szlDlgUnits.cy * FACTOR_Y; 506 544 507 545 // check if maybe an explicit size was specified 508 // for the group; if that is larger than what546 // for the group; only if that is larger than what 509 547 // we've calculated above, use it instead 510 if ( pTableDef->pCtlDef->szlControlProposed.cx> pColumnDef->cpControl.cx)548 if (cxCalc > pColumnDef->cpControl.cx) 511 549 // should be -1 for auto-size 512 pColumnDef->cpControl.cx = pTableDef->pCtlDef->szlControlProposed.cx;513 514 if ( pTableDef->pCtlDef->szlControlProposed.cy> pColumnDef->cpControl.cy)550 pColumnDef->cpControl.cx = cxCalc; 551 552 if (cyCalc > pColumnDef->cpControl.cy) 515 553 // should be -1 for auto-size 516 pColumnDef->cpControl.cy = pTableDef->pCtlDef->szlControlProposed.cy; 517 518 // in any case, make this wider 519 ulExtraCX = 2 * PM_GROUP_SPACING_X; 520 ulExtraCY = (PM_GROUP_SPACING_X + PM_GROUP_SPACING_TOP); 554 pColumnDef->cpControl.cy = cyCalc; 555 556 // in any case, add the inner spacing so that the group 557 // will be large enough 558 // fixed V0.9.19 (2002-04-24) [umoeller] 559 xExtraColumn = ( (2 * pControlDef->duSpacing) 560 + 2 * GROUP_INNER_SPACING_X 561 ) * FACTOR_X; 562 yExtraColumn = ( (2 * pControlDef->duSpacing) 563 + GROUP_OUTER_SPACING_BOTTOM 564 + GROUP_INNER_SPACING_BOTTOM 565 + GROUP_INNER_SPACING_TOP 566 + GROUP_OUTER_SPACING_TOP 567 ) * FACTOR_Y; 521 568 } 522 569 } … … 533 580 if (ProcessMode == PROCESS_1_CALC_SIZES) 534 581 { 535 if ( (pControlDef->szlControlProposed.cx == -1) 536 || (pControlDef->szlControlProposed.cy == -1) 582 // V0.9.19 (2002-04-24) [umoeller]: added resolution correlation 583 LONG cxCalc = pControlDef->szlDlgUnits.cx * FACTOR_X, 584 cyCalc = pControlDef->szlDlgUnits.cy * FACTOR_Y; 585 586 if ( (pControlDef->szlDlgUnits.cx == -1) 587 || (pControlDef->szlDlgUnits.cy == -1) 537 588 ) 538 589 { 539 590 ULONG ulWidth; 540 if (pControlDef->szl ControlProposed.cx == -1)591 if (pControlDef->szlDlgUnits.cx == -1) 541 592 ulWidth = 1000; 542 593 else 543 ulWidth = pControlDef->szlControlProposed.cx;594 ulWidth = cxCalc; 544 595 arc = CalcAutoSize(pControlDef, 545 596 ulWidth, … … 548 599 } 549 600 550 if ( (pControlDef->szl ControlProposed.cx < -1)551 && (pControlDef->szl ControlProposed.cx >= -100)601 if ( (pControlDef->szlDlgUnits.cx < -1) 602 && (pControlDef->szlDlgUnits.cx >= -100) 552 603 ) 553 604 { … … 558 609 } 559 610 560 if ( (pControlDef->szl ControlProposed.cy < -1)561 && (pControlDef->szl ControlProposed.cy >= -100)611 if ( (pControlDef->szlDlgUnits.cy < -1) 612 && (pControlDef->szlDlgUnits.cy >= -100) 562 613 ) 563 614 { … … 570 621 if (!arc) 571 622 { 572 if (pControlDef->szlControlProposed.cx < 0) 623 if (pControlDef->szlDlgUnits.cx < 0) 624 // this was autosize: 573 625 pColumnDef->cpControl.cx = szlAuto.cx; 574 626 else 575 pColumnDef->cpControl.cx = pControlDef->szlControlProposed.cx; 576 577 if (pControlDef->szlControlProposed.cy < 0) 627 // this was explicit: use converted size 628 // V0.9.19 (2002-04-24) [umoeller] 629 pColumnDef->cpControl.cx = cxCalc; 630 631 if (pControlDef->szlDlgUnits.cy < 0) 632 // this was autosize: 578 633 pColumnDef->cpControl.cy = szlAuto.cy; 579 634 else 580 pColumnDef->cpControl.cy = pControlDef->szlControlProposed.cy; 635 // this was explicit: use converted size 636 // V0.9.19 (2002-04-24) [umoeller] 637 pColumnDef->cpControl.cy = cyCalc; 581 638 } 582 639 583 640 } // end if (ProcessMode == PROCESS_1_CALC_SIZES) 584 641 585 ulExtraCX 586 = ulExtraCY 587 = (2 * pControlDef->ulSpacing); 642 xExtraColumn = 2 * (pControlDef->duSpacing * FACTOR_X); 643 yExtraColumn = 2 * (pControlDef->duSpacing * FACTOR_Y); 588 644 } 589 645 590 646 pColumnDef->cpColumn.cx = pColumnDef->cpControl.cx 591 + ulExtraCX;647 + xExtraColumn; 592 648 pColumnDef->cpColumn.cy = pColumnDef->cpControl.cy 593 + ulExtraCY;649 + yExtraColumn; 594 650 595 651 if ( (pControlDef) … … 614 670 + pDlgData->fmLast.lExternalLeading 615 671 + 2 * cyMargin 616 + ulExtraCY;672 + yExtraColumn; 617 673 } 618 674 } … … 628 684 *@@added V0.9.15 (2001-08-26) [umoeller] 629 685 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET 686 *@@changed V0.9.19 (2002-04-24) [umoeller]: fixed PM groups alignment 630 687 */ 631 688 … … 638 695 639 696 // calculate column position: this includes spacing 640 LONG lSpacingX= 0,641 lSpacingY= 0;697 LONG xSpacingControl = 0, 698 ySpacingControl = 0; 642 699 643 700 // column position = *plX on ProcessRow stack … … 672 729 { 673 730 // yes: 674 lSpacingX = PM_GROUP_SPACING_X; // V0.9.16 (2001-10-15) [umoeller] 675 lSpacingY = PM_GROUP_SPACING_X; // V0.9.16 (2001-10-15) [umoeller] 731 // V0.9.19 (2002-04-24) [umoeller] 732 xSpacingControl = ( pTableDef->pCtlDef->duSpacing 733 + GROUP_INNER_SPACING_X 734 ) * FACTOR_X; 735 ySpacingControl = ( pTableDef->pCtlDef->duSpacing 736 + GROUP_OUTER_SPACING_BOTTOM 737 + GROUP_INNER_SPACING_BOTTOM 738 ) * FACTOR_Y; 676 739 } 677 740 } … … 680 743 // no nested table, but control: 681 744 PCONTROLDEF pControlDef = (PCONTROLDEF)pColumnDef->pvDefinition; 682 lSpacingX = lSpacingY = pControlDef->ulSpacing; 745 xSpacingControl = pControlDef->duSpacing * FACTOR_X; 746 ySpacingControl = pControlDef->duSpacing * FACTOR_Y; 683 747 } 684 748 … … 688 752 // calculate CONTROL pos from COLUMN pos by applying spacing 689 753 pColumnDef->cpControl.x = (LONG)pColumnDef->cpColumn.x 690 + lSpacingX;754 + xSpacingControl; 691 755 pColumnDef->cpControl.y = (LONG)pColumnDef->cpColumn.y 692 + lSpacingY;756 + ySpacingControl; 693 757 694 758 if (pColumnDef->fIsNestedTable) … … 716 780 *@@changed V0.9.16 (2001-12-08) [umoeller]: fixed entry field ES_MARGIN positioning 717 781 *@@changed V0.9.19 (2002-04-17) [umoeller]: fixes for the STUPID drop-down comboboxes 782 *@@changed V0.9.19 (2002-04-24) [umoeller]: fixed PM groups alignment 718 783 */ 719 784 … … 747 812 // (do this AFTER the other controls from recursing, 748 813 // otherwise the stupid container doesn't show up) 749 if (p TableDef->pCtlDef)814 if (pControlDef = pTableDef->pCtlDef) 750 815 { 751 816 // yes: 752 817 // pcp = &pColumnDef->cpColumn; // !! not control 753 pControlDef = pTableDef->pCtlDef;754 818 pcszClass = pControlDef->pcszClass; 755 819 pcszTitle = pControlDef->pcszText; 756 820 flStyle = pControlDef->flStyle; 757 821 758 x = pColumnDef->cpColumn.x 822 // note: we do use cpControl, which is cpColumn plus 823 // spacings applied. But for groups, this is the 824 // following (see ColumnCalcPositions): 825 // V0.9.19 (2002-04-24) [umoeller] 826 // x is cpColumn.x plus GROUP_INNER_SPACING_X plus group control spacing 827 // y is cpColumn.y plus GROUP_INNER_SPACING_Y plus group control spacing 828 // cx is cpColumn.cx plus 2 * GROUP_INNER_SPACING_Y plus 2 * group control spacing 829 // cy is cpColumn.cy plus 2 * GROUP_INNER_SPACING_Y 830 // plus GROUP_INNER_SPACING_TOP 831 // plus 2 * group control spacing 832 // so this needs some hacks again 833 x = pColumnDef->cpControl.x 759 834 + pDlgData->ptlTotalOfs.x 760 + PM_GROUP_SPACING_X / 2;761 cx = pColumnDef->cpColumn.cx762 - PM_GROUP_SPACING_X;763 // note, just one spacing: for the _column_ size,764 // we have specified 2 X spacings765 y = pColumnDef->cpCo lumn.y835 - (GROUP_INNER_SPACING_X * FACTOR_X); 836 ; 837 cx = pColumnDef->cpControl.cx 838 + (2 * (GROUP_INNER_SPACING_X * FACTOR_X)); 839 ; 840 y = pColumnDef->cpControl.y 766 841 + pDlgData->ptlTotalOfs.y 767 + PM_GROUP_SPACING_X / 2; 768 // cy = pcp->cy - PM_GROUP_SPACING_X; 769 // cy = pcp->cy - /* PM_GROUP_SPACING_X - */ PM_GROUP_SPACING_TOP; 770 cy = pColumnDef->cpColumn.cy 771 - PM_GROUP_SPACING_X / 2; // - PM_GROUP_SPACING_TOP / 2; 842 - (GROUP_INNER_SPACING_BOTTOM * FACTOR_Y); 843 ; 844 cy = pColumnDef->cpControl.cy 845 + ( ( GROUP_INNER_SPACING_BOTTOM 846 + GROUP_INNER_SPACING_TOP 847 ) * FACTOR_Y); 848 ; 772 849 } 773 850 … … 848 925 pColumnDef->cpControl.cy)); 849 926 _Pmpf((" cyDelta = %d", cyDelta)); 850 y -= cyDelta + 3 * pDlgData->cyBorder + pControlDef->ulSpacing; 927 y -= cyDelta 928 + 3 * pDlgData->cyBorder 929 + pControlDef->duSpacing * FACTOR_Y; 851 930 // cy += cyDelta; 852 931 } … … 921 1000 winhSetPresColor(hwndDebug, PP_FOREGROUNDCOLOR, RGBCOL_DARKGREEN); 922 1001 923 /*924 1002 // and another one for the control size 925 1003 hwndDebug = … … 938 1016 NULL); 939 1017 winhSetPresColor(hwndDebug, PP_FOREGROUNDCOLOR, RGBCOL_RED); 940 */941 1018 } 942 1019 #endif … … 1081 1158 PCONTROLDEF pControlDef = (PCONTROLDEF)pColumnDef->pvDefinition; 1082 1159 1083 if ( (pControlDef->szl ControlProposed.cx < -1)1084 && (pControlDef->szl ControlProposed.cx >= -100)1160 if ( (pControlDef->szlDlgUnits.cx < -1) 1161 && (pControlDef->szlDlgUnits.cx >= -100) 1085 1162 ) 1086 1163 { … … 1088 1165 // this we ignored during PROCESS_1_CALC_SIZES 1089 1166 // (see ColumnCalcSizes); now set it to the 1090 // table width!1167 // percentage of the table width! 1091 1168 ULONG cxThis = pOwningRow->pOwningTable->cpTable.cx 1092 * -pControlDef->szlControlProposed.cx / 100; 1169 * -pControlDef->szlDlgUnits.cx 1170 / 100; 1093 1171 1094 1172 // but the table already has spacing applied, 1095 1173 // so reduce that 1096 1174 pColumnDef->cpControl.cx = cxThis 1097 - (2 * pControlDef->ulSpacing);1175 - (2 * (pControlDef->duSpacing * FACTOR_X)); 1098 1176 1099 1177 pColumnDef->cpColumn.cx = cxThis; 1100 1178 1101 1179 // now we might have to re-compute auto-size 1102 if (pControlDef->szl ControlProposed.cy == -1)1180 if (pControlDef->szlDlgUnits.cy == -1) 1103 1181 { 1104 1182 SIZEL szlAuto; … … 1115 1193 1116 1194 pColumnDef->cpControl.cy = szlAuto.cy; 1117 pColumnDef->cpColumn.cy = szlAuto.cy1118 + (2 * pControlDef->ulSpacing);1195 pColumnDef->cpColumn.cy = szlAuto.cy 1196 + (2 * (pControlDef->duSpacing * FACTOR_Y)); 1119 1197 } 1120 1198 } 1121 1199 } 1122 1200 1123 if ( (pControlDef->szl ControlProposed.cy < -1)1124 && (pControlDef->szl ControlProposed.cy >= -100)1201 if ( (pControlDef->szlDlgUnits.cy < -1) 1202 && (pControlDef->szlDlgUnits.cy >= -100) 1125 1203 ) 1126 1204 { 1127 1205 // same thing for CY, but this time we 1128 // take the row height1206 // take the percentage of the row height 1129 1207 ULONG cyThis = pOwningRow->cpRow.cy 1130 * -pControlDef->szlControlProposed.cy / 100; 1208 * -pControlDef->szlDlgUnits.cy 1209 / 100; 1131 1210 1132 1211 // but the table already has spacing applied, 1133 1212 // so reduce that 1134 pColumnDef->cpControl.cy = cyThis1135 - (2 * pControlDef->ulSpacing);1213 pColumnDef->cpControl.cy = cyThis 1214 - (2 * (pControlDef->duSpacing * FACTOR_Y)); 1136 1215 1137 1216 pColumnDef->cpColumn.cy = cyThis; … … 1510 1589 } STACKITEM, *PSTACKITEM; 1511 1590 1512 #define SPACING 101513 1514 1591 /* 1515 1592 *@@ Dlg0_Init: 1516 1593 * 1517 1594 *@@added V0.9.15 (2001-08-26) [umoeller] 1518 *@@changed V0.9.18 (2002-03-03) [umoeller]: aded pllWindows 1595 *@@changed V0.9.18 (2002-03-03) [umoeller]: added pllWindows 1596 *@@changed V0.9.19 (2002-04-24) [umoeller]: added resolution correlation 1519 1597 */ 1520 1598 … … 1523 1601 PLINKLIST pllControls) 1524 1602 { 1525 PDLGPRIVATE pDlgData; 1603 PDLGPRIVATE pDlgData; 1604 POINTL ptl = {100, 100}; 1605 1526 1606 if (!(pDlgData = NEW(DLGPRIVATE))) 1527 1607 return (ERROR_NOT_ENOUGH_MEMORY); … … 1537 1617 pDlgData->cxBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER); 1538 1618 pDlgData->cyBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER); 1619 1620 // check how many pixels we get out of the 1621 // dlgunits (100/100) for mapping all sizes 1622 // V0.9.19 (2002-04-24) [umoeller] 1623 if (WinMapDlgPoints(NULLHANDLE, 1624 &ptl, 1625 1, 1626 TRUE)) 1627 { 1628 // this worked: 1629 // for 1024x768, I get 200/250 out of the above, 1630 // so calculate a factor from that; we multiply 1631 // szlDlgUnits with this factor when calculating 1632 // the sizes 1633 pDlgData->dFactorX = (double)ptl.x / (double)100; // 2 on 1024x768 1634 pDlgData->dFactorY = (double)ptl.y / (double)100; // 2.5 on 1024x768 1635 } 1636 else 1637 { 1638 // didn't work: 1639 pDlgData->dFactorX = 2; 1640 pDlgData->dFactorY = 2.5; 1641 } 1539 1642 1540 1643 *ppDlgData = pDlgData; … … 1777 1880 */ 1778 1881 1779 pDlgData->ptlTotalOfs.x 1780 = pDlgData->ptlTotalOfs.y 1781 = SPACING; 1882 pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X; 1883 pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y; 1782 1884 1783 1885 ProcessAll(pDlgData, … … 2088 2190 *@@changed V0.9.14 (2001-08-21) [umoeller]: fixed default push button problems 2089 2191 *@@changed V0.9.16 (2001-12-06) [umoeller]: fixed bad owner if not direct desktop child 2192 *@@changed V0.9.19 (2002-04-24) [umoeller]: added excpt handling 2090 2193 */ 2091 2194 … … 2102 2205 APIRET arc = NO_ERROR; 2103 2206 2104 ULONG ul; 2105 2106 PDLGPRIVATE pDlgData = NULL; 2107 2108 HWND hwndDesktop = WinQueryDesktopWindow(NULLHANDLE, NULLHANDLE); 2109 // works with a null HAB 2110 2111 /* 2112 * 1) parse the table and create structures from it 2113 * 2114 */ 2115 2116 if (!(arc = Dlg0_Init(&pDlgData, 2117 pcszControlsFont, 2118 NULL))) 2119 { 2120 if (!(arc = Dlg1_ParseTables(pDlgData, 2121 paDlgItems, 2122 cDlgItems))) 2123 { 2124 /* 2125 * 2) create empty dialog frame 2126 * 2127 */ 2128 2129 FRAMECDATA fcData = {0}; 2130 ULONG flStyle = 0; 2131 HWND hwndOwnersParent; 2132 2133 fcData.cb = sizeof(FRAMECDATA); 2134 fcData.flCreateFlags = flCreateFlags | 0x40000000L; 2135 2136 if (flCreateFlags & FCF_SIZEBORDER) 2137 // dialog has size border: 2138 // add "clip siblings" style 2139 flStyle |= WS_CLIPSIBLINGS; 2140 2141 if (hwndOwner == HWND_DESKTOP) 2142 // there's some dumb XWorkplace code left 2143 // which uses this, and this disables the 2144 // mouse for some reason 2145 // V0.9.14 (2001-07-07) [umoeller] 2146 hwndOwner = NULLHANDLE; 2147 2148 // now, make sure the owner window is child of 2149 // HWND_DESKTOP... if it is not, we'll only disable 2150 // some dumb child window, which is not sufficient 2151 // V0.9.16 (2001-12-06) [umoeller] 2152 while ( (hwndOwner) 2153 && (hwndOwnersParent = WinQueryWindow(hwndOwner, QW_PARENT)) 2154 && (hwndOwnersParent != hwndDesktop) 2155 ) 2156 hwndOwner = hwndOwnersParent; 2157 2158 if (!(pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP, 2159 WC_FRAME, 2160 (PSZ)pcszDlgTitle, 2161 flStyle, // style; invisible for now 2162 0, 0, 0, 0, 2163 hwndOwner, 2164 HWND_TOP, 2165 0, // ID 2166 &fcData, 2167 NULL))) // presparams 2168 arc = DLGERR_CANNOT_CREATE_FRAME; 2169 else 2207 TRY_LOUD(excpt1) 2208 { 2209 ULONG ul; 2210 2211 PDLGPRIVATE pDlgData = NULL; 2212 2213 HWND hwndDesktop = WinQueryDesktopWindow(NULLHANDLE, NULLHANDLE); 2214 // works with a null HAB 2215 2216 /* 2217 * 1) parse the table and create structures from it 2218 * 2219 */ 2220 2221 if (!(arc = Dlg0_Init(&pDlgData, 2222 pcszControlsFont, 2223 NULL))) 2224 { 2225 if (!(arc = Dlg1_ParseTables(pDlgData, 2226 paDlgItems, 2227 cDlgItems))) 2170 2228 { 2171 HWND hwndDlg = pDlgData->hwndDlg;2172 HWND hwndFocusItem = NULLHANDLE;2173 RECTL rclClient;2174 2175 2229 /* 2176 * 3) compute size of all controls2230 * 2) create empty dialog frame 2177 2231 * 2178 2232 */ 2179 2233 2180 if (!(arc = Dlg2_CalcSizes(pDlgData))) 2234 FRAMECDATA fcData = {0}; 2235 ULONG flStyle = 0; 2236 HWND hwndOwnersParent; 2237 2238 fcData.cb = sizeof(FRAMECDATA); 2239 fcData.flCreateFlags = flCreateFlags | 0x40000000L; 2240 2241 if (flCreateFlags & FCF_SIZEBORDER) 2242 // dialog has size border: 2243 // add "clip siblings" style 2244 flStyle |= WS_CLIPSIBLINGS; 2245 2246 if (hwndOwner == HWND_DESKTOP) 2247 // there's some dumb XWorkplace code left 2248 // which uses this, and this disables the 2249 // mouse for some reason 2250 // V0.9.14 (2001-07-07) [umoeller] 2251 hwndOwner = NULLHANDLE; 2252 2253 // now, make sure the owner window is child of 2254 // HWND_DESKTOP... if it is not, we'll only disable 2255 // some dumb child window, which is not sufficient 2256 // V0.9.16 (2001-12-06) [umoeller] 2257 while ( (hwndOwner) 2258 && (hwndOwnersParent = WinQueryWindow(hwndOwner, QW_PARENT)) 2259 && (hwndOwnersParent != hwndDesktop) 2260 ) 2261 hwndOwner = hwndOwnersParent; 2262 2263 if (!(pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP, 2264 WC_FRAME, 2265 (PSZ)pcszDlgTitle, 2266 flStyle, // style; invisible for now 2267 0, 0, 0, 0, 2268 hwndOwner, 2269 HWND_TOP, 2270 0, // ID 2271 &fcData, 2272 NULL))) // presparams 2273 arc = DLGERR_CANNOT_CREATE_FRAME; 2274 else 2181 2275 { 2182 WinSubclassWindow(hwndDlg, pfnwpDialogProc); 2276 HWND hwndDlg = pDlgData->hwndDlg; 2277 HWND hwndFocusItem = NULLHANDLE; 2278 RECTL rclClient; 2183 2279 2184 2280 /* 2185 * 4) compute size of dialog client from total 2186 * size of all controls 2187 */ 2188 2189 // calculate the frame size from the client size 2190 rclClient.xLeft = 10; 2191 rclClient.yBottom = 10; 2192 rclClient.xRight = pDlgData->szlClient.cx + 2 * SPACING; 2193 rclClient.yTop = pDlgData->szlClient.cy + 2 * SPACING; 2194 WinCalcFrameRect(hwndDlg, 2195 &rclClient, 2196 FALSE); // frame from client 2197 2198 WinSetWindowPos(hwndDlg, 2199 0, 2200 10, 2201 10, 2202 rclClient.xRight, 2203 rclClient.yTop, 2204 SWP_MOVE | SWP_SIZE | SWP_NOADJUST); 2205 2206 arc = Dlg3_PositionAndCreate(pDlgData, 2207 &hwndFocusItem); 2208 2209 /* 2210 * 7) WM_INITDLG, set focus 2281 * 3) compute size of all controls 2211 2282 * 2212 2283 */ 2213 2284 2214 if (!WinSendMsg(pDlgData->hwndDlg, 2215 WM_INITDLG, 2216 (MPARAM)hwndFocusItem, 2217 (MPARAM)pCreateParams)) 2285 if (!(arc = Dlg2_CalcSizes(pDlgData))) 2218 2286 { 2219 // if WM_INITDLG returns FALSE, this means 2220 // the dlg proc has not changed the focus; 2221 // we must then set the focus here 2222 WinSetFocus(HWND_DESKTOP, hwndFocusItem); 2287 WinSubclassWindow(hwndDlg, pfnwpDialogProc); 2288 2289 /* 2290 * 4) compute size of dialog client from total 2291 * size of all controls 2292 */ 2293 2294 // calculate the frame size from the client size 2295 rclClient.xLeft = 10; 2296 rclClient.yBottom = 10; 2297 rclClient.xRight = pDlgData->szlClient.cx 2298 + 2 * (DLG_OUTER_SPACING_X * FACTOR_X); 2299 rclClient.yTop = pDlgData->szlClient.cy 2300 + 2 * (DLG_OUTER_SPACING_Y * FACTOR_Y); 2301 WinCalcFrameRect(hwndDlg, 2302 &rclClient, 2303 FALSE); // frame from client 2304 2305 WinSetWindowPos(hwndDlg, 2306 0, 2307 10, 2308 10, 2309 rclClient.xRight, 2310 rclClient.yTop, 2311 SWP_MOVE | SWP_SIZE | SWP_NOADJUST); 2312 2313 arc = Dlg3_PositionAndCreate(pDlgData, 2314 &hwndFocusItem); 2315 2316 /* 2317 * 7) WM_INITDLG, set focus 2318 * 2319 */ 2320 2321 if (!WinSendMsg(pDlgData->hwndDlg, 2322 WM_INITDLG, 2323 (MPARAM)hwndFocusItem, 2324 (MPARAM)pCreateParams)) 2325 { 2326 // if WM_INITDLG returns FALSE, this means 2327 // the dlg proc has not changed the focus; 2328 // we must then set the focus here 2329 WinSetFocus(HWND_DESKTOP, hwndFocusItem); 2330 } 2223 2331 } 2224 2332 } 2225 2333 } 2226 } 2227 2228 if (arc) 2229 { 2230 // error: clean up 2231 if (pDlgData->hwndDlg) 2334 2335 if (arc) 2232 2336 { 2233 WinDestroyWindow(pDlgData->hwndDlg); 2234 pDlgData->hwndDlg = NULLHANDLE; 2337 // error: clean up 2338 if (pDlgData->hwndDlg) 2339 { 2340 WinDestroyWindow(pDlgData->hwndDlg); 2341 pDlgData->hwndDlg = NULLHANDLE; 2342 } 2235 2343 } 2236 } 2237 else 2238 // no error: output dialog 2239 *phwndDlg = pDlgData->hwndDlg; 2240 2241 Dlg9_Cleanup(&pDlgData); 2242 } 2344 else 2345 // no error: output dialog 2346 *phwndDlg = pDlgData->hwndDlg; 2347 2348 Dlg9_Cleanup(&pDlgData); 2349 } 2350 } 2351 CATCH(excpt1) 2352 { 2353 arc = ERROR_PROTECTION_VIOLATION; 2354 } END_CATCH(); 2243 2355 2244 2356 if (arc) … … 2287 2399 *@@added V0.9.16 (2001-09-29) [umoeller] 2288 2400 *@@changed V0.9.18 (2002-03-03) [umoeller]: added pszlClient, fixed output 2401 *@@changed V0.9.19 (2002-04-24) [umoeller]: added excpt handling 2289 2402 */ 2290 2403 … … 2299 2412 APIRET arc = NO_ERROR; 2300 2413 2301 ULONG ul; 2302 2303 PDLGPRIVATE pDlgData = NULL; 2304 PLINKLIST pllControls = NULL; 2305 2306 /* 2307 * 1) parse the table and create structures from it 2308 * 2309 */ 2310 2311 if (ppllControls) 2312 pllControls = *(PLINKLIST*)ppllControls = lstCreate(FALSE); 2313 2314 if (!(arc = Dlg0_Init(&pDlgData, 2315 pcszControlsFont, 2316 pllControls))) 2317 { 2318 if (!(arc = Dlg1_ParseTables(pDlgData, 2319 paDlgItems, 2320 cDlgItems))) 2321 { 2322 HWND hwndFocusItem; 2323 2324 /* 2325 * 2) create empty dialog frame 2326 * 2327 */ 2328 2329 pDlgData->hwndDlg = hwndDlg; 2330 2331 /* 2332 * 3) compute size of all controls 2333 * 2334 */ 2335 2336 Dlg2_CalcSizes(pDlgData); 2337 2338 if (pszlClient) 2414 TRY_LOUD(excpt1) 2415 { 2416 ULONG ul; 2417 2418 PDLGPRIVATE pDlgData = NULL; 2419 PLINKLIST pllControls = NULL; 2420 2421 /* 2422 * 1) parse the table and create structures from it 2423 * 2424 */ 2425 2426 if (ppllControls) 2427 pllControls = *(PLINKLIST*)ppllControls = lstCreate(FALSE); 2428 2429 if (!(arc = Dlg0_Init(&pDlgData, 2430 pcszControlsFont, 2431 pllControls))) 2432 { 2433 if (!(arc = Dlg1_ParseTables(pDlgData, 2434 paDlgItems, 2435 cDlgItems))) 2339 2436 { 2340 pszlClient->cx = pDlgData->szlClient.cx + 2 * SPACING; 2341 pszlClient->cy = pDlgData->szlClient.cy + 2 * SPACING; 2437 HWND hwndFocusItem; 2438 2439 /* 2440 * 2) create empty dialog frame 2441 * 2442 */ 2443 2444 pDlgData->hwndDlg = hwndDlg; 2445 2446 /* 2447 * 3) compute size of all controls 2448 * 2449 */ 2450 2451 Dlg2_CalcSizes(pDlgData); 2452 2453 if (pszlClient) 2454 { 2455 pszlClient->cx = pDlgData->szlClient.cx 2456 + 2 * (DLG_OUTER_SPACING_X * FACTOR_X); 2457 pszlClient->cy = pDlgData->szlClient.cy 2458 + 2 * (DLG_OUTER_SPACING_Y * FACTOR_Y); 2459 } 2460 2461 if (flFlags & DFFL_CREATECONTROLS) 2462 { 2463 if (!(arc = Dlg3_PositionAndCreate(pDlgData, 2464 &hwndFocusItem))) 2465 WinSetFocus(HWND_DESKTOP, hwndFocusItem); 2466 } 2342 2467 } 2343 2468 2344 if (flFlags & DFFL_CREATECONTROLS) 2345 { 2346 if (!(arc = Dlg3_PositionAndCreate(pDlgData, 2347 &hwndFocusItem))) 2348 WinSetFocus(HWND_DESKTOP, hwndFocusItem); 2349 } 2350 } 2351 2352 Dlg9_Cleanup(&pDlgData); 2353 } 2469 Dlg9_Cleanup(&pDlgData); 2470 } 2471 } 2472 CATCH(excpt1) 2473 { 2474 arc = ERROR_PROTECTION_VIOLATION; 2475 } END_CATCH(); 2354 2476 2355 2477 if (arc) … … 2470 2592 + fnwpMyDialogProc, 2471 2593 + "Title", 2472 + pArray->paD ialogItems,// dialog array!2594 + pArray->paDlgItems, // dialog array! 2473 2595 + pArray->cDlgItemsNow, // real count of items! 2474 2596 + NULL, … … 2588 2710 2589 2711 /* 2712 *@@ fnwpMessageBox: 2713 * 2714 *@@added V0.9.19 (2002-04-24) [umoeller] 2715 */ 2716 2717 MRESULT EXPENTRY fnwpMessageBox(HWND hwndBox, ULONG msg, MPARAM mp1, MPARAM mp2) 2718 { 2719 switch (msg) 2720 { 2721 case WM_HELP: 2722 { 2723 PFNHELP pfnHelp; 2724 if (pfnHelp = (PFNHELP)WinQueryWindowPtr(hwndBox, QWL_USER)) 2725 pfnHelp(hwndBox); 2726 2727 return 0; 2728 } 2729 } 2730 2731 return WinDefDlgProc(hwndBox, msg, mp1, mp2); 2732 } 2733 2734 /* 2590 2735 *@@ dlghCreateMessageBox: 2591 2736 * 2592 2737 *@@added V0.9.13 (2001-06-21) [umoeller] 2593 2738 *@@changed V0.9.14 (2001-07-26) [umoeller]: fixed missing focus on buttons 2739 *@@changed V0.9.19 (2002-04-24) [umoeller]: added pfnHelp 2594 2740 */ 2595 2741 … … 2599 2745 PCSZ pcszTitle, 2600 2746 PCSZ pcszMessage, 2747 PFNHELP pfnHelp, // in: help callback or NULL 2601 2748 ULONG flFlags, 2602 2749 PCSZ pcszFont, … … 2604 2751 PULONG pulAlarmFlag) // out: alarm sound to be played 2605 2752 { 2753 APIRET arc; 2754 2606 2755 CONTROLDEF 2607 Icon = { 2608 WC_STATIC, 2609 NULL, // text, set below 2610 WS_VISIBLE | SS_ICON, 2611 0, // ID 2612 NULL, // no font 2613 0, 2614 { SZL_AUTOSIZE, SZL_AUTOSIZE }, 2615 5 2616 }, 2617 InfoText = 2618 { 2619 WC_STATIC, 2620 NULL, // text, set below 2621 WS_VISIBLE | SS_TEXT | DT_WORDBREAK | DT_LEFT | DT_TOP, 2622 10, // ID 2623 CTL_COMMON_FONT, 2624 0, 2625 { 400, SZL_AUTOSIZE }, 2626 5 2627 }, 2628 Buttons[] = { 2629 { 2630 WC_BUTTON, 2631 NULL, // text, set below 2632 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 2633 1, // ID 2634 CTL_COMMON_FONT, // no font 2635 0, 2636 { 100, 30 }, 2637 5 2638 }, 2639 { 2640 WC_BUTTON, 2641 NULL, // text, set below 2642 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 2643 2, // ID 2644 CTL_COMMON_FONT, // no font 2645 0, 2646 { 100, 30 }, 2647 5 2648 }, 2649 { 2650 WC_BUTTON, 2651 NULL, // text, set below 2652 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 2653 3, // ID 2654 CTL_COMMON_FONT, // no font 2655 0, 2656 { 100, 30 }, 2657 5 2658 } 2659 }; 2660 2661 DLGHITEM MessageBox[] = 2662 { 2756 Icon = CONTROLDEF_ICON(NULLHANDLE, 0), 2757 Spacing = CONTROLDEF_TEXT(NULL, 0, 1, 1), 2758 InfoText = CONTROLDEF_TEXT_WORDBREAK(NULL, 10, 200), 2759 Buttons[] = 2760 { 2761 CONTROLDEF_PUSHBUTTON(NULL, 1, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT), 2762 CONTROLDEF_PUSHBUTTON(NULL, 2, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT), 2763 CONTROLDEF_PUSHBUTTON(NULL, 3, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT), 2764 CONTROLDEF_HELPPUSHBUTTON(NULL, 4, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT) 2765 }; 2766 2767 DLGHITEM MessageBoxFront[] = 2768 { 2663 2769 START_TABLE, 2664 2770 START_ROW(ROW_VALIGN_CENTER), … … 2666 2772 START_TABLE, 2667 2773 START_ROW(ROW_VALIGN_CENTER), 2774 CONTROL_DEF(&Spacing), 2775 START_ROW(ROW_VALIGN_CENTER), 2668 2776 CONTROL_DEF(&InfoText), 2777 START_ROW(ROW_VALIGN_CENTER), 2778 CONTROL_DEF(&Spacing), 2669 2779 START_ROW(ROW_VALIGN_CENTER), 2670 2780 CONTROL_DEF(&Buttons[0]), 2671 2781 CONTROL_DEF(&Buttons[1]), 2672 2782 CONTROL_DEF(&Buttons[2]), 2783 }, 2784 MessageBoxHelp[] = 2785 { 2786 CONTROL_DEF(&Buttons[3]), 2787 }, 2788 MessageBoxTail[] = 2789 { 2673 2790 END_TABLE, 2674 2791 END_TABLE 2675 2792 }; 2676 2793 2677 2794 ULONG flButtons = flFlags & 0xF; // low nibble contains MB_YESNO etc. 2795 PDLGARRAY pArrayBox; 2678 2796 2679 2797 PCSZ p0 = "Error", … … 2764 2882 *pulAlarmFlag = WA_WARNING; 2765 2883 2766 return (dlghCreateDlg(phwndDlg, 2767 hwndOwner, 2768 FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER | FCF_NOBYTEALIGN, 2769 WinDefDlgProc, 2770 pcszTitle, 2771 MessageBox, 2772 ARRAYITEMCOUNT(MessageBox), 2773 NULL, 2774 pcszFont)); 2884 if (pfnHelp) 2885 Buttons[3].pcszText = pStrings->pcszHelp; 2886 2887 if (!(arc = dlghCreateArray( ARRAYITEMCOUNT(MessageBoxFront) 2888 + ARRAYITEMCOUNT(MessageBoxHelp) 2889 + ARRAYITEMCOUNT(MessageBoxTail), 2890 &pArrayBox))) 2891 { 2892 if ( (!(arc = dlghAppendToArray(pArrayBox, 2893 MessageBoxFront, 2894 ARRAYITEMCOUNT(MessageBoxFront)))) 2895 && ( (!pfnHelp) 2896 || (!(arc = dlghAppendToArray(pArrayBox, 2897 MessageBoxHelp, 2898 ARRAYITEMCOUNT(MessageBoxHelp)))) 2899 ) 2900 && (!(arc = dlghAppendToArray(pArrayBox, 2901 MessageBoxTail, 2902 ARRAYITEMCOUNT(MessageBoxTail)))) 2903 ) 2904 { 2905 if (!(arc = dlghCreateDlg(phwndDlg, 2906 hwndOwner, 2907 FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER | FCF_NOBYTEALIGN, 2908 fnwpMessageBox, 2909 pcszTitle, 2910 pArrayBox->paDlgItems, 2911 pArrayBox->cDlgItemsNow, 2912 NULL, 2913 pcszFont))) 2914 // added help callback V0.9.19 (2002-04-24) [umoeller] 2915 WinSetWindowPtr(*phwndDlg, QWL_USER, (PVOID)pfnHelp); 2916 } 2917 2918 dlghFreeArray(&pArrayBox); 2919 } 2920 2921 return arc; 2775 2922 } 2776 2923 … … 2885 3032 * -- MB_ICONEXCLAMATION 2886 3033 * 3034 * If (pfnHelp != NULL), a "Help" button is also added and 3035 * pfnHelp gets called when the user presses it or the F1 3036 * key. 3037 * 2887 3038 * Returns MBID_* codes like WinMessageBox. 2888 3039 * 2889 3040 *@@added V0.9.13 (2001-06-21) [umoeller] 3041 *@@changed V0.9.19 (2002-04-24) [umoeller]: added pfnHelp 2890 3042 */ 2891 3043 2892 3044 ULONG dlghMessageBox(HWND hwndOwner, // in: owner for msg box 2893 3045 HPOINTER hptrIcon, // in: icon to display 2894 PCSZ pcszTitle, // in: title 2895 PCSZ pcszMessage, // in: message 3046 PCSZ pcszTitle, // in: title 3047 PCSZ pcszMessage, // in: message 3048 PFNHELP pfnHelp, // in: help callback or NULL 2896 3049 ULONG flFlags, // in: standard message box flags 2897 PCSZ pcszFont, // in: font (e.g. "9.WarpSans")3050 PCSZ pcszFont, // in: font (e.g. "9.WarpSans") 2898 3051 const MSGBOXSTRINGS *pStrings) // in: strings array 2899 3052 { … … 2905 3058 pcszTitle, 2906 3059 pcszMessage, 3060 pfnHelp, 2907 3061 flFlags, 2908 3062 pcszFont, … … 2980 3134 CTL_COMMON_FONT, 2981 3135 0, 2982 { 300, SZL_AUTOSIZE }, // size3136 { 150, SZL_AUTOSIZE }, // size 2983 3137 5 // spacing 2984 3138 }, … … 2990 3144 CTL_COMMON_FONT, 2991 3145 0, 2992 { 300, SZL_AUTOSIZE }, // size3146 { 150, SZL_AUTOSIZE }, // size 2993 3147 5 // spacing 2994 3148 }, … … 3000 3154 CTL_COMMON_FONT, 3001 3155 0, 3002 { 100, 30}, // size3156 { STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT }, // size 3003 3157 5 // spacing 3004 3158 }, … … 3010 3164 CTL_COMMON_FONT, 3011 3165 0, 3012 { 100, 30}, // size3166 { STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT }, // size 3013 3167 5 // spacing 3014 3168 };
Note:
See TracChangeset
for help on using the changeset viewer.