实例介绍
【实例简介】
【实例截图】
【核心代码】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 | Chapter 1 Introduction 1-1 What’s in this manual? . . . . . . . . . . . . . . 1-1 Manual conventions . . . . . . . . . . . . . . . . 1-2 Developer support services . . . . . . . . . . . . 1-3 Part I Programming with Delphi Chapter 2 Developing applications with Delphi 2-1 Integrated development environment . . . . . . 2-1 Designing applications . . . . . . . . . . . . . . 2-2 Creating projects . . . . . . . . . . . . . . . . . . 2-3 Editing code . . . . . . . . . . . . . . . . . . . . 2-4 Compiling applications . . . . . . . . . . . . . . 2-4 Debugging applications . . . . . . . . . . . . . . 2-5 Deploying applications . . . . . . . . . . . . . . 2-5 Chapter 3 Using the component library 3-1 Understanding the component library . . . . . 3-1 Properties, methods, and events . . . . . . . 3-3 Properties . . . . . . . . . . . . . . . . . . 3-3 Methods . . . . . . . . . . . . . . . . . . 3-4 Events . . . . . . . . . . . . . . . . . . . . 3-4 User events . . . . . . . . . . . . . . . . . 3-4 System events . . . . . . . . . . . . . . . 3-4 Internal events . . . . . . . . . . . . . . . 3-4 Objects, components, and controls. . . . . . . . 3-5 TObject branch . . . . . . . . . . . . . . . . . 3-6 TPersistent branch . . . . . . . . . . . . . . . 3-7 TComponent branch . . . . . . . . . . . . . . 3-7 TControl branch . . . . . . . . . . . . . . . . 3-9 TWinControl/TWidgetControl branch . . .3-10 Chapter 4 Using the object model 4-1 What is an object? . . . . . . . . . . . . . . . . . 4-1 Examining a Delphi object . . . . . . . . . . 4-2 Changing the name of a component . . . . . 4-4 Inheriting data and code from an object. . . . . 4-5 Scope and qualifiers . . . . . . . . . . . . . . . . 4-5 Private, protected, public, and published declarations . . . . . . . . . . . . . . . . . . 4-6 Using object variables . . . . . . . . . . . . . . 4-7 Creating, instantiating, and destroying objects . . . . . . . . . . . . . . . . . . . . . . 4-8 Components and ownership . . . . . . . . . 4-9 Defining new classes . . . . . . . . . . . . . . . 4-9 Using interfaces . . . . . . . . . . . . . . . . . . 4-12 Using interfaces across the hierarchy . . . . 4-13 Using interfaces with procedures . . . . . . 4-14 Implementing IInterface . . . . . . . . . . . 4-14 TInterfacedObject . . . . . . . . . . . . . . . 4-15 Using the as operator with interfaces . . . . 4-16 Reusing code and delegation. . . . . . . . . 4-16 Using implements for delegation . . . . 4-17 Aggregation . . . . . . . . . . . . . . . . 4-18 Memory management of interface objects. . . . . . . . . . . . . . . . . . . . . 4-18 Using reference counting . . . . . . . . 4-19 Not using reference counting . . . . . . 4-20 Using interfaces in distributed applications . . . . . . . . . . . . . . . . . 4-21 Chapter 5 Using BaseCLX 5-1 Using streams . . . . . . . . . . . . . . . . . . . 5-2 Using streams to read or write data . . . . . 5-2 Stream methods for reading and writing . . . . . . . . . . . . . . . 5-2 Reading and writing components . . . 5-3 Reading and writing strings . . . . . . . 5-3 Copying data from one stream to another. . . . . . . . . . . . . . . . . . . 5-4 Specifying the stream position and size. . . 5-4 Seeking to a specific position . . . . . . 5-4 Using Position and Size properties . . . 5-5 Working with files . . . . . . . . . . . . . . . . 5-5 Approaches to file I/O . . . . . . . . . . . . 5-6 Using file streams . . . . . . . . . . . . . . . 5-6 Creating and opening files using file streams . . . . . . . . . . . . . . . 5-7 Using the file handle . . . . . . . . . . . 5-8 Manipulating files . . . . . . . . . . . . . . . 5-8 Deleting a file . . . . . . . . . . . . . . . 5-8 Finding a file . . . . . . . . . . . . . . . 5-8 Renaming a file . . . . . . . . . . . . . . 5-10 File date-time routines . . . . . . . . . . 5-10 Copying a file . . . . . . . . . . . . . . . 5-11 Contents iv Working with ini files and the system Registry . . . . . . . . . . . . . . . . . . . . . 5-11 Using TIniFile and TMemIniFile . . . . 5-12 Using TRegistryIniFile . . . . . . . . . 5-13 Using TRegistry . . . . . . . . . . . . . 5-13 Working with lists . . . . . . . . . . . . . . . . 5-14 Common list operations . . . . . . . . . . . 5-15 Adding list items . . . . . . . . . . . . 5-15 Deleting list items . . . . . . . . . . . . 5-15 Accessing list items . . . . . . . . . . . 5-16 Rearranging list items . . . . . . . . . . 5-16 Persistent lists. . . . . . . . . . . . . . . . . 5-16 Working with string lists . . . . . . . . . . . . 5-17 Loading and saving string lists . . . . . . . 5-17 Creating a new string list . . . . . . . . . . 5-18 Short-term string lists . . . . . . . . . . 5-18 Long-term string lists . . . . . . . . . . 5-18 Manipulating strings in a list . . . . . . . . 5-20 Counting the strings in a list . . . . . . 5-20 Accessing a particular string . . . . . . 5-20 Locating items in a string list . . . . . . 5-20 Iterating through strings in a list . . . . 5-20 Adding a string to a list . . . . . . . . . 5-21 Moving a string within a list . . . . . . 5-21 Deleting a string from a list . . . . . . . 5-21 Associating objects with a string list . . . . . . . . . . . . . . . . 5-22 Working with strings . . . . . . . . . . . . . . 5-22 Wide character routines . . . . . . . . . . . 5-22 Commonly used long string routines . . . 5-23 Commonly used routines for null-terminated strings. . . . . . . . . . . 5-26 Declaring and initializing strings. . . . . . 5-27 Mixing and converting string types . . . . 5-28 String to PChar conversions. . . . . . . . . 5-28 String dependencies . . . . . . . . . . . 5-29 Returning a PChar local variable . . . 5-29 Passing a local variable as a PChar . . . . . . . . . . . . . . . . . 5-29 Compiler directives for strings . . . . . . . 5-30 Creating drawing spaces . . . . . . . . . . . . 5-31 Printing . . . . . . . . . . . . . . . . . . . . . . 5-32 Converting measurements . . . . . . . . . . . 5-33 Performing conversions . . . . . . . . . . . 5-33 Performing simple conversions . . . . 5-33 Performing complex conversions . . . 5-33 Adding new measurement types . . . . . . 5-34 Creating a simple conversion family and adding units. . . . . . . . . . . . . . . 5-34 Declare variables . . . . . . . . . . . . . 5-35 Register the conversion family . . . . . 5-35 Register measurement units . . . . . . . 5-35 Use the new units . . . . . . . . . . . . . 5-35 Using a conversion function . . . . . . . . . 5-36 Declare variables . . . . . . . . . . . . . 5-36 Register the conversion family . . . . . 5-36 Register the base unit . . . . . . . . . . 5-36 Write methods to convert to and from the base unit . . . . . . . . . . . . 5-36 Register the other units . . . . . . . . . 5-37 Use the new units . . . . . . . . . . . . . 5-37 Using a class to manage conversions . . . . 5-37 Creating the conversion class . . . . . . 5-38 Declare variables . . . . . . . . . . . . . 5-39 Register the conversion family and the other units . . . . . . . . . . . . . . 5-39 Use the new units . . . . . . . . . . . . . 5-40 Defining custom variants . . . . . . . . . . . . 5-40 Storing a custom variant type’s data . . . . 5-41 Creating a class to enable the custom variant type . . . . . . . . . . . . . 5-42 Enabling casting . . . . . . . . . . . . . 5-42 Implementing binary operations . . . . 5-44 Implementing comparison operations . . . . . . . . . . . . . . . . 5-46 Implementing unary operations . . . . 5-47 Copying and clearing custom variants . . . 5-48 Loading and saving custom variant values . . . . . . . . . . . . . . 5-49 Using the TCustomVariantType descendant . . . . . . . . . . . . . . . . 5-50 Writing utilities to work with a custom variant type . . . . . . . . . . . . . 5-50 Supporting properties and methods in custom variants . . . . . . . . . . . . . . 5-51 Using TInvokeableVariantType . . . . . 5-51 Using TPublishableVariantType . . . . 5-53 Chapter 6 Working with components 6-1 Setting component properties . . . . . . . . . . 6-2 Setting properties at design time . . . . . . 6-2 Using property editors . . . . . . . . . . 6-3 Setting properties at runtime. . . . . . . . . 6-3 Calling methods. . . . . . . . . . . . . . . . . . 6-3 v Working with events and event handlers . . . . 6-3 Generating a new event handler . . . . . . . 6-4 Generating a handler for a component’s default event . . . . . . . . . 6-4 Locating event handlers . . . . . . . . . . . . 6-4 Associating an event with an existing event handler . . . . . . . . . . . . . . . . . 6-5 Using the Sender parameter . . . . . . . 6-5 Displaying and coding shared events . . . . . . . . . . . . . . . . . . . 6-5 Associating menu events with event handlers . . . . . . . . . . . . . . . . 6-6 Deleting event handlers . . . . . . . . . . . . 6-6 Cross-platform and non-cross-platform components . . . . . . . . . . . . . . . . . . . . 6-7 Adding custom components to the Component palette . . . . . . . . . . . . . . 6-9 Chapter 7 Working with controls 7-1 Implementing drag and drop in controls . . . . 7-1 Starting a drag operation . . . . . . . . . . . 7-1 Accepting dragged items . . . . . . . . . . . 7-2 Dropping items . . . . . . . . . . . . . . . . . 7-3 Ending a drag operation. . . . . . . . . . . . 7-3 Customizing drag and drop with a drag object. . . . . . . . . . . . . . . . . . 7-3 Changing the drag mouse pointer . . . . . . 7-4 Implementing drag and dock in controls . . . . 7-4 Making a windowed control a docking site . . . . . . . . . . . . . . . . . . 7-4 Making a control a dockable child . . . . . . 7-5 Controlling how child controls are docked . . . . . . . . . . . . . . . . . . . 7-5 Controlling how child controls are undocked . . . . . . . . . . . . . . . . . 7-6 Controlling how child controls respond to drag-and-dock operations . . . . . . . . 7-6 Working with text in controls. . . . . . . . . . . 7-6 Setting text alignment . . . . . . . . . . . . . 7-7 Adding scroll bars at runtime. . . . . . . . . 7-7 Adding the clipboard object. . . . . . . . . . 7-8 Selecting text . . . . . . . . . . . . . . . . . . 7-9 Selecting all text . . . . . . . . . . . . . . . . 7-9 Cutting, copying, and pasting text . . . . . 7-10 Deleting selected text . . . . . . . . . . . . 7-10 Disabling menu items . . . . . . . . . . . . 7-11 Providing a pop-up menu . . . . . . . . . . 7-11 Handling the OnPopup event. . . . . . . . 7-12 Adding graphics to controls . . . . . . . . . . . 7-13 Indicating that a control is owner-drawn. . . . . . . . . . . . . . . . . 7-13 Adding graphical objects to a string list . . . . . . . . . . . . . . . . . . 7-14 Adding images to an application . . . . 7-14 Adding images to a string list . . . . . . 7-14 Drawing owner-drawn items . . . . . . 7-15 Sizing owner-draw items . . . . . . . . . . . 7-16 Drawing owner-draw items . . . . . . . . . 7-17 Chapter 8 Building applications, components, and libraries 8-1 Creating applications . . . . . . . . . . . . . . . 8-1 GUI applications. . . . . . . . . . . . . . . . 8-2 User interface models . . . . . . . . . . 8-2 SDI applications . . . . . . . . . . . . . 8-2 MDI applications . . . . . . . . . . . . . 8-2 Setting IDE, project, and compiler options . . . . . . . . . . . . . . . . . . 8-3 Programming templates . . . . . . . . . . . 8-3 Console applications . . . . . . . . . . . . . 8-4 Service applications . . . . . . . . . . . . . . 8-5 Service threads . . . . . . . . . . . . . . 8-8 Service name properties . . . . . . . . . 8-9 Debugging service applications . . . . . 8-10 Creating packages and DLLs . . . . . . . . . . 8-11 When to use packages and DLLs . . . . . . 8-11 Writing database applications . . . . . . . . . . 8-12 Distributing database applications . . . . . 8-13 Creating Web server applications . . . . . . . . 8-13 Creating Web Broker applications . . . . . . 8-14 Creating WebSnap applications . . . . . . . 8-15 Creating Web Services applications . . . . . 8-15 Writing applications using COM . . . . . . . . 8-16 Using COM and DCOM . . . . . . . . . . . 8-16 Using MTS and COM . . . . . . . . . . . . 8-16 Using data modules . . . . . . . . . . . . . . . 8-17 Creating and editing standard data modules. . . . . . . . . . . . . . . . . . . . 8-17 Naming a data module and its unit file . . . . . . . . . . . . . . . . 8-18 Placing and naming components . . . . 8-19 Using component properties and events in a data module . . . . . . . . 8-19 Creating business rules in a data module . . . . . . . . . . . . . . . 8-20 vi Accessing a data module from a form . . . 8-20 Adding a remote data module to an application server project . . . . . . . . . 8-21 Using the Object Repository . . . . . . . . . . 8-21 Sharing items within a project . . . . . . . 8-21 Adding items to the Object Repository . . . . . . . . . . . . . . . . . . 8-22 Sharing objects in a team environment. . . . . . . . . . . . . . . . . 8-22 Using an Object Repository item in a project . . . . . . . . . . . . . . . . . . . 8-22 Copying an item . . . . . . . . . . . . . 8-22 Inheriting an item . . . . . . . . . . . . 8-23 Using an item . . . . . . . . . . . . . . 8-23 Using project templates . . . . . . . . . . . 8-23 Modifying shared items . . . . . . . . . . . 8-23 Specifying a default project, new form, and main form . . . . . . . . . . . . . . . 8-24 Enabling Help in applications . . . . . . . . . 8-24 Help system interfaces. . . . . . . . . . . . 8-25 Implementing ICustomHelpViewer . . . . 8-25 Communicating with the Help Manager . . . . . . . . . . . . . . . . . . . 8-26 Asking the Help Manager for information . . . . . . . . . . . . . . . . . 8-26 Displaying keyword-based Help . . . . . . 8-27 Displaying tables of contents . . . . . . . . 8-28 Implementing IExtendedHelpViewer . . . 8-28 Implementing IHelpSelector . . . . . . . . 8-29 Registering Help system objects . . . . . . 8-30 Registering Help viewers . . . . . . . . 8-30 Registering Help selectors . . . . . . . 8-30 Using Help in a VCL application. . . . . . . . 8-31 How TApplication processes VCL Help . . . . . . . . . . . . . . . . . . 8-31 How VCL controls process Help . . . . . . 8-31 Using Help in a CLX application. . . . . . . . 8-32 How TApplication processes CLX Help . . . . . . . . . . . . . . . . . . 8-32 How CLX controls process Help . . . . . . 8-32 Calling a Help system directly . . . . . . . . . 8-33 Using IHelpSystem . . . . . . . . . . . . . . . 8-33 Customizing the IDE Help system . . . . . . . 8-34 Chapter 9 Developing the application user interface 9-1 Controlling application behavior . . . . . . . . 9-1 Working at the application level . . . . . . . 9-2 Handling the screen. . . . . . . . . . . . . . 9-2 Setting up forms. . . . . . . . . . . . . . . . . . 9-3 Using the main form . . . . . . . . . . . . . 9-3 Hiding the main form. . . . . . . . . . . . . 9-3 Adding forms . . . . . . . . . . . . . . . . . 9-4 Linking forms . . . . . . . . . . . . . . . 9-4 Avoiding circular unit references . . . . 9-4 Managing layout . . . . . . . . . . . . . . . 9-5 Using forms . . . . . . . . . . . . . . . . . . . . 9-6 Controlling when forms reside in memory . . . . . . . . . . . . . . . . . . 9-6 Displaying an auto-created form . . . . 9-6 Creating forms dynamically . . . . . . . 9-7 Creating modeless forms such as windows . . . . . . . . . . . . . . . 9-8 Creating a form instance using a local variable . . . . . . . . . . . . . 9-8 Passing additional arguments to forms . . . 9-8 Retrieving data from forms. . . . . . . . . . 9-9 Retrieving data from modeless forms . . . . . . . . . . . . . . . . . . . 9-9 Retrieving data from modal forms . . . 9-11 Reusing components and groups of components . . . . . . . . . . . . . . . . . . . 9-13 Creating and using component templates . . . . . . . . . . . . . . . . . . . . . 9-13 Working with frames . . . . . . . . . . . . . . . 9-14 Creating frames . . . . . . . . . . . . . . . . 9-14 Adding frames to the Component palette. . . . . . . . . . . . . . . . . . . . . 9-15 Using and modifying frames. . . . . . . . . 9-15 Sharing frames. . . . . . . . . . . . . . . . . 9-16 Developing dialog boxes . . . . . . . . . . . . . 9-17 Using open dialog boxes . . . . . . . . . . . 9-17 Organizing actions for toolbars and menus . . . . . . . . . . . . . . . . . . . . 9-18 What is an action? . . . . . . . . . . . . . . . 9-19 Setting up action bands . . . . . . . . . . . . 9-20 vii Creating toolbars and menus . . . . . . . . 9-20 Adding color, patterns, or pictures to menus, buttons, and toolbars . . . 9-22 Adding icons to menus and toolbars . . . . . . . . . . . . . . . . . 9-22 Selecting menu and toolbar styles . . . 9-23 Creating dynamic menus . . . . . . . . 9-24 Creating toolbars and menus that users can customize . . . . . . . . . . 9-24 Hiding unused items and categories in action bands . . . . . . . . . . . . . 9-24 Creating most recently used (MRU) lists . . . . . . . . . . . . . . . 9-25 Using action lists . . . . . . . . . . . . . . . . . 9-26 Setting up action lists . . . . . . . . . . . . 9-26 What happens when an action fires . . . . 9-27 Responding with events . . . . . . . . 9-27 How actions find their targets . . . . . 9-29 Updating actions . . . . . . . . . . . . . . . 9-29 Predefined action classes . . . . . . . . . . 9-30 Writing action components . . . . . . . . . 9-31 Registering actions . . . . . . . . . . . . . . 9-31 Creating and managing menus. . . . . . . . . 9-32 Opening the Menu Designer . . . . . . . . 9-33 Building menus. . . . . . . . . . . . . . . . 9-34 Naming menus . . . . . . . . . . . . . 9-34 Naming the menu items . . . . . . . . 9-34 Adding, inserting, and deleting menu items . . . . . . . . . . . . . . . 9-35 Adding separator bars . . . . . . . . . 9-36 Specifying accelerator keys and keyboard shortcuts . . . . . . . . . . 9-36 Creating submenus. . . . . . . . . . . . . . 9-37 Creating submenus by demoting existing menus . . . . . . . . . . . . . 9-37 Moving menu items . . . . . . . . . . . 9-38 Adding images to menu items . . . . . 9-38 Viewing the menu . . . . . . . . . . . . 9-39 Editing menu items in the Object Inspector. . . . . . . . . . . . . . . . . . . 9-39 Using the Menu Designer context menu . . . . . . . . . . . . . . . . . . . . . 9-40 Commands on the context menu . . . 9-40 Switching between menus at design time . . . . . . . . . . . . . . . 9-41 Using menu templates . . . . . . . . . . . . 9-41 Saving a menu as a template . . . . . . . . 9-43 Naming conventions for template menu items and event handlers . . . 9-44 Manipulating menu items at runtime . . . . 9-44 Merging menus . . . . . . . . . . . . . . . . 9-44 Specifying the active menu: Menu property . . . . . . . . . . . . . . . . . 9-45 Determining the order of merged menu items: GroupIndex property . . . . . . 9-45 Importing resource files . . . . . . . . . . . 9-45 Designing toolbars and cool bars . . . . . . . . 9-46 Adding a toolbar using a panel component . . . . . . . . . . . . . . . . . . 9-47 Adding a speed button to a panel . . . 9-47 Assigning a speed button’s glyph . . . 9-48 Setting the initial condition of a speed button . . . . . . . . . . . . . . . 9-48 Creating a group of speed buttons . . . 9-48 Allowing toggle buttons . . . . . . . . . 9-49 Adding a toolbar using the toolbar component . . . . . . . . . . . . . . . . . . 9-49 Adding a tool button . . . . . . . . . . . 9-49 Assigning images to tool buttons . . . . 9-50 Setting tool button appearance and initial conditions . . . . . . . . . . . . 9-50 Creating groups of tool buttons . . . . . 9-51 Allowing toggled tool buttons . . . . . 9-51 Adding a cool bar component . . . . . . . . 9-51 Setting the appearance of the cool bar . . . . . . . . . . . . . . . . . . 9-52 Responding to clicks . . . . . . . . . . . . . 9-52 Assigning a menu to a tool button . . . 9-52 Adding hidden toolbars . . . . . . . . . . . 9-53 Hiding and showing toolbars . . . . . . . . 9-53 Demo programs . . . . . . . . . . . . . . . . 9-53 Common controls and XP themes. . . . . . . . 9-54 Chapter 10 Types of controls 10-1 Text controls . . . . . . . . . . . . . . . . . . . . 10-1 Edit controls . . . . . . . . . . . . . . . . . . 10-1 Memo and rich edit controls . . . . . . 10-2 Text viewing controls . . . . . . . . . . . . . 10-3 Labels . . . . . . . . . . . . . . . . . . . . . . 10-3 Specialized input controls . . . . . . . . . . . . 10-4 Scroll bars . . . . . . . . . . . . . . . . . . . 10-4 Track bars. . . . . . . . . . . . . . . . . . . . 10-5 Up-down controls . . . . . . . . . . . . . . . 10-5 Spin edit controls (CLX only) . . . . . . . . 10-5 Hot key controls (VCL only) . . . . . . . . . 10-6 Splitter controls . . . . . . . . . . . . . . . . 10-6 viii Buttons and similar controls . . . . . . . . . . 10-6 Button controls . . . . . . . . . . . . . . . . 10-7 Bitmap buttons . . . . . . . . . . . . . . . . 10-7 Speed buttons. . . . . . . . . . . . . . . . . 10-8 Check boxes. . . . . . . . . . . . . . . . . . 10-8 Radio buttons . . . . . . . . . . . . . . . . . 10-8 Toolbars . . . . . . . . . . . . . . . . . . . . 10-9 Cool bars (VCL only). . . . . . . . . . . . . 10-9 List controls. . . . . . . . . . . . . . . . . . . . 10-9 List boxes and check-list boxes . . . . . . . 10-10 Combo boxes . . . . . . . . . . . . . . . . . 10-11 Tree views . . . . . . . . . . . . . . . . . . . 10-11 List views . . . . . . . . . . . . . . . . . . . 10-12 Icon views (CLX only) . . . . . . . . . . . . 10-12 Date-time pickers and month calendars. . . . . . . . . . . . . . . . . . . 10-12 Grouping controls . . . . . . . . . . . . . . . . 10-12 Group boxes and radio groups . . . . . . . 10-13 Panels . . . . . . . . . . . . . . . . . . . . . 10-13 Scroll boxes . . . . . . . . . . . . . . . . . . 10-13 Tab controls . . . . . . . . . . . . . . . . . . 10-14 Page controls . . . . . . . . . . . . . . . . . 10-14 Header controls. . . . . . . . . . . . . . . . 10-14 Display controls . . . . . . . . . . . . . . . . . 10-15 Status bars. . . . . . . . . . . . . . . . . . . 10-15 Progress bars . . . . . . . . . . . . . . . . . 10-15 Help and hint properties . . . . . . . . . . 10-16 Grids. . . . . . . . . . . . . . . . . . . . . . . . 10-16 Draw grids . . . . . . . . . . . . . . . . . . 10-16 String grids . . . . . . . . . . . . . . . . . . 10-16 Value list editors (VCL only) . . . . . . . . . . 10-17 Graphic controls . . . . . . . . . . . . . . . . . 10-18 Images . . . . . . . . . . . . . . . . . . . . . 10-18 Shapes . . . . . . . . . . . . . . . . . . . . . 10-18 Bevels . . . . . . . . . . . . . . . . . . . . . 10-18 Paint boxes . . . . . . . . . . . . . . . . . . 10-19 Animation control . . . . . . . . . . . . . . 10-19 Chapter 11 Designing classes and components with ModelMaker 11-1 ModelMaker fundamentals. . . . . . . . . . . 11-2 ModelMaker models . . . . . . . . . . . . . 11-2 Using ModelMaker with the IDE . . . . . . 11-2 Creating models . . . . . . . . . . . . . . . 11-3 Using ModelMaker views . . . . . . . . . . . . 11-4 Collections pane . . . . . . . . . . . . . . . . 11-5 Classes view . . . . . . . . . . . . . . . . 11-5 Units view . . . . . . . . . . . . . . . . . 11-5 Diagrams view . . . . . . . . . . . . . . 11-6 Members pane . . . . . . . . . . . . . . . . . 11-7 Editors pane . . . . . . . . . . . . . . . . . . 11-7 Implementation Editor . . . . . . . . . . 11-7 Unit Code Editor . . . . . . . . . . . . . 11-8 Diagram Editor . . . . . . . . . . . . . . 11-9 Other Editors . . . . . . . . . . . . . . . 11-9 For more information. . . . . . . . . . . . . . 11-10 Chapter 12 Working with graphics and multimedia 12-1 Overview of graphics programming . . . . . . 12-1 Refreshing the screen . . . . . . . . . . . . . 12-2 Types of graphic objects . . . . . . . . . . . 12-3 Common properties and methods of Canvas . . . . . . . . . . . . . . . . . . . 12-4 Using the properties of the Canvas object . . . . . . . . . . . . . . . . . . . . . 12-5 Using pens . . . . . . . . . . . . . . . . 12-5 Using brushes . . . . . . . . . . . . . . . 12-8 Reading and setting pixels . . . . . . . 12-9 Using Canvas methods to draw graphic objects . . . . . . . . . . . . . . . 12-10 Drawing lines and polylines . . . . . 12-10 Drawing shapes . . . . . . . . . . . . . 12-11 Handling multiple drawing objects in your application . . . . . . . . . . . . 12-12 Keeping track of which drawing tool to use . . . . . . . . . . . . . . . 12-12 Changing the tool with speed buttons . . . . . . . . . . . . . . . . . 12-13 Using drawing tools . . . . . . . . . . 12-14 Drawing on a graphic. . . . . . . . . . . . 12-16 Making scrollable graphics . . . . . . 12-17 Adding an image control . . . . . . . 12-17 Loading and saving graphics files. . . . . 12-19 Loading a picture from a file . . . . . 12-19 Saving a picture to a file . . . . . . . . 12-20 Replacing the picture . . . . . . . . . . 12-20 ix Using the clipboard with graphics . . . . . 12-21 Copying graphics to the clipboard . . . . . . . . . . . . . . . . 12-22 Cutting graphics to the clipboard . . . 12-22 Pasting graphics from the clipboard . . . . . . . . . . . . . . . . 12-23 Rubber banding example . . . . . . . . . . 12-24 Responding to the mouse . . . . . . . . 12-24 Responding to a mouse-down action . . . . . . . . . . . . . . . . . . 12-25 Adding a field to a form object to track mouse actions . . . . . . . . . . 12-27 Refining line drawing . . . . . . . . . . 12-28 Working with multimedia . . . . . . . . . . . 12-30 Adding silent video clips to an application. . . . . . . . . . . . . . . . . . 12-30 Example of adding silent video clips . . . . . . . . . . . . . . . 12-31 Adding audio and/or video clips to an application . . . . . . . . . . . . . . . . 12-32 Example of adding audio and/or video clips (VCL only) . . . . . . . . 12-33 Chapter 13 Writing multi-threaded applications 13-1 Defining thread objects . . . . . . . . . . . . . 13-2 Initializing the thread . . . . . . . . . . . . 13-3 Assigning a default priority . . . . . . 13-3 Indicating when threads are freed . . . 13-4 Writing the thread function . . . . . . . . . 13-4 Using the main VCL/CLX thread . . . 13-4 Using thread-local variables . . . . . . 13-6 Checking for termination by other threads . . . . . . . . . . . . . . . . . 13-6 Handling exceptions in the thread function . . . . . . . . . . . . . . . . . 13-6 Writing clean-up code . . . . . . . . . . . . 13-7 Coordinating threads . . . . . . . . . . . . . . 13-7 Avoiding simultaneous access . . . . . . . 13-7 Locking objects . . . . . . . . . . . . . 13-8 Using critical sections . . . . . . . . . . 13-8 Using the multi-read exclusive-write synchronizer . . . . . . . . . . . . . . 13-8 Other techniques for sharing memory . . . . . . . . . . . . . . . . . 13-9 Waiting for other threads . . . . . . . . . . 13-9 Waiting for a thread to finish executing . . . . . . . . . . . . . . . . 13-10 Waiting for a task to be completed . . . . . . . . . . . . . . . 13-10 Executing thread objects . . . . . . . . . . . . 13-12 Overriding the default priority . . . . . . 13-12 Starting and stopping threads . . . . . . . 13-12 Debugging multi-threaded applications . . . 13-13 Naming a thread. . . . . . . . . . . . . . . 13-13 Converting an unnamed thread to a named thread . . . . . . . . . . 13-13 Assigning separate names to similar threads . . . . . . . . . . . . 13-15 Chapter 14 Exception handling 14-1 Defining protected blocks . . . . . . . . . . . . 14-2 Writing the try block . . . . . . . . . . . . . 14-2 Raising an exception . . . . . . . . . . . 14-3 Writing exception handlers. . . . . . . . . . 14-4 Exception-handling statements . . . . . 14-4 Handling classes of exceptions . . . . . 14-6 Scope of exception handlers . . . . . . . 14-6 Reraising exceptions . . . . . . . . . . . 14-7 Writing finally blocks . . . . . . . . . . . . . 14-8 Writing a finally block . . . . . . . . . . 14-9 Handling exceptions in VCL applications . . . . . . . . . . . . . . . . . . . 14-9 VCL exception classes . . . . . . . . . . . 14-10 Default exception handling in VCL . . . . 14-11 Silent exceptions. . . . . . . . . . . . . . . 14-12 Defining your own VCL exceptions. . . . 14-13 Chapter 15 Developing cross-platform applications 15-1 Creating CLX applications . . . . . . . . . . . . 15-2 Porting VCL applications . . . . . . . . . . . . 15-2 Porting techniques . . . . . . . . . . . . . . 15-2 Platform-specific ports . . . . . . . . . . 15-3 Cross-platform ports . . . . . . . . . . . 15-3 Windows emulation ports . . . . . . . . 15-3 Modifying VCL applications . . . . . . . . . 15-4 WinCLX versus VisualCLX. . . . . . . . . . 15-5 What VisualCLX does differently . . . . 15-6 Features that do not port directly or are missing . . . . . . . . . . . . . . . . 15-7 Comparing WinCLX and VisualCLX units . . . . . . . . . . . . . . . 15-8 Differences in CLX object constructors . . 15-11 Handling system and widget events . . . 15-12 x Writing portable code . . . . . . . . . . . . 15-12 Using conditional directives . . . . . . 15-13 Terminating conditional directives . . . . . . . . . . . . . . . . 15-14 Including inline assembler code . . . . 15-15 Programming differences on Linux . . . . 15-16 Transferring applications between Windows and Linux . . . . . . . . . . . . . . 15-17 Sharing source files between Windows and Linux . . . . . . . . . . . . 15-17 Environmental differences between Windows and Linux . . . . . . . . . . . . 15-18 Registry . . . . . . . . . . . . . . . . . . 15-20 Look and feel . . . . . . . . . . . . . . . 15-20 Directory structure on Linux . . . . . . . . 15-20 Cross-platform database applications . . . . . 15-21 dbExpress differences . . . . . . . . . . . . 15-22 Component-level differences . . . . . . . . 15-22 User interface-level differences . . . . . . . 15-23 Porting database applications to Linux . . . . . . . . . . . . . . . . . . . 15-24 Updating data in dbExpress applications . . . . . . . . . . . . . . . . . 15-26 Cross-platform Internet applications . . . . . 15-28 Porting Internet applications to Linux . . . . . . . . . . . . . . . . . . . 15-28 Chapter 16 Working with packages and components 16-1 Why use packages? . . . . . . . . . . . . . . . 16-2 Packages and standard DLLs . . . . . . . . 16-2 Runtime packages . . . . . . . . . . . . . . . . 16-3 Loading packages in an application . . . . 16-3 Loading packages with the LoadPackage function . . . . . . . . . . 16-4 Deciding which runtime packages to use. . . . . . . . . . . . . . . . . . . . . 16-4 Custom packages. . . . . . . . . . . . . . . 16-5 Design-time packages . . . . . . . . . . . . . . 16-5 Installing component packages . . . . . . . 16-6 Creating and editing packages . . . . . . . . . 16-7 Creating a package . . . . . . . . . . . . . . 16-7 Editing an existing package . . . . . . . . . 16-8 Understanding the structure of a package . . . . . . . . . . . . . . . . . . 16-8 Naming packages . . . . . . . . . . . . 16-8 Requires clause . . . . . . . . . . . . . 16-9 Contains clause . . . . . . . . . . . . . 16-9 Editing package source files manually . . . . . . . . . . . . . . . . . . 16-10 Compiling packages . . . . . . . . . . . . 16-10 Package-specific compiler directives . . . . . . . . . . . . . . . . 16-11 Compiling and linking from the command line . . . . . . . . . . . . . 16-13 Package files created when compiling . . . . . . . . . . . . . . . 16-13 Deploying packages . . . . . . . . . . . . . . 16-14 Deploying applications that use packages . . . . . . . . . . . . . . . . . . 16-14 Distributing packages to other developers . . . . . . . . . . . . . . . . . 16-14 Package collection files . . . . . . . . . . . 16-14 Chapter 17 Creating international applications 17-1 Internationalization and localization . . . . . . 17-1 Internationalization . . . . . . . . . . . . . . 17-1 Localization . . . . . . . . . . . . . . . . . . 17-2 Internationalizing applications . . . . . . . . . 17-2 Enabling application code . . . . . . . . . . 17-2 ~Character sets . . . . . . . . . . . . . . 17-2 OEM and ANSI character sets . . . . . 17-3 Multibyte character sets . . . . . . . . . 17-3 Wide characters . . . . . . . . . . . . . . 17-4 Including bi-directional functionality in applications . . . . . . . . . . . . . . 17-4 BiDiMode property . . . . . . . . . . . . 17-4 Locale-specific features . . . . . . . . . 17-7 Designing the user interface . . . . . . . . . 17-7 Text . . . . . . . . . . . . . . . . . . . . . 17-7 Graphic images . . . . . . . . . . . . . . 17-8 Formats and sort order . . . . . . . . . . 17-8 Keyboard mappings . . . . . . . . . . . 17-8 Isolating resources. . . . . . . . . . . . . . . 17-8 Creating resource DLLs. . . . . . . . . . . . 17-9 Using resource DLLs . . . . . . . . . . . . 17-10 Dynamic switching of resource DLLs . . . 17-11 Localizing applications. . . . . . . . . . . . . 17-12 Localizing resources. . . . . . . . . . . . . 17-12 xi Chapter 18 Deploying applications 18-1 Deploying general applications . . . . . . . . 18-1 Using installation programs. . . . . . . . . 18-2 Identifying application files . . . . . . 18-2 Application files . . . . . . . . . . . . . 18-3 Package files . . . . . . . . . . . . . . . 18-3 Merge modules . . . . . . . . . . . . . 18-3 ActiveX controls . . . . . . . . . . . . . 18-5 Helper applications . . . . . . . . . . . 18-5 DLL locations . . . . . . . . . . . . . . 18-6 Deploying CLX applications . . . . . . . . . . 18-6 Deploying database applications. . . . . . . . 18-6 Deploying dbExpress database applications . . . . . . . . . . . . . . . . . 18-7 Deploying BDE applications . . . . . . . . 18-8 Borland Database Engine . . . . . . . . 18-8 Deploying multi-tiered database applications (DataSnap) . . . . . . . . . . 18-9 Deploying Web applications . . . . . . . . . . 18-9 Deploying on Apache servers . . . . . . . 18-10 Enabling modules . . . . . . . . . . . . 18-10 CGI applications . . . . . . . . . . . . . 18-11 Programming for varying host environments . . . . . . . . . . . . . . . . . . 18-12 Screen resolutions and color depths . . . . 18-12 Considerations when not dynamically resizing . . . . . . . . . 18-12 Considerations when dynamically resizing forms and controls . . . . . . 18-13 Accommodating varying color depths . . . . . . . . . . . . . . 18-14 Fonts . . . . . . . . . . . . . . . . . . . . . . 18-14 Operating systems versions . . . . . . . . . 18-15 Software license requirements . . . . . . . . . 18-15 DEPLOY. . . . . . . . . . . . . . . . . . . . 18-15 README . . . . . . . . . . . . . . . . . . . 18-16 No-nonsense license agreement . . . . . . 18-16 Third-party product documentation . . . . 18-16 Part II Developing database applications Chapter 19 Designing database applications 19-1 Using databases . . . . . . . . . . . . . . . . . 19-1 Types of databases . . . . . . . . . . . . . . 19-2 Database security. . . . . . . . . . . . . . . 19-4 Transactions . . . . . . . . . . . . . . . . . . 19-4 Referential integrity, stored procedures, and triggers. . . . . . . . . . . . . . . . . . 19-5 Database architecture. . . . . . . . . . . . . . . 19-6 General structure . . . . . . . . . . . . . . . 19-6 The user interface form . . . . . . . . . 19-6 The data module . . . . . . . . . . . . . 19-6 Connecting directly to a database server . . . . . . . . . . . . . . . . . . . . . 19-8 Using a dedicated file on disk . . . . . . . . 19-9 Connecting to another dataset . . . . . . . 19-10 Connecting a client dataset to another dataset in the same application . . . 19-12 Using a multi-tiered architecture . . . 19-13 Combining approaches . . . . . . . . . . . 19-14 Designing the user interface . . . . . . . . . . 19-15 Analyzing data . . . . . . . . . . . . . . . 19-15 Writing reports. . . . . . . . . . . . . . . . 19-16 Chapter 20 Using data controls 20-1 Using common data control features . . . . . . 20-2 Associating a data control with a dataset . . . . . . . . . . . . . . . . . . . 20-3 Changing the associated dataset at runtime . . . . . . . . . . . . . . . . 20-4 Enabling and disabling the data source . . . . . . . . . . . . . . . . . . 20-4 Responding to changes mediated by the data source . . . . . . . . . . . 20-4 Editing and updating data . . . . . . . . . . 20-5 Enabling editing in controls on user entry . . . . . . . . . . . . . . . . 20-5 Editing data in a control . . . . . . . . . 20-5 Disabling and enabling data display . . . . 20-6 Refreshing data display. . . . . . . . . . . . 20-7 Enabling mouse, keyboard, and timer events . . . . . . . . . . . . . . . . . 20-7 Choosing how to organize the data . . . . . . . 20-7 Displaying a single record . . . . . . . . . . 20-7 Displaying data as labels . . . . . . . . 20-8 Displaying and editing fields in an edit box . . . . . . . . . . . . . . . . 20-8 Displaying and editing text in a memo control . . . . . . . . . . . . . . 20-9 Displaying and editing text in a rich edit memo control . . . . . . . . . . . 20-9 Displaying and editing graphics fields in an image control . . . . . . 20-10 xii Displaying and editing data in list and combo boxes . . . . . . . . . . . 20-10 Handling Boolean field values with check boxes . . . . . . . . . . . . 20-13 Restricting field values with radio controls . . . . . . . . . . . . . . 20-14 Displaying multiple records. . . . . . . . . 20-14 Viewing and editing data with TDBGrid . . . 20-15 Using a grid control in its default state . . . . . . . . . . . . . . . . . . . . . 20-16 Creating a customized grid . . . . . . . . . 20-17 Understanding persistent columns . . . . . . . . . . . . . . . . . 20-17 Creating persistent columns . . . . . . 20-18 Deleting persistent columns . . . . . . 20-19 Arranging the order of persistent columns . . . . . . . . . . . . . . . . . 20-19 Setting column properties at design time . . . . . . . . . . . . . . . 20-20 Defining a lookup list column . . . . . 20-21 Putting a button in a column . . . . . . 20-22 Restoring default values to a column . . . . . . . . . . . . . . . . 20-22 Displaying ADT and array fields . . . . . . 20-22 Setting grid options . . . . . . . . . . . . . 20-24 Editing in the grid . . . . . . . . . . . . . . 20-26 Controlling grid drawing . . . . . . . . . . 20-26 Responding to user actions at runtime . . . . . . . . . . . . . . . . . . 20-27 Creating a grid that contains other data-aware controls . . . . . . . . . . . . . . 20-28 Navigating and manipulating records. . . . . 20-29 Choosing navigator buttons to display . . . . . . . . . . . . . . . . . . . . 20-30 Hiding and showing navigator buttons at design time . . . . . . . . . 20-30 Hiding and showing navigator buttons at runtime . . . . . . . . . . . 20-31 Displaying fly-over help. . . . . . . . . . . 20-31 Using a single navigator for multiple datasets . . . . . . . . . . . . . . . . . . . 20-32 Chapter 21 Creating reports with Rave Reports 21-1 Overview . . . . . . . . . . . . . . . . . . . . . 21-1 Getting started . . . . . . . . . . . . . . . . . . 21-2 The Rave Visual Designer. . . . . . . . . . . . 21-3 Component overview . . . . . . . . . . . . . . 21-4 VCL/CLX components . . . . . . . . . . . . 21-4 Engine components . . . . . . . . . . . 21-4 Render components . . . . . . . . . . . 21-4 Data connection components . . . . . . 21-4 Rave project component . . . . . . . . . 21-5 Reporting components . . . . . . . . . . . . 21-5 Project components . . . . . . . . . . . . 21-5 Data objects . . . . . . . . . . . . . . . . 21-5 Standard components . . . . . . . . . . 21-5 Drawing components . . . . . . . . . . 21-5 Report components . . . . . . . . . . . . 21-6 Bar code components . . . . . . . . . . 21-6 Getting more information . . . . . . . . . . . . 21-6 Chapter 22 Using decision support components 22-1 Overview . . . . . . . . . . . . . . . . . . . . . 22-1 About crosstabs . . . . . . . . . . . . . . . . . . 22-2 One-dimensional crosstabs. . . . . . . . . . 22-3 Multidimensional crosstabs . . . . . . . . . 22-3 Guidelines for using decision support components . . . . . . . . . . . . . . . . . . . 22-4 Using datasets with decision support components . . . . . . . . . . . . . . . . . . . 22-5 Creating decision datasets with TQuery or TTable . . . . . . . . . . . . . . 22-6 Creating decision datasets with the Decision Query editor. . . . . . . . . . . . 22-6 Using decision cubes . . . . . . . . . . . . . . . 22-7 Decision cube properties and events . . . . 22-7 Using the Decision Cube editor . . . . . . . 22-8 Viewing and changing dimension settings . . . . . . . . . . . . . . . . . . 22-8 Setting the maximum available dimensions and summaries . . . . . . 22-9 Viewing and changing design options . . . . . . . . . . . . . . . . . . 22-9 Using decision sources . . . . . . . . . . . . . . 22-9 Properties and events . . . . . . . . . . . . . 22-9 Using decision pivots. . . . . . . . . . . . . . 22-10 Decision pivot properties. . . . . . . . . . 22-10 Creating and using decision grids . . . . . . 22-11 Creating decision grids . . . . . . . . . . . 22-11 Using decision grids . . . . . . . . . . . . 22-11 Opening and closing decision grid fields . . . . . . . . . . . . . . . 22-11 xiii Reorganizing rows and columns in decision grids . . . . . . . . . . . . . 22-12 Drilling down for detail in decision grids . . . . . . . . . . . . . 22-12 Limiting dimension selection in decision grids . . . . . . . . . . . . . 22-12 Decision grid properties . . . . . . . . . . . 22-12 Creating and using decision graphs . . . . . . 22-13 Creating decision graphs . . . . . . . . . . 22-13 Using decision graphs . . . . . . . . . . . . 22-14 The decision graph display . . . . . . . . . 22-15 Customizing decision graphs . . . . . . . . 22-16 Setting decision graph template defaults . . . . . . . . . . . . . . . . . 22-17 Customizing decision graph series . . . . . . . . . . . . . . . . . . 22-18 Decision support components at runtime . . . . . . . . . . . . . . . . . . . . . 22-19 Decision pivots at runtime . . . . . . . . . 22-19 Decision grids at runtime . . . . . . . . . . 22-19 Decision graphs at runtime . . . . . . . . . 22-20 Decision support components and memory control . . . . . . . . . . . . . . . . 22-20 Setting maximum dimensions, summaries, and cells . . . . . . . . . . . . 22-20 Setting dimension state . . . . . . . . . . . 22-21 Using paged dimensions . . . . . . . . . . 22-21 Chapter 23 Connecting to databases 23-1 Using implicit connections . . . . . . . . . . . 23-2 Controlling connections . . . . . . . . . . . . . 23-3 Connecting to a database server . . . . . . 23-3 Disconnecting from a database server . . . 23-4 Controlling server login . . . . . . . . . . . . . 23-4 Managing transactions . . . . . . . . . . . . . 23-6 Starting a transaction . . . . . . . . . . . . 23-7 Ending a transaction . . . . . . . . . . . . . 23-8 Ending a successful transaction . . . . 23-8 Ending an unsuccessful transaction . . . . . . . . . . . . . . . 23-9 Specifying the transaction isolation level . . . . . . . . . . . . . . . . 23-9 Sending commands to the server . . . . . . . 23-10 Working with associated datasets . . . . . . . 23-12 Closing all datasets without disconnecting from the server. . . . . . . 23-12 Iterating through the associated datasets . . . . . . . . . . . . . . . . . . . 23-13 Obtaining metadata. . . . . . . . . . . . . . . 23-13 Listing available tables . . . . . . . . . . . 23-14 Listing the fields in a table . . . . . . . . . 23-14 Listing available stored procedures . . . . 23-14 Listing available indexes . . . . . . . . . . 23-14 Listing stored procedure parameters . . . 23-15 Chapter 24 Understanding datasets 24-1 Using TDataSet descendants . . . . . . . . . . 24-2 Determining dataset states. . . . . . . . . . . . 24-3 Opening and closing datasets . . . . . . . . . . 24-4 Navigating datasets. . . . . . . . . . . . . . . . 24-5 Using the First and Last methods . . . . . . 24-6 Using the Next and Prior methods . . . . . 24-7 Using the MoveBy method. . . . . . . . . . 24-7 Using the Eof and Bof properties . . . . . . 24-8 Eof . . . . . . . . . . . . . . . . . . . . . 24-8 Bof . . . . . . . . . . . . . . . . . . . . . 24-9 Marking and returning to records . . . . . . 24-9 The Bookmark property . . . . . . . . . 24-9 The GetBookmark method . . . . . . 24-10 The GotoBookmark and BookmarkValid methods . . . . . . . 24-10 The CompareBookmarks method . . 24-10 The FreeBookmark method . . . . . . 24-10 A bookmarking example . . . . . . . 24-10 Searching datasets . . . . . . . . . . . . . . . 24-11 Using Locate . . . . . . . . . . . . . . . . . 24-11 Using Lookup . . . . . . . . . . . . . . . . 24-12 Displaying and editing a subset of data using filters . . . . . . . . . . . . . . . . . . 24-13 Enabling and disabling filtering . . . . . . 24-13 Creating filters . . . . . . . . . . . . . . . . 24-13 Setting the Filter property . . . . . . . 24-14 Writing an OnFilterRecord event handler . . . . . . . . . . . . . 24-15 Switching filter event handlers at runtime . . . . . . . . . . . . . . . 24-16 Setting filter options. . . . . . . . . . . . . 24-16 Navigating records in a filtered dataset . . . . . . . . . . . . . . . . . . . 24-16 Modifying data . . . . . . . . . . . . . . . . . 24-17 Editing records. . . . . . . . . . . . . . . . 24-18 Adding new records . . . . . . . . . . . . 24-19 Inserting records . . . . . . . . . . . . 24-19 Appending records . . . . . . . . . . . 24-20 Deleting records . . . . . . . . . . . . . . . 24-20 Posting data . . . . . . . . . . . . . . . . . 24-21 xiv Canceling changes . . . . . . . . . . . . . . 24-21 Modifying entire records . . . . . . . . . . 24-22 Calculating fields . . . . . . . . . . . . . . . . 24-23 Types of datasets . . . . . . . . . . . . . . . . . 24-24 Using table type datasets . . . . . . . . . . . . 24-25 Advantages of using table type datasets . . . . . . . . . . . . . . . . . . . 24-26 Sorting records with indexes . . . . . . . . 24-26 Obtaining information about indexes . . . . . . . . . . . . . . . . . 24-27 Specifying an index with IndexName . . . . . . . . . . . . . . . 24-27 Creating an index with IndexFieldNames . . . . . . . . . . . 24-28 Using Indexes to search for records . . . . 24-28 Executing a search with Goto methods . . . . . . . . . . . . . . . . . 24-29 Executing a search with Find methods . . . . . . . . . . . . . . . . . 24-30 Specifying the current record after a successful search . . . . . . . . . . . 24-30 Searching on partial keys . . . . . . . . 24-30 Repeating or extending a search . . . . 24-30 Limiting records with ranges . . . . . . . . 24-31 Understanding the differences between ranges and filters . . . . . . 24-31 Specifying ranges . . . . . . . . . . . . 24-31 Modifying a range . . . . . . . . . . . . 24-34 Applying or canceling a range . . . . . 24-34 Creating master/detail relationships. . . . 24-35 Making the table a detail of another dataset . . . . . . . . . . . . . 24-35 Using nested detail tables . . . . . . . 24-37 Controlling Read/write access to tables . . . . . . . . . . . . . . . . . . . 24-38 Creating and deleting tables . . . . . . . . 24-38 Creating tables . . . . . . . . . . . . . . 24-38 Deleting tables . . . . . . . . . . . . . . 24-41 Emptying tables . . . . . . . . . . . . . . . 24-41 Synchronizing tables . . . . . . . . . . . . . 24-42 Using query-type datasets . . . . . . . . . . . 24-42 Specifying the query . . . . . . . . . . . . . 24-43 Specifying a query using the SQL property . . . . . . . . . . . . . . 24-44 Specifying a query using the CommandText property . . . . . . . 24-44 Using parameters in queries . . . . . . . . 24-45 Supplying parameters at design time . . . . . . . . . . . . . . . . . . . 24-45 Supplying parameters at runtime . . 24-47 Establishing master/detail relationships using parameters . . . . . . . . . . . . . 24-47 Preparing queries . . . . . . . . . . . . . . 24-48 Executing queries that don’t return a result set . . . . . . . . . . . . . . . . . 24-49 Using unidirectional result sets . . . . . . 24-49 Using stored procedure-type datasets . . . . 24-50 Working with stored procedure parameters . . . . . . . . . . . . . . . . . 24-51 Setting up parameters at design time . . . . . . . . . . . . . . 24-52 Using parameters at runtime . . . . . 24-54 Preparing stored procedures . . . . . . . . 24-55 Executing stored procedures that don’t return a result set . . . . . . . . . . . . . 24-55 Fetching multiple result sets . . . . . . . . 24-56 Chapter 25 Working with field components 25-1 Dynamic field components . . . . . . . . . . . 25-2 Persistent field components . . . . . . . . . . . 25-3 Creating persistent fields . . . . . . . . . . . 25-4 Arranging persistent fields . . . . . . . . . . 25-5 Defining new persistent fields . . . . . . . . 25-5 Defining a data field . . . . . . . . . . . 25-6 Defining a calculated field . . . . . . . . 25-7 Programming a calculated field . . . . . 25-8 Defining a lookup field . . . . . . . . . 25-9 Defining an aggregate field . . . . . . 25-10 Deleting persistent field components . . . 25-11 Setting persistent field properties and events . . . . . . . . . . . . . . . . . 25-11 Setting display and edit properties at design time . . . . . . . . . . . . . 25-11 Setting field component properties at runtime . . . . . . . . . . . . . . . 25-13 Creating attribute sets for field components . . . . . . . . . . . . . . 25-13 Associating attribute sets with field components . . . . . . . . . . . . . . 25-14 Removing attribute associations . . . 25-14 Controlling and masking user input . . . . . . . . . . . . . . . 25-15 xv Using default formatting for numeric, date, and time fields . . . . . . . . . . 25-15 Handling events . . . . . . . . . . . . . 25-16 Working with field component methods at runtime . . . . . . . . . . . . . . . . . . . . 25-17 Displaying, converting, and accessing field values . . . . . . . . . . . . . . . . . . . 25-18 Displaying field component values in standard controls . . . . . . . . . . . . . . 25-18 Converting field values . . . . . . . . . . . 25-19 Accessing field values with the default dataset property . . . . . . . . . . . . . . 25-20 Accessing field values with a dataset’s Fields property . . . . . . . . . . . . . . . 25-21 Accessing field values with a dataset’s FieldByName method . . . . . . . . . . . 25-21 Setting a default value for a field. . . . . . . . 25-22 Working with constraints . . . . . . . . . . . . 25-22 Creating a custom constraint . . . . . . . . 25-22 Using server constraints . . . . . . . . . . . 25-23 Using object fields . . . . . . . . . . . . . . . . 25-23 Displaying ADT and array fields . . . . . . 25-24 Working with ADT fields . . . . . . . . . . 25-25 Using persistent field components . . . . . . . . . . . . . . 25-25 Using the dataset’s FieldByName method . . . . . . . . . . . . . . . . . 25-25 Using the dateset’s FieldValues property . . . . . . . . . . . . . . . . . 25-25 Using the ADT field’s FieldValues property . . . . . . . . . . . . . . . . . 25-26 Using the ADT field’s Fields property . . . . . . . . . . . . . . . . . 25-26 Working with array fields . . . . . . . . . . 25-26 Using persistent fields . . . . . . . . . 25-26 Using the array field’s FieldValues property . . . . . . . . . . . . . . . . . 25-27 Using the array field’s Fields property . . . . . . . . . . . . . . . . . 25-27 Working with dataset fields . . . . . . . . . 25-27 Displaying dataset fields . . . . . . . . 25-27 Accessing data in a nested dataset . . . 25-28 Working with reference fields. . . . . . . . 25-28 Displaying reference fields . . . . . . . 25-28 Accessing data in a reference field . . . 25-29 Chapter 26 Using the Borland Database Engine 26-1 BDE-based architecture. . . . . . . . . . . . . . 26-1 Using BDE-enabled datasets . . . . . . . . . 26-2 Associating a dataset with database and session connections . . . . . . . . 26-3 Caching BLOBs . . . . . . . . . . . . . . 26-4 Obtaining a BDE handle . . . . . . . . . 26-4 Using TTable . . . . . . . . . . . . . . . . . . 26-5 Specifying the table type for local tables . . . . . . . . . . . . . . . . . . . 26-5 Controlling read/write access to local tables . . . . . . . . . . . . . . . . 26-6 Specifying a dBASE index file . . . . . . 26-6 Renaming local tables . . . . . . . . . . 26-8 Importing data from another table . . . 26-8 Using TQuery . . . . . . . . . . . . . . . . . 26-9 Creating heterogeneous queries . . . . 26-9 Obtaining an editable result set . . . . 26-10 Updating read-only result sets . . . . 26-11 Using TStoredProc . . . . . . . . . . . . . 26-11 Binding parameters . . . . . . . . . . 26-12 Working with Oracle overloaded stored procedures . . . . . . . . . . . 26-12 Connecting to databases with TDatabase . . . . . . . . . . . . . . . . . 26-12 Associating a database component with a session . . . . . . . . . . . . . 26-13 Understanding database and session component interactions . . . . . . . 26-13 Identifying the database . . . . . . . . 26-14 Opening a connection using TDatabase . . . . . . . . . . . . . . . 26-15 Using database components in data modules . . . . . . . . . . . . . . . . 26-16 Managing database sessions . . . . . . . . 26-16 Activating a session . . . . . . . . . . 26-18 Specifying default database connection behavior . . . . . . . . . 26-18 Managing database connections . . . 26-19 Working with password-protected Paradox and dBASE tables . . . . . 26-21 Specifying Paradox directory locations . . . . . . . . . . . . . . . . 26-24 Working with BDE aliases . . . . . . . 26-25 Retrieving information about a session . . . . . . . . . . . . . . . . 26-27 xvi Creating additional sessions . . . . . . 26-28 Naming a session . . . . . . . . . . . . 26-29 Managing multiple sessions . . . . . . 26-29 Using transactions with the BDE. . . . . . . . 26-31 Using passthrough SQL . . . . . . . . . . . 26-32 Using local transactions . . . . . . . . . . . 26-32 Using the BDE to cache updates . . . . . . . . 26-33 Enabling BDE-based cached updates . . . 26-34 Applying BDE-based cached updates . . . 26-35 Applying cached updates using a database . . . . . . . . . . . . . . . . 26-36 Applying cached updates with dataset component methods . . . . . . . . . . 26-36 Creating an OnUpdateRecord event handler . . . . . . . . . . . . . . 26-37 Handling cached update errors . . . . 26-38 Using update objects to update a dataset . . . . . . . . . . . . . . . . . . . 26-40 Creating SQL statements for update components . . . . . . . . . . . . . . 26-41 Using multiple update objects . . . . . 26-45 Executing the SQL statements . . . . . 26-46 Using TBatchMove. . . . . . . . . . . . . . . . 26-49 Creating a batch move component . . . . . 26-49 Specifying a batch move mode . . . . . . . 26-50 Appending records . . . . . . . . . . . 26-50 Updating records . . . . . . . . . . . . 26-50 Appending and updating records . . . . . . . . . . . . . . . . . 26-51 Copying datasets . . . . . . . . . . . . 26-51 Deleting records . . . . . . . . . . . . . 26-51 Mapping data types . . . . . . . . . . . . . 26-51 Executing a batch move . . . . . . . . . . . 26-52 Handling batch move errors . . . . . . . . 26-52 The Data Dictionary . . . . . . . . . . . . . . . 26-53 Tools for working with the BDE . . . . . . . . 26-55 Chapter 27 Working with ADO components 27-1 Overview of ADO components . . . . . . . . 27-2 Connecting to ADO data stores . . . . . . . . 27-3 Connecting to a data store using TADOConnection. . . . . . . . . . . . . . 27-3 Accessing the connection object . . . . 27-5 Fine-tuning a connection . . . . . . . . . . 27-5 Forcing asynchronous connections . . . . . . . . . . . . . . . 27-5 Controlling time-outs . . . . . . . . . . 27-6 Indicating the types of operations the connection supports . . . . . . . . 27-6 Specifying whether the connection automatically initiates transactions . . . . . . . . . . . . . . . 27-7 Accessing the connection’s commands . . . . . . . . . . . . . . . . . . 27-7 ADO connection events. . . . . . . . . . . . 27-8 Events when establishing a connection . . . . . . . . . . . . . . . . 27-8 Events when disconnecting . . . . . . . 27-8 Events when managing transactions . . . . . . . . . . . . . . . 27-9 Other events . . . . . . . . . . . . . . . . 27-9 Using ADO datasets . . . . . . . . . . . . . . . 27-9 Connecting an ADO dataset to a data store . . . . . . . . . . . . . . 27-10 Working with record sets . . . . . . . 27-11 Filtering records based on bookmarks . . . . . . . . . . . . . . . 27-11 Fetching records asynchronously . . . 27-12 Using batch updates . . . . . . . . . . 27-13 Loading data from and saving data to files . . . . . . . . . . . . . . 27-15 Using TADODataSet . . . . . . . . . . . . 27-16 Using Command objects . . . . . . . . . . . . 27-18 Specifying the command . . . . . . . . . . 27-18 Using the Execute method . . . . . . . . . 27-19 Canceling commands . . . . . . . . . . . . 27-19 Retrieving result sets with commands . . 27-20 Handling command parameters. . . . . . 27-20 Chapter 28 Using unidirectional datasets 28-1 Types of unidirectional datasets. . . . . . . . . 28-2 Connecting to the database server . . . . . . . 28-2 Setting up TSQLConnection . . . . . . . . . 28-3 Identifying the driver . . . . . . . . . . 28-3 Specifying connection parameters . . . 28-4 Naming a connection description . . . . 28-4 Using the Connection Editor . . . . . . 28-5 Specifying what data to display . . . . . . . . . 28-6 Representing the results of a query . . . . . 28-6 Representing the records in a table . . . . . 28-7 Representing a table using TSQLDataSet . . . . . . . . . . . . . . 28-7 Representing a table using TSQLTable . . . . . . . . . . . . . . . . 28-7 xvii Representing the results of a stored procedure . . . . . . . . . . . . . . 28-8 Fetching the data. . . . . . . . . . . . . . . . . 28-8 Preparing the dataset . . . . . . . . . . . . 28-9 Fetching multiple datasets . . . . . . . . . 28-9 Executing commands that do not return records. . . . . . . . . . . . . . . . . . 28-10 Specifying the command to execute . . . . 28-10 Executing the command . . . . . . . . . . . 28-11 Creating and modifying server metadata. . . . . . . . . . . . . . . . . . . 28-11 Setting up master/detail linked cursors. . . . 28-12 Accessing schema information . . . . . . . . . 28-13 Fetching metadata into a unidirectional dataset . . . . . . . . . . . . . . . . . . . . 28-13 Fetching data after using the dataset for metadata . . . . . . . . . . . . . . 28-14 The structure of metadata datasets . . . . . . . . . . . . . . . . . 28-14 Debugging dbExpress applications . . . . . . 28-19 Using TSQLMonitor to monitor SQL commands . . . . . . . . . . . . . . . 28-19 Using a callback to monitor SQL commands . . . . . . . . . . . . . . . 28-20 Chapter 29 Using client datasets 29-1 Working with data using a client dataset . . . 29-2 Navigating data in client datasets . . . . . 29-2 Limiting what records appear. . . . . . . . 29-2 Editing data . . . . . . . . . . . . . . . . . . 29-5 Undoing changes . . . . . . . . . . . . 29-5 Saving changes . . . . . . . . . . . . . 29-6 Constraining data values . . . . . . . . . . 29-7 Specifying custom constraints . . . . . 29-7 Sorting and indexing. . . . . . . . . . . . . 29-8 Adding a new index . . . . . . . . . . . 29-8 Deleting and switching indexes . . . . 29-9 Using indexes to group data . . . . . . 29-9 Representing calculated values . . . . . . . 29-10 Using internally calculated fields in client datasets . . . . . . . . . . . . 29-11 Using maintained aggregates . . . . . . . . 29-11 Specifying aggregates . . . . . . . . . 29-12 Aggregating over groups of records . . . . . . . . . . . . . . . . . 29-13 Obtaining aggregate values . . . . . . 29-14 Copying data from another dataset . . . . 29-14 Assigning data directly . . . . . . . . 29-14 Cloning a client dataset cursor . . . . 29-15 Adding application-specific information to the data . . . . . . . . . . . . . . . . . 29-15 Using a client dataset to cache updates. . . . 29-16 Overview of using cached updates . . . . 29-17 Choosing the type of dataset for caching updates . . . . . . . . . . . . . . . . . . . 29-18 Indicating what records are modified. . . 29-19 Updating records . . . . . . . . . . . . . . 29-20 Applying updates . . . . . . . . . . . 29-20 Intervening as updates are applied . . . . . . . . . . . . . . . . . 29-21 Reconciling update errors . . . . . . . 29-23 Using a client dataset with a provider . . . . 29-24 Specifying a provider . . . . . . . . . . . . 29-25 Requesting data from the source dataset or document . . . . . . . . . . . . . . . . 29-26 Incremental fetching . . . . . . . . . . 29-26 Fetch-on-demand . . . . . . . . . . . . 29-27 Getting parameters from the source dataset . . . . . . . . . . . . . . . . . . . 29-27 Passing parameters to the source dataset . . . . . . . . . . . . . . . . . . . 29-28 Sending query or stored procedure parameters . . . . . . . . . . . . . . . 29-29 Limiting records with parameters . . 29-29 Handling constraints from the server . . . 29-30 Refreshing records. . . . . . . . . . . . . . 29-31 Communicating with providers using custom events . . . . . . . . . . . . . . . 29-31 Overriding the source dataset . . . . . . . 29-32 Using a client dataset with file-based data . . . . . . . . . . . . . . . . . . . . . . . 29-33 Creating a new dataset . . . . . . . . . . . 29-33 Loading data from a file or stream . . . . 29-34 Merging changes into data . . . . . . . . . 29-34 Saving data to a file or stream . . . . . . . 29-35 Using a simple dataset . . . . . . . . . . . . . 29-35 When to use TSimpleDataSet . . . . . . . 29-36 Setting up a simple dataset. . . . . . . . . 29-36 xviii Chapter 30 Using provider components 30-1 Determining the source of data. . . . . . . . . 30-2 Using a dataset as the source of the data . . . . . . . . . . . . . . . . . . 30-2 Using an XML document as the source of the data . . . . . . . . . . . . . . . . . . 30-2 Communicating with the client dataset . . . . 30-3 Choosing how to apply updates using a dataset provider . . . . . . . . . . . . . . . 30-4 Controlling what information is included in data packets . . . . . . . . . . . . . . . . . 30-4 Specifying what fields appear in data packets . . . . . . . . . . . . . . . . . 30-4 Setting options that influence the data packets . . . . . . . . . . . . . . . . . 30-5 Adding custom information to data packets . . . . . . . . . . . . . . . . . 30-6 Responding to client data requests. . . . . . . 30-7 Responding to client update requests . . . . . 30-8 Editing delta packets before updating the database . . . . . . . . . . . . . . . . . 30-9 Influencing how updates are applied . . . 30-10 Screening individual updates . . . . . . . . 30-11 Resolving update errors on the provider . . . . . . . . . . . . . . . . . 30-11 Applying updates to datasets that do not represent a single table . . . . . . . . 30-12 Responding to client-generated events . . . . 30-12 Handling server constraints . . . . . . . . . . 30-13 Chapter 31 Creating multi-tiered applications 31-1 Advantages of the multi-tiered database model. . . . . . . . . . . . . . . . . 31-2 Understanding multi-tiered database applications . . . . . . . . . . . . . . . . . . . 31-2 Overview of a three-tiered application. . . 31-3 The structure of the client application . . . 31-4 The structure of the application server. . . 31-5 The contents of the remote data module . . . . . . . . . . . . . . 31-6 Using transactional data modules . . . 31-7 Pooling remote data modules . . . . . 31-8 Choosing a connection protocol . . . . . . 31-9 Using DCOM connections . . . . . . . 31-9 Using Socket connections . . . . . . . . 31-9 Using Web connections . . . . . . . . . 31-10 Using SOAP connections . . . . . . . . 31-11 Building a multi-tiered application . . . . . . 31-11 Creating the application server . . . . . . . . 31-12 Setting up the remote data module . . . . 31-13 Configuring TRemoteDataModule . . . . . . . . 31-13 Configuring TMTSDataModule . . . 31-15 Configuring TSoapDataModule . . . 31-16 Extending the application server’s interface. . . . . . . . . . . . . . . . . . . 31-16 Adding callbacks to the application server’s interface . . . . . . . . . . . 31-17 Extending a transactional application server’s interface . . . . . . . . . . . 31-17 Managing transactions in multi-tiered applications . . . . . . . . . . . . . . . . 31-17 Supporting master/detail relationships . . . . . . . . . . . . . . . . 31-18 Supporting state information in remote data modules. . . . . . . . . . . . . . . . 31-19 Using multiple remote data modules . . . 31-21 Registering the application server . . . . . . 31-22 Creating the client application. . . . . . . . . 31-22 Connecting to the application server . . . 31-23 Specifying a connection using DCOM . . . . . . . . . . . . . 31-24 Specifying a connection using sockets . . . . . . . . . . . . . 31-24 Specifying a connection using HTTP . . . . . . . . . . . . . . 31-25 Specifying a connection using SOAP . . . . . . . . . . . . . . 31-26 Brokering connections . . . . . . . . . 31-27 Managing server connections . . . . . . . 31-27 Connecting to the server . . . . . . . . 31-27 Dropping or changing a server connection . . . . . . . . . . . . . . . 31-28 Calling server interfaces . . . . . . . . . . 31-28 Using early binding with DCOM . . . 31-29 Using dispatch interfaces with TCP/IP or HTTP . . . . . . . . . . . 31-29 Calling the interface of a SOAP-based server . . . . . . . . . . . . . . . . . . 31-30 Connecting to an application server that uses multiple data modules . . . . . . . 31-30 Writing Web-based client applications . . . . 31-31 Distributing a client application as an ActiveX control . . . . . . . . . . . . . . 31-32 Creating an Active Form for the client application . . . . . . . . . . . . . . . 31-33 xix Building Web applications using InternetExpress . . . . . . . . . . . . . . . 31-33 Building an InternetExpress application. . . . . . . . . . . . . . . . . . 31-34 Using the javascript libraries . . . . . . 31-35 Granting permission to access and launch the application server . . . . . 31-36 Using an XML broker . . . . . . . . . . . . 31-36 Fetching XML data packets . . . . . . . 31-36 Applying updates from XML delta packets . . . . . . . . . . . . . . 31-37 Creating Web pages with an InternetExpress page producer . . . . . . 31-39 Using the Web page editor . . . . . . . 31-39 Setting Web item properties . . . . . . 31-40 Customizing the InternetExpress page producer template . . . . . . . . 31-41 Chapter 32 Using XML in database applications 32-1 Defining transformations . . . . . . . . . . . . 32-1 Mapping between XML nodes and data packet fields . . . . . . . . . . . . . . 32-2 Using XMLMapper. . . . . . . . . . . . . . 32-4 Loading an XML schema or data packet . . . . . . . . . . . . . . . 32-4 Defining mappings . . . . . . . . . . . 32-5 Generating transformation files . . . . 32-6 Converting XML documents into data packets. . . . . . . . . . . . . . . . . . . 32-6 Specifying the source XML document . . . 32-6 Specifying the transformation . . . . . . . 32-7 Obtaining the resulting data packet . . . . 32-7 Converting user-defined nodes . . . . . . . 32-7 Using an XML document as the source for a provider . . . . . . . . . . . . . . . . . . 32-8 Using an XML document as the client of a provider . . . . . . . . . . . . . . . . . . 32-9 Fetching an XML document from a provider . . . . . . . . . . . . . . . . . . 32-9 Applying updates from an XML document to a provider . . . . . . . . . . 32-11 Part III Writing Internet applications Chapter 33 Creating Internet server applications 33-1 About Web Broker and WebSnap . . . . . . . . 33-1 Terminology and standards . . . . . . . . . . . 33-3 Parts of a Uniform Resource Locator . . . . 33-3 URI vs. URL . . . . . . . . . . . . . . . . 33-4 HTTP request header information. . . . . . 33-4 HTTP server activity . . . . . . . . . . . . . . . 33-5 Composing client requests . . . . . . . . . . 33-5 Serving client requests . . . . . . . . . . . . 33-5 Responding to client requests . . . . . . . . 33-6 Types of Web server applications . . . . . . . . 33-6 ISAPI and NSAPI . . . . . . . . . . . . . 33-6 CGI stand-alone . . . . . . . . . . . . . 33-6 Apache . . . . . . . . . . . . . . . . . . . 33-7 Web App Debugger . . . . . . . . . . . 33-7 Converting Web server application target types . . . . . . . . . . . . . . . . . . 33-8 Debugging server applications . . . . . . . . . 33-9 Using the Web Application Debugger . . . 33-9 Launching your application with the Web Application Debugger . . . . 33-9 Converting your application to another type of Web server application . . . . . . . . . . . . . . . 33-10 Debugging Web applications that are DLLs. . . . . . . . . . . . . . . . 33-10 User rights necessary for DLL debugging . . . . . . . . . . . . 33-10 Chapter 34 Using Web Broker 34-1 Creating Web server applications with Web Broker. . . . . . . . . . . . . . . . . . . . 34-1 The Web module. . . . . . . . . . . . . . . . 34-2 The Web Application object . . . . . . . . . 34-3 The structure of a Web Broker application . . . . . . . . . . . . . . . . . . . . 34-3 The Web dispatcher. . . . . . . . . . . . . . . . 34-5 Adding actions to the dispatcher . . . . . . 34-5 Dispatching request messages . . . . . . . . 34-5 xx Action items . . . . . . . . . . . . . . . . . . . 34-6 Determining when action items fire . . . . 34-6 The target URL . . . . . . . . . . . . . . 34-6 The request method type . . . . . . . . 34-7 Enabling and disabling action items . . . . . . . . . . . . . . . . . . . 34-7 Choosing a default action item . . . . . 34-7 Responding to request messages with action items . . . . . . . . . . . . . . . . . 34-8 Sending the response . . . . . . . . . . 34-8 Using multiple action items . . . . . . 34-9 Accessing client request information . . . . . 34-9 Properties that contain request header information . . . . . . . . . . . . . . . . . 34-9 Properties that identify the target . . . 34-9 Properties that describe the Web client . . . . . . . . . . . . . . . . 34-10 Properties that identify the purpose of the request . . . . . . . . . . . . . . 34-10 Properties that describe the expected response . . . . . . . . . . . . . . . . 34-10 Properties that describe the content . . . . . . . . . . . . . . . . . 34-11 The content of HTTP request messages. . . . . . . . . . . . . . . . . . . 34-11 Creating HTTP response messages . . . . . . 34-11 Filling in the response header. . . . . . . . 34-11 Indicating the response status . . . . . 34-12 Indicating the need for client action . . . . . . . . . . . . . . . . . . 34-12 Describing the server application . . . 34-12 Describing the content . . . . . . . . . 34-12 Setting the response content . . . . . . . . 34-13 Sending the response . . . . . . . . . . . . 34-13 Generating the content of response messages . . . . . . . . . . . . . . . . . . . . 34-13 Using page producer components . . . . . 34-14 HTML templates . . . . . . . . . . . . . 34-14 Specifying the HTML template . . . . 34-15 Converting HTML-transparent tags . . . . . . . . . . . . . . . . . . . 34-16 Using page producers from an action item . . . . . . . . . . . . . . . 34-16 Chaining page producers together . . . . . . . . . . . . . . . . . 34-17 Using database information in responses . . . . . . . . . . . . . . . . . . . . 34-18 Adding a session to the Web module . . . 34-18 Representing database information in HTML . . . . . . . . . . . . . . . . . . 34-19 Using dataset page producers . . . . . 34-19 Using table producers . . . . . . . . . 34-20 Specifying the table attributes . . . . . 34-20 Specifying the row attributes . . . . . 34-20 Specifying the columns . . . . . . . . 34-20 Embedding tables in HTML documents . . . . . . . . . . . . . . . 34-21 Setting up a dataset table producer . . . . . . . . . . . . . . . . 34-21 Setting up a query table producer . . . . . . . . . . . . . . . . 34-21 Chapter 35 Creating Web Server applications using WebSnap 35-1 Fundamental WebSnap components . . . . . . 35-2 Web modules. . . . . . . . . . . . . . . . . . 35-2 Web application module types . . . . . 35-3 Web page modules . . . . . . . . . . . . 35-4 Web data modules . . . . . . . . . . . . 35-5 Adapters . . . . . . . . . . . . . . . . . . . . 35-5 Fields . . . . . . . . . . . . . . . . . . . . 35-6 Actions . . . . . . . . . . . . . . . . . . . 35-6 Errors . . . . . . . . . . . . . . . . . . . 35-6 Records . . . . . . . . . . . . . . . . . . 35-6 Page producers . . . . . . . . . . . . . . . . 35-6 Creating Web server applications with WebSnap . . . . . . . . . . . . . . . . . . 35-7 Selecting a server type . . . . . . . . . . . . 35-8 Specifying application module components . . . . . . . . . . . . . . . . . 35-9 Selecting Web application module options . . . . . . . . . . . . . . . . . . . 35-10 Advanced HTML design. . . . . . . . . . . . 35-11 Manipulating server-side script in HTML files . . . . . . . . . . . . . . . . . 35-12 Login support . . . . . . . . . . . . . . . . . . 35-13 Adding login support. . . . . . . . . . . . 35-13 Using the sessions service . . . . . . . . . 35-14 Login pages . . . . . . . . . . . . . . . . . 35-15 Setting pages to require logins . . . . . . . 35-17 User access rights . . . . . . . . . . . . . . 35-17 Dynamically displaying fields as edit or text boxes . . . . . . . . . . . 35-18 Hiding fields and their contents . . . 35-18 Preventing page access . . . . . . . . . 35-19 xxi Server-side scripting in WebSnap . . . . . . . 35-19 Active scripting. . . . . . . . . . . . . . . . 35-20 Script engine . . . . . . . . . . . . . . . . . 35-20 Script blocks. . . . . . . . . . . . . . . . . . 35-20 Creating script . . . . . . . . . . . . . . . . 35-21 Wizard templates . . . . . . . . . . . . 35-21 TAdapterPageProducer . . . . . . . . . 35-21 Editing and viewing script . . . . . . . . . 35-21 Including script in a page . . . . . . . . . . 35-21 Script objects . . . . . . . . . . . . . . . . . 35-22 Dispatching requests and responses . . . . . . 35-22 Dispatcher components . . . . . . . . . . . 35-23 Adapter dispatcher operation. . . . . . . . 35-23 Using adapter components to generate content . . . . . . . . . . . . 35-23 Receiving adapter requests and generating responses . . . . . . . . . 35-25 Image request . . . . . . . . . . . . . . 35-26 Image response . . . . . . . . . . . . . 35-27 Dispatching action items . . . . . . . . . . 35-27 Page dispatcher operation. . . . . . . . . . 35-28 Chapter 36 Creating Web server applications using IntraWeb 36-1 Using IntraWeb components . . . . . . . . . . 36-2 Getting started with IntraWeb . . . . . . . . . 36-3 Creating a new IntraWeb application . . . 36-4 Editing the main form . . . . . . . . . . . . 36-4 Writing an event handler for the button . . . . . . . . . . . . . . . . . . 36-5 Running the completed application . . . . 36-6 Using IntraWeb with Web Broker and WebSnap . . . . . . . . . . . . . . . . . . 36-7 For more information . . . . . . . . . . . . . . 36-8 Chapter 37 Working with XML documents 37-1 Using the Document Object Model . . . . . . 37-2 Working with XML components . . . . . . . . 37-4 Using TXMLDocument . . . . . . . . . . . 37-4 Working with XML nodes . . . . . . . . . . 37-4 Working with a node’s value . . . . . . 37-5 Working with a node’s attributes . . . 37-5 Adding and deleting child nodes . . . 37-6 Abstracting XML documents with the Data Binding wizard . . . . . . . . . . . . . . 37-6 Using the XML Data Binding wizard . . . . 37-8 Using code that the XML Data Binding wizard generates. . . . . . . . . . 37-9 Chapter 38 Using Web Services 38-1 Understanding invokable interfaces . . . . . . 38-2 Using nonscalar types in invokable interfaces . . . . . . . . . . . . . . . . . . . 38-4 Registering nonscalar types . . . . . . . 38-5 Using remotable objects . . . . . . . . . 38-6 Representing attachments . . . . . . . . 38-7 Managing the lifetime of remotable objects . . . . . . . . . . . . . . . . . . 38-7 Remotable object example . . . . . . . . 38-7 Writing servers that support Web Services. . . 38-9 Building a Web Service server . . . . . . . . 38-9 Using the SOAP application wizard . . . 38-10 Adding new Web Services . . . . . . . . . 38-11 Editing the generated code . . . . . . 38-12 Using a different base class . . . . . . 38-12 Using the WSDL importer . . . . . . . . . 38-13 Browsing for Business services . . . . . . 38-14 Understanding UDDI . . . . . . . . . 38-15 Using the UDDI browser . . . . . . . 38-15 Defining and using SOAP headers . . . . 38-16 Defining header classes . . . . . . . . 38-16 Sending and receiving headers . . . . 38-16 Handling scalar-type headers . . . . . 38-17 Communicating the structure of your headers to other applications . . . . 38-18 Creating custom exception classes for Web Services . . . . . . . . . . . . . . . . 38-18 Generating WSDL documents for a Web Service application. . . . . . . . . 38-19 Writing clients for Web Services. . . . . . . . 38-20 Importing WSDL documents . . . . . . . 38-20 Calling invokable interfaces . . . . . . . . 38-20 Obtaining an invokable interface from the generated function . . . . . 38-21 Using a remote interfaced object . . . 38-21 Processing headers in client applications . . . . . . . . . . . . . . . . 38-23 xxii Chapter 39 Working with sockets 39-1 Implementing services . . . . . . . . . . . . . 39-1 Understanding service protocols . . . . . . 39-2 Communicating with applications . . . . . . . . . . . . . . . 39-2 Services and ports . . . . . . . . . . . . . . 39-2 Types of socket connections. . . . . . . . . . . 39-3 Client connections . . . . . . . . . . . . . . 39-3 Listening connections . . . . . . . . . . . . 39-3 Server connections . . . . . . . . . . . . . . 39-3 Describing sockets . . . . . . . . . . . . . . . . 39-4 Describing the host. . . . . . . . . . . . . . 39-4 Choosing between a host name and an IP address . . . . . . . . . . . 39-5 Using ports . . . . . . . . . . . . . . . . . . 39-5 Using socket components . . . . . . . . . . . . 39-6 Getting information about the connection . . . . . . . . . . . . . . . . . . 39-6 Using client sockets . . . . . . . . . . . . . 39-6 Specifying the desired server . . . . . . 39-7 Forming the connection . . . . . . . . . 39-7 Getting information about the connection . . . . . . . . . . . . . . . 39-7 Closing the connection . . . . . . . . . 39-7 Using server sockets . . . . . . . . . . . . . 39-7 Specifying the port . . . . . . . . . . . 39-8 Listening for client requests . . . . . . 39-8 Connecting to clients . . . . . . . . . . 39-8 Closing server connections . . . . . . . 39-8 Responding to socket events . . . . . . . . . . 39-8 Error events . . . . . . . . . . . . . . . . . . 39-9 Client events . . . . . . . . . . . . . . . . . 39-9 Server events . . . . . . . . . . . . . . . . . 39-9 Events when listening . . . . . . . . . . 39-9 Events with client connections . . . . . 39-10 Reading and writing over socket connections . . . . . . . . . . . . . . . . . . . 39-10 Non-blocking connections. . . . . . . . . . 39-10 Reading and writing events . . . . . . 39-11 Blocking connections. . . . . . . . . . . . . 39-11 Part IV Developing COM-based applications Chapter 40 Overview of COM technologies 40-1 COM as a specification and implementation . . . . . . . . . . . . . 40-2 COM extensions . . . . . . . . . . . . . 40-2 Parts of a COM application . . . . . . . . . . . 40-3 COM interfaces . . . . . . . . . . . . . . . . 40-3 The fundamental COM interface, IUnknown . . . . . . . . . . . . . . . . 40-4 COM interface pointers . . . . . . . . . 40-5 COM servers . . . . . . . . . . . . . . . . . . 40-5 CoClasses and class factories . . . . . . 40-6 In-process, out-of-process, and remote servers . . . . . . . . . . . . . . 40-7 The marshaling mechanism . . . . . . . 40-8 Aggregation . . . . . . . . . . . . . . . . 40-9 COM clients . . . . . . . . . . . . . . . . . 40-10 COM extensions. . . . . . . . . . . . . . . . . 40-10 Automation servers . . . . . . . . . . . . . 40-12 Active Server Pages . . . . . . . . . . . . . 40-13 ActiveX controls . . . . . . . . . . . . . . . 40-13 Active Documents. . . . . . . . . . . . . . 40-14 Transactional objects . . . . . . . . . . . . 40-15 Type libraries. . . . . . . . . . . . . . . . . 40-16 The content of type libraries . . . . . . 40-16 Creating type libraries . . . . . . . . . 40-17 When to use type libraries . . . . . . . 40-17 Accessing type libraries . . . . . . . . 40-18 Benefits of using type libraries . . . . 40-18 Using type library tools . . . . . . . . 40-19 Implementing COM objects with wizards . . . . . . . . . . . . . . . . . . 40-19 Code generated by wizards . . . . . . . . 40-22 xxiii Chapter 41 Working with type libraries 41-1 Type Library editor . . . . . . . . . . . . . . . 41-2 Parts of the Type Library editor. . . . . . . 41-3 Toolbar . . . . . . . . . . . . . . . . . . 41-3 Object list pane . . . . . . . . . . . . . . 41-5 Status bar . . . . . . . . . . . . . . . . . 41-5 Pages of type information . . . . . . . 41-6 Type library elements . . . . . . . . . . . . 41-8 Interfaces . . . . . . . . . . . . . . . . . 41-9 Dispinterfaces . . . . . . . . . . . . . . 41-9 CoClasses . . . . . . . . . . . . . . . . . 41-10 Type definitions . . . . . . . . . . . . . 41-10 Modules . . . . . . . . . . . . . . . . . 41-11 Using the Type Library editor. . . . . . . . 41-11 Valid types . . . . . . . . . . . . . . . . 41-12 Using Delphi or IDL syntax . . . . . . 41-13 Creating a new type library . . . . . . 41-19 Opening an existing type library . . . 41-20 Adding an interface to the type library . . . . . . . . . . . . . . . . . . 41-21 Modifying an interface using the type library . . . . . . . . . . . . . . . 41-21 Adding properties and methods to an interface or dispinterface . . . . . 41-22 Adding a CoClass to the type library . . . . . . . . . . . . . . . . . . 41-23 Adding an interface to a CoClass . . . 41-23 Adding an enumeration to the type library . . . . . . . . . . . . . . . 41-24 Adding an alias to the type library . . . . . . . . . . . . . . . . . . 41-24 Adding a record or union to the type library . . . . . . . . . . . . . . . 41-24 Adding a module to the type library . . . . . . . . . . . . . . . . . . 41-25 Saving and registering type library information . . . . . . . . . . . . . . . 41-25 Apply Updates dialog . . . . . . . . . 41-26 Saving a type library . . . . . . . . . . 41-26 Refreshing the type library . . . . . . . 41-26 Registering the type library . . . . . . 41-27 Exporting an IDL file . . . . . . . . . . 41-27 Deploying type libraries . . . . . . . . . . . . 41-27 Chapter 42 Creating COM clients 42-1 Importing type library information. . . . . . . 42-2 Using the Import Type Library dialog . . . 42-3 Using the Import ActiveX dialog . . . . . . 42-4 Code generated when you import type library information . . . . . . . . . . 42-5 Controlling an imported object . . . . . . . . . 42-6 Using component wrappers . . . . . . . . . 42-6 ActiveX wrappers . . . . . . . . . . . . 42-6 Automation object wrappers . . . . . . 42-7 Using data-aware ActiveX controls . . . . . 42-8 Example: Printing a document with Microsoft Word . . . . . . . . . . . . . . . 42-9 Preparing Delphi for this example . . 42-10 Importing the Word type library . . . 42-10 Using a VTable or dispatch interface object to control Microsoft Word . . . . . . . . . . . . 42-11 Cleaning up the example . . . . . . . 42-12 Writing client code based on type library definitions . . . . . . . . . . . . . 42-13 Connecting to a server . . . . . . . . . 42-13 Controlling an Automation server using a dual interface . . . . . . . . 42-13 Controlling an Automation server using a dispatch interface . . . . . . 42-14 Handling events in an automation controller . . . . . . . . . . . . . . . . 42-14 Creating clients for servers that do not have a type library . . . . . . . . . . . . . . 42-16 Using .NET assemblies with Delphi . . . . . 42-17 Requirements for COM interoperability . . . . . . . . . . . . . . 42-17 .NET components and type libraries . . . 42-18 Accessing user-defined .NET components . . . . . . . . . . . . . . . . 42-20 xxiv Chapter 43 Creating simple COM servers 43-1 Overview of creating a COM object . . . . . . 43-2 Designing a COM object . . . . . . . . . . . . 43-2 Using the COM object wizard . . . . . . . . . 43-3 Using the Automation object wizard . . . . . 43-5 COM object instancing types . . . . . . . . 43-6 Choosing a threading model . . . . . . . . 43-6 Writing an object that supports the free threading model . . . . . . . . . 43-8 Writing an object that supports the apartment threading model . . . . . 43-9 Writing an object that supports the neutral threading model . . . . . . . 43-9 Defining a COM object’s interface . . . . . . . 43-9 Adding a property to the object’s interface . . . . . . . . . . . . . . . . . . . 43-10 Adding a method to the object’s interface . . . . . . . . . . . . . . . . . . . 43-10 Exposing events to clients . . . . . . . . . . 43-11 Managing events in your Automation object . . . . . . . . . . . 43-12 Automation interfaces. . . . . . . . . . . . . . 43-13 Dual interfaces . . . . . . . . . . . . . . . . 43-13 Dispatch interfaces . . . . . . . . . . . . . . 43-14 Custom interfaces . . . . . . . . . . . . . . 43-15 Marshaling data . . . . . . . . . . . . . . . . . 43-15 Automation compatible types . . . . . . . 43-16 Type restrictions for automatic marshaling . . . . . . . . . . . . . . . . . 43-16 Custom marshaling . . . . . . . . . . . . . 43-17 Registering a COM object . . . . . . . . . . . . 43-17 Registering an in-process server . . . . . . 43-17 Registering an out-of-process server . . . . 43-17 Testing and debugging the application . . . . 43-18 Chapter 44 Creating an Active Server Page 44-1 Creating an Active Server Object. . . . . . . . 44-2 Using the ASP intrinsics . . . . . . . . . . . 44-3 Application . . . . . . . . . . . . . . . . 44-4 Request . . . . . . . . . . . . . . . . . . 44-4 Response . . . . . . . . . . . . . . . . . 44-5 Session . . . . . . . . . . . . . . . . . . 44-6 Server . . . . . . . . . . . . . . . . . . . 44-6 Creating ASPs for in-process or out-of-process servers . . . . . . . . . . . 44-7 Registering an Active Server Object . . . . . . 44-8 Registering an in-process server . . . . . . . 44-8 Registering an out-of-process server . . . . 44-8 Testing and debugging the Active Server Page application. . . . . . . . . . . . . . . . . 44-8 Chapter 45 Creating an ActiveX control 45-1 Overview of ActiveX control creation . . . . . 45-2 Elements of an ActiveX control . . . . . . . 45-2 VCL control . . . . . . . . . . . . . . . . 45-3 ActiveX wrapper . . . . . . . . . . . . . 45-3 Type library . . . . . . . . . . . . . . . . 45-3 Property page . . . . . . . . . . . . . . . 45-3 Designing an ActiveX control . . . . . . . . . . 45-4 Generating an ActiveX control from a VCL control . . . . . . . . . . . . . . . . . . . 45-4 Generating an ActiveX control based on a VCL form. . . . . . . . . . . . . . . . . . . . 45-6 Licensing ActiveX controls. . . . . . . . . . . . 45-7 Customizing the ActiveX control’s interface . . . . . . . . . . . . . . . . . . . . . 45-8 Adding additional properties, methods, and events . . . . . . . . . . . . 45-9 Adding properties and methods . . . . 45-9 Adding events . . . . . . . . . . . . . 45-10 Enabling simple data binding with the type library. . . . . . . . . . . . . . . 45-11 Creating a property page for an ActiveX control . . . . . . . . . . . . . . . . 45-12 Creating a new property page . . . . . . . 45-13 Adding controls to a property page . . . . 45-13 Associating property page controls with ActiveX control properties . . . . . 45-13 Updating the property page . . . . . . 45-13 Updating the object . . . . . . . . . . 45-14 Connecting a property page to an ActiveX control . . . . . . . . . . . . . . 45-14 Registering an ActiveX control . . . . . . . . 45-15 Testing an ActiveX control . . . . . . . . . . . 45-15 Deploying an ActiveX control on the Web . . . . . . . . . . . . . . . . . . . 45-15 Setting options. . . . . . . . . . . . . . . . 45-16 xxv Chapter 46 Creating MTS or COM objects 46-1 Understanding transactional objects. . . . . . 46-2 Requirements for a transactional object . . . . . . . . . . . . . . . . . . . . . 46-3 Managing resources . . . . . . . . . . . . . . . 46-3 Accessing the object context. . . . . . . . . 46-4 Just-in-time activation . . . . . . . . . . . . 46-4 Resource pooling . . . . . . . . . . . . . . . 46-5 Database resource dispensers . . . . . 46-6 Shared property manager . . . . . . . 46-6 Releasing resources . . . . . . . . . . . 46-8 Object pooling . . . . . . . . . . . . . . . . 46-8 MTS and COM transaction support . . . . . 46-9 Transaction attributes . . . . . . . . . . . . 46-10 Setting the transaction attribute . . . . 46-11 Stateful and stateless objects . . . . . . . . 46-11 Influencing how transactions end . . . . . 46-12 Initiating transactions . . . . . . . . . . . . 46-12 Setting up a transaction object on the client side . . . . . . . . . . . . 46-13 Setting up a transaction object on the server side . . . . . . . . . . . . . 46-14 Transaction time-out . . . . . . . . . . . . . 46-14 Role-based security . . . . . . . . . . . . . . . 46-15 Overview of creating transactional objects . . . . . . . . . . . . . . . . . . . . . 46-15 Using the Transactional Object wizard . . . . 46-16 Choosing a threading model for a transactional object . . . . . . . . . . . . 46-17 Activities . . . . . . . . . . . . . . . . 46-18 Generating events under COM . . . . . . . 46-19 Using the Event Object wizard. . . . . . . 46-21 Using the COM Event Subscription object wizard . . . . . . . . . . . . . . . . 46-22 Firing events using a COM event object . . . . . . . . . . . . . . . . . . . . 46-23 Passing object references . . . . . . . . . . . . 46-23 Using the SafeRef method . . . . . . . 46-24 Callbacks . . . . . . . . . . . . . . . . 46-25 Debugging and testing transactional objects . . . . . . . . . . . . . . . . . . . . . 46-25 Installing transactional objects . . . . . . . . 46-26 Administering transactional objects . . . . . 46-27 Index I-1 |
好例子网口号:伸出你的我的手 — 分享!
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论