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 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761
|
/*
wxActiveX Library Licence, Version 3
====================================
Copyright (C) 2003 Lindsay Mathieson [, ...]
Everyone is permitted to copy and distribute verbatim copies
of this licence document, but changing it is not allowed.
wxActiveX LIBRARY LICENCE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, or (at
your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
General Public Licence for more details.
You should have received a copy of the GNU Library General Public Licence
along with this software, usually in a file named COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA.
EXCEPTION NOTICE
1. As a special exception, the copyright holders of this library give
permission for additional uses of the text contained in this release of
the library as licenced under the wxActiveX Library Licence, applying
either version 3 of the Licence, or (at your option) any later version of
the Licence as published by the copyright holders of version 3 of the
Licence document.
2. The exception is that you may use, copy, link, modify and distribute
under the user's own terms, binary object code versions of works based
on the Library.
3. If you copy code from files distributed under the terms of the GNU
General Public Licence or the GNU Library General Public Licence into a
copy of this library, as this licence permits, the exception does not
apply to the code that you add in this way. To avoid misleading anyone as
to the status of such modified files, you must delete this exception
notice from such code and/or adjust the licensing conditions notice
accordingly.
4. If you write modifications of your own for this library, it is your
choice whether to permit this exception to apply to your modifications.
If you do not wish that, you must delete the exception notice from such
code and/or adjust the licensing conditions notice accordingly.
*/
#include "wxActiveX.h"
#include <wx/strconv.h>
#include <wx/event.h>
#include <wx/string.h>
#include <wx/datetime.h>
#include <wx/log.h>
#include <oleidl.h>
#include <winerror.h>
#include <idispids.h>
#include <olectl.h>
using namespace std;
// Depending on compilation mode, the wx headers may have undef'd
// this, but in this case we need it so the virtual method in
// FrameSite will match what is in oleidl.h.
#ifndef GetObject
#ifdef _UNICODE
#define GetObject GetObjectW
#else
#define GetObject GetObjectA
#endif
#endif
//////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxActiveX, wxWindow)
EVT_SIZE(wxActiveX::OnSize)
EVT_PAINT(wxActiveX::OnPaint)
EVT_MOUSE_EVENTS(wxActiveX::OnMouse)
EVT_SET_FOCUS(wxActiveX::OnSetFocus)
EVT_KILL_FOCUS(wxActiveX::OnKillFocus)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxActiveX, wxWindow)
class wxActiveX;
class FrameSite :
public IOleClientSite,
public IOleInPlaceSiteEx,
public IOleInPlaceFrame,
public IOleItemContainer,
public IDispatch,
public IOleCommandTarget,
public IOleDocumentSite,
public IAdviseSink,
public IOleControlSite
{
private:
DECLARE_OLE_UNKNOWN(FrameSite);
public:
FrameSite(wxActiveX * win);
virtual ~FrameSite();
//IOleWindow
STDMETHODIMP GetWindow(HWND*);
STDMETHODIMP ContextSensitiveHelp(BOOL);
//IOleInPlaceUIWindow
STDMETHODIMP GetBorder(LPRECT);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*, LPCOLESTR);
//IOleInPlaceFrame
STDMETHODIMP InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS);
STDMETHODIMP SetMenu(HMENU, HOLEMENU, HWND);
STDMETHODIMP RemoveMenus(HMENU);
STDMETHODIMP SetStatusText(LPCOLESTR);
STDMETHODIMP EnableModeless(BOOL);
STDMETHODIMP TranslateAccelerator(LPMSG, WORD);
//IOleInPlaceSite
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(IOleInPlaceFrame**, IOleInPlaceUIWindow**,
LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO);
STDMETHODIMP Scroll(SIZE);
STDMETHODIMP OnUIDeactivate(BOOL);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT);
//IOleInPlaceSiteEx
STDMETHODIMP OnInPlaceActivateEx(BOOL*, DWORD);
STDMETHODIMP OnInPlaceDeactivateEx(BOOL);
STDMETHODIMP RequestUIActivate();
//IOleClientSite
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker**);
STDMETHODIMP GetContainer(LPOLECONTAINER FAR*);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL);
STDMETHODIMP RequestNewObjectLayout();
//IOleControlSite
STDMETHODIMP OnControlInfoChanged();
STDMETHODIMP LockInPlaceActive(BOOL);
STDMETHODIMP GetExtendedControl(IDispatch**);
STDMETHODIMP TransformCoords(POINTL*, POINTF*, DWORD);
STDMETHODIMP TranslateAccelerator(LPMSG, DWORD);
STDMETHODIMP OnFocus(BOOL);
STDMETHODIMP ShowPropertyFrame();
//IOleCommandTarget
STDMETHODIMP QueryStatus(const GUID*, ULONG, OLECMD[], OLECMDTEXT*);
STDMETHODIMP Exec(const GUID*, DWORD, DWORD, VARIANTARG*, VARIANTARG*);
//IParseDisplayName
STDMETHODIMP ParseDisplayName(IBindCtx*, LPOLESTR, ULONG*, IMoniker**);
//IOleContainer
STDMETHODIMP EnumObjects(DWORD, IEnumUnknown**);
STDMETHODIMP LockContainer(BOOL);
//IOleItemContainer
STDMETHODIMP GetObject(LPOLESTR, DWORD, IBindCtx*, REFIID, void**);
STDMETHODIMP GetObjectStorage(LPOLESTR, IBindCtx*, REFIID, void**);
STDMETHODIMP IsRunning(LPOLESTR);
//IDispatch
STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*);
STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**);
STDMETHODIMP GetTypeInfoCount(unsigned int*);
STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
//IAdviseSink
void STDMETHODCALLTYPE OnDataChange(FORMATETC*, STGMEDIUM*);
void STDMETHODCALLTYPE OnViewChange(DWORD, LONG);
void STDMETHODCALLTYPE OnRename(IMoniker*);
void STDMETHODCALLTYPE OnSave();
void STDMETHODCALLTYPE OnClose();
// IOleDocumentSite
HRESULT STDMETHODCALLTYPE ActivateMe(IOleDocumentView __RPC_FAR *pViewToActivate);
protected:
wxActiveX * m_window;
HDC m_hDCBuffer;
HWND m_hWndParent;
bool m_bSupportsWindowlessActivation;
bool m_bInPlaceLocked;
bool m_bInPlaceActive;
bool m_bUIActive;
bool m_bWindowless;
LCID m_nAmbientLocale;
COLORREF m_clrAmbientForeColor;
COLORREF m_clrAmbientBackColor;
bool m_bAmbientShowHatching;
bool m_bAmbientShowGrabHandles;
bool m_bAmbientAppearance;
};
DEFINE_OLE_TABLE(FrameSite)
OLE_INTERFACE(IID_IUnknown, IOleClientSite)
OLE_IINTERFACE(IOleClientSite)
OLE_INTERFACE(IID_IOleWindow, IOleInPlaceSite)
OLE_IINTERFACE(IOleInPlaceSite)
OLE_IINTERFACE(IOleInPlaceSiteEx)
//OLE_IINTERFACE(IOleWindow)
OLE_IINTERFACE(IOleInPlaceUIWindow)
OLE_IINTERFACE(IOleInPlaceFrame)
OLE_IINTERFACE(IParseDisplayName)
OLE_IINTERFACE(IOleContainer)
OLE_IINTERFACE(IOleItemContainer)
OLE_IINTERFACE(IDispatch)
OLE_IINTERFACE(IOleCommandTarget)
OLE_IINTERFACE(IOleDocumentSite)
OLE_IINTERFACE(IAdviseSink)
OLE_IINTERFACE(IOleControlSite)
END_OLE_TABLE;
wxActiveX::wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name) :
wxWindow(parent, id, pos, size, style, name)
{
m_bAmbientUserMode = true;
m_docAdviseCookie = 0;
CreateActiveX(clsid);
}
wxActiveX::wxActiveX(wxWindow * parent, const wxString& progId, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name) :
wxWindow(parent, id, pos, size, style, name)
{
m_bAmbientUserMode = true;
m_docAdviseCookie = 0;
CreateActiveX((LPOLESTR) (const wchar_t *) progId.wc_str(wxConvUTF8));
}
wxActiveX::~wxActiveX()
{
// disconnect connection points
wxOleConnectionArray::iterator it = m_connections.begin();
while (it != m_connections.end())
{
wxOleConnectionPoint& cp = it->first;
cp->Unadvise(it->second);
it++;
};
m_connections.clear();
if (m_oleInPlaceObject.Ok())
{
m_oleInPlaceObject->InPlaceDeactivate();
m_oleInPlaceObject->UIDeactivate();
}
if (m_oleObject.Ok())
{
if (m_docAdviseCookie != 0)
m_oleObject->Unadvise(m_docAdviseCookie);
m_oleObject->DoVerb(OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL);
m_oleObject->Close(OLECLOSE_NOSAVE);
m_oleObject->SetClientSite(NULL);
}
// Unregister object as active
RevokeActiveObject(m_pdwRegister, NULL);
}
void wxActiveX::CreateActiveX(REFCLSID clsid)
{
HRESULT hret;
////////////////////////////////////////////////////////
// FrameSite
FrameSite *frame = new FrameSite(this);
// oleClientSite
hret = m_clientSite.QueryInterface(IID_IOleClientSite, (IDispatch *) frame);
wxCHECK_RET(SUCCEEDED(hret), _T("m_clientSite.QueryInterface failed"));
// adviseSink
wxAutoOleInterface<IAdviseSink> adviseSink(IID_IAdviseSink, (IDispatch *) frame);
wxCHECK_RET(adviseSink.Ok(), _T("adviseSink not Ok"));
// Create Object, get IUnknown interface
m_ActiveX.CreateInstance(clsid, IID_IUnknown);
wxCHECK_RET(m_ActiveX.Ok(), _T("m_ActiveX.CreateInstance failed"));
// Register object as active
unsigned long pdwRegister;
hret = RegisterActiveObject(m_ActiveX, clsid, ACTIVEOBJECT_WEAK, &m_pdwRegister);
WXOLE_WARN(hret, "Unable to register object as active");
// Get Dispatch interface
hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX);
WXOLE_WARN(hret, "Unable to get dispatch interface");
// Type Info
GetTypeInfo();
// Get IOleObject interface
hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX);
wxCHECK_RET(SUCCEEDED(hret), _("Unable to get IOleObject interface"));
// get IViewObject Interface
hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX);
wxCHECK_RET(SUCCEEDED(hret), _T("Unable to get IViewObject Interface"));
// document advise
m_docAdviseCookie = 0;
hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
WXOLE_WARN(hret, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
OleSetContainedObject(m_oleObject, TRUE);
OleRun(m_oleObject);
// Get IOleInPlaceObject interface
hret = m_oleInPlaceObject.QueryInterface(IID_IOleInPlaceObject, m_ActiveX);
wxCHECK_RET(SUCCEEDED(hret), _T("Unable to get IOleInPlaceObject interface"));
// status
DWORD dwMiscStatus;
m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
wxCHECK_RET(SUCCEEDED(hret), _T("Unable to get oleObject status"));
// set client site first ?
if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
m_oleObject->SetClientSite(m_clientSite);
// stream init
wxAutoOleInterface<IPersistStreamInit>
pPersistStreamInit(IID_IPersistStreamInit, m_oleObject);
if (pPersistStreamInit.Ok())
{
hret = pPersistStreamInit->InitNew();
WXOLE_WARN(hret, "CreateActiveX::pPersistStreamInit->InitNew()");
};
if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
m_oleObject->SetClientSite(m_clientSite);
int w, h;
GetClientSize(&w, &h);
RECT posRect;
posRect.left = 0;
posRect.top = 0;
posRect.right = w;
posRect.bottom = h;
m_oleObjectHWND = 0;
if (m_oleInPlaceObject.Ok())
{
hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
if (SUCCEEDED(hret))
::SetActiveWindow(m_oleObjectHWND);
};
if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
{
if (w > 0 && h > 0 && m_oleInPlaceObject.Ok())
m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)GetHWND(), &posRect);
hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)GetHWND(), &posRect);
};
if (! m_oleObjectHWND && m_oleInPlaceObject.Ok())
{
hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
};
if (m_oleObjectHWND)
{
::SetActiveWindow(m_oleObjectHWND);
::ShowWindow(m_oleObjectHWND, SW_SHOW);
// Update by GBR to resize older controls
wxSizeEvent szEvent;
szEvent.m_size = wxSize(w, h) ;
GetEventHandler()->AddPendingEvent(szEvent);
};
}
void wxActiveX::CreateActiveX(LPOLESTR progId)
{
CLSID clsid;
if (CLSIDFromProgID(progId, &clsid) != S_OK)
return;
CreateActiveX(clsid);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Case Insensitive Map of Event names to eventTypes
// created dynamically at run time in:
// EVT_ACTIVEX(eventName, id, fn)
// we map the pointer to them so that:
// const wxEventType& RegisterActiveXEvent(wxString eventName);
// can return a const reference, which is neccessary for event tables
// probably should use a wxWindows hash table here, but I'm lazy ...
typedef map<wxString, wxEventType *, NS_wxActiveX::less_wxStringI> ActiveXNamedEventMap;
static ActiveXNamedEventMap sg_NamedEventMap;
const wxEventType& RegisterActiveXEvent(const wxChar *eventName)
{
wxString ev = eventName;
ActiveXNamedEventMap::iterator it = sg_NamedEventMap.find(ev);
if (it == sg_NamedEventMap.end())
{
wxEventType *et = new wxEventType(wxNewEventType());
sg_NamedEventMap[ev] = et;
return *et;
};
return *(it->second);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Map of Event DISPID's to eventTypes
// created dynamically at run time in:
// EVT_ACTIVEX(eventName, id, fn)
// we map the pointer to them so that:
// const wxEventType& RegisterActiveXEvent(wxString eventName);
// can return a const reference, which is neccessary for event tables
typedef map<DISPID, wxEventType *> ActiveXDISPIDEventMap;
static ActiveXDISPIDEventMap sg_dispIdEventMap;
const wxEventType& RegisterActiveXEvent(DISPID event)
{
ActiveXDISPIDEventMap::iterator it = sg_dispIdEventMap.find(event);
if (it == sg_dispIdEventMap.end())
{
wxEventType *et = new wxEventType(wxNewEventType());
sg_dispIdEventMap[event] = et;
return *et;
};
return *(it->second);
};
// one off class for automatic freeing of activeX eventtypes
class ActiveXEventMapFlusher
{
public:
~ActiveXEventMapFlusher()
{
// Named events
ActiveXNamedEventMap::iterator it = sg_NamedEventMap.end();
while (it != sg_NamedEventMap.end())
{
delete it->second;
it++;
};
sg_NamedEventMap.clear();
// DISPID events
ActiveXDISPIDEventMap::iterator dit = sg_dispIdEventMap.end();
while (dit != sg_dispIdEventMap.end())
{
delete dit->second;
dit++;
};
sg_dispIdEventMap.clear();
};
};
static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher;
//////////////////////////////////////////////////////
VARTYPE wxTypeToVType(const wxVariant& v)
{
wxString type = v.GetType();
if (type == wxT("bool"))
return VT_BOOL;
else if (type == wxT("char"))
return VT_I1;
else if (type == wxT("datetime"))
return VT_DATE;
else if (type == wxT("double"))
return VT_R8;
else if (type == wxT("list"))
return VT_ARRAY;
else if (type == wxT("long"))
return VT_I4;
else if (type == wxT("string"))
return VT_BSTR;
else if (type == wxT("stringlist"))
return VT_ARRAY;
else if (type == wxT("date"))
return VT_DATE;
else if (type == wxT("time"))
return VT_DATE;
else if (type == wxT("void*"))
return VT_VOID | VT_BYREF;
else
return VT_NULL;
};
bool wxDateTimeToDATE(wxDateTime dt, DATE& d)
{
SYSTEMTIME st;
memset(&st, 0, sizeof(st));
st.wYear = dt.GetYear();
st.wMonth = dt.GetMonth() + 1;
st.wDay = dt.GetDay();
st.wHour = dt.GetHour();
st.wMinute = dt.GetMinute();
st.wSecond = dt.GetSecond();
st.wMilliseconds = dt.GetMillisecond();
return SystemTimeToVariantTime(&st, &d) != FALSE;
};
bool wxDateTimeToVariant(wxDateTime dt, VARIANTARG& va)
{
return wxDateTimeToDATE(dt, va.date);
};
bool DATEToWxDateTime(DATE date, wxDateTime& dt)
{
SYSTEMTIME st;
if (! VariantTimeToSystemTime(date, &st))
return false;
dt = wxDateTime(
st.wDay,
wxDateTime::Month(int(wxDateTime::Jan) + st.wMonth - 1),
st.wYear,
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
return true;
};
bool VariantToWxDateTime(VARIANTARG va, wxDateTime& dt)
{
HRESULT hr = VariantChangeType(&va, &va, 0, VT_DATE);
if (! SUCCEEDED(hr))
return false;
return DATEToWxDateTime(va.date, dt);
};
bool MSWVariantToVariant(VARIANTARG& va, wxVariant& vx)
{
bool byRef = false;
VARTYPE vt = va.vt;
if (vt & VT_ARRAY)
return false; // don't support arrays yet
if (vt & VT_BYREF)
{
byRef = true;
vt &= ~(VT_BYREF);
};
switch(vt)
{
case VT_VARIANT:
if (byRef)
return MSWVariantToVariant(*va.pvarVal, vx);
else
{
VARIANT tmp = va;
VariantChangeType(&tmp, &tmp, 0, wxTypeToVType(vx));
bool rc = MSWVariantToVariant(tmp, vx);
VariantClear(&tmp);
return rc;
};
// 1 byte chars
case VT_I1:
case VT_UI1:
if (byRef)
vx = (wxChar) *va.pbVal;
else
vx = (wxChar) va.bVal;
return true;
// 2 byte shorts
case VT_I2:
case VT_UI2:
if (byRef)
vx = (long) *va.puiVal;
else
vx = (long) va.uiVal;
return true;
// 4 bytes longs
case VT_I4:
case VT_UI4:
case VT_INT:
case VT_UINT:
case VT_ERROR:
if (byRef)
vx = (long) *va.pulVal;
else
vx = (long) va.ulVal;
return true;
// 4 byte floats
case VT_R4:
if (byRef)
vx = *va.pfltVal;
else
vx = va.fltVal;
return true;
// 8 byte doubles
case VT_R8:
if (byRef)
vx = *va.pdblVal;
else
vx = va.dblVal;
return true;
case VT_BOOL:
if (byRef)
vx = (*va.pboolVal ? true : false);
else
vx = (va.boolVal ? true : false);
return true;
case VT_CY:
vx.MakeNull();
return false; // what the hell is a CY ?
case VT_DECIMAL:
{
double d = 0;
HRESULT hr;
if (byRef)
hr = VarR8FromDec(va.pdecVal, &d);
else
hr = VarR8FromDec(&va.decVal, &d);
vx = d;
return SUCCEEDED(hr);
};
case VT_DATE:
{
wxDateTime dt;
bool rc = false;
if (byRef)
rc = DATEToWxDateTime(*va.pdate, dt);
else
rc = VariantToWxDateTime(va, dt);
vx = dt;
return rc;
};
case VT_BSTR:
if (byRef)
vx = wxString(*va.pbstrVal);
else
vx = wxString(va.bstrVal);
return true;
case VT_UNKNOWN: // should do a custom wxVariantData for this
if (byRef)
vx = (void *) *va.ppunkVal;
else
vx = (void *) va.punkVal;
return false;
case VT_DISPATCH: // should do a custom wxVariantData for this
if (byRef)
vx = (void *) *va.ppdispVal;
else
vx = (void *) va.pdispVal;
return false;
default:
vx.MakeNull();
return false;
};
};
bool VariantToMSWVariant(const wxVariant& vx, VARIANTARG& va)
{
bool byRef = false;
VARTYPE vt = va.vt;
if (vt & VT_ARRAY)
return false; // don't support arrays yet
if (vt & VT_BYREF)
{
byRef = true;
vt &= ~(VT_BYREF);
};
switch(vt)
{
case VT_VARIANT:
if (byRef)
return VariantToMSWVariant(vx, *va.pvarVal);
else
{
va.vt = wxTypeToVType(vx);
return VariantToMSWVariant(vx, va);
};
// 1 byte chars
case VT_I1:
case VT_UI1:
if (byRef)
*va.pbVal = (wxChar) vx;
else
va.bVal = (wxChar) vx;
return true;
// 2 byte shorts
case VT_I2:
case VT_UI2:
if (byRef)
*va.puiVal = (long) vx;
else
va.uiVal = (long) vx;
return true;
// 4 bytes longs
case VT_I4:
case VT_UI4:
case VT_INT:
case VT_UINT:
case VT_ERROR:
if (byRef)
*va.pulVal = (long) vx;
else
va.ulVal = (long) vx;
return true;
// 4 byte floats
case VT_R4:
if (byRef)
*va.pfltVal = (double) vx;
else
va.fltVal = (double) vx;
return true;
// 8 byte doubles
case VT_R8:
if (byRef)
*va.pdblVal = (double) vx;
else
va.dblVal = (double) vx;
return true;
case VT_BOOL:
if (byRef)
*va.pboolVal = ((bool) vx) ? TRUE : FALSE;
else
va.boolVal = ((bool) vx) ? TRUE : FALSE;
return true;
case VT_CY:
return false; // what the hell is a CY ?
case VT_DECIMAL:
if (byRef)
return SUCCEEDED(VarDecFromR8(vx, va.pdecVal));
else
return SUCCEEDED(VarDecFromR8(vx, &va.decVal));
case VT_DATE:
if (byRef)
return wxDateTimeToDATE(vx, *va.pdate);
else
return wxDateTimeToVariant(vx,va);
case VT_BSTR:
if (byRef)
*va.pbstrVal = SysAllocString(vx.GetString().wc_str(wxConvUTF8));
else
va.bstrVal = SysAllocString(vx.GetString().wc_str(wxConvUTF8));
return true;
case VT_UNKNOWN: // should do a custom wxVariantData for this
if (byRef)
*va.ppunkVal = (IUnknown *) (void *) vx;
else
va.punkVal = (IUnknown *) (void *) vx;
return false;
case VT_DISPATCH: // should do a custom wxVariantData for this
if (byRef)
*va.ppdispVal = (IDispatch *) (void *) vx;
else
va.pdispVal = (IDispatch *) (void *) vx;
return false;
default:
return false;
};
};
IMPLEMENT_CLASS(wxActiveXEvent, wxCommandEvent)
class wxActiveXEvents : public IDispatch
{
private:
DECLARE_OLE_UNKNOWN(wxActiveXEvents);
wxActiveX *m_activeX;
IID m_customId;
bool m_haveCustomId;
friend bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc);
public:
wxActiveXEvents(wxActiveX *ax) : m_activeX(ax), m_haveCustomId(false) {}
wxActiveXEvents(wxActiveX *ax, REFIID iid) : m_activeX(ax), m_haveCustomId(true), m_customId(iid) {}
virtual ~wxActiveXEvents()
{
}
//IDispatch
STDMETHODIMP GetIDsOfNames(REFIID r, OLECHAR** o, unsigned int i, LCID l, DISPID* d)
{
return E_NOTIMPL;
};
STDMETHODIMP GetTypeInfo(unsigned int i, LCID l, ITypeInfo** t)
{
return E_NOTIMPL;
};
STDMETHODIMP GetTypeInfoCount(unsigned int* i)
{
return E_NOTIMPL;
};
void DispatchEvent(wxActiveX::FuncX &func, const wxEventType& eventType, DISPPARAMS * pDispParams)
{
wxActiveXEvent event;
event.SetId(m_activeX->GetId());
event.SetEventType(eventType);
event.m_params.NullList();
event.m_params.SetName(func.name);
// arguments
if (pDispParams)
{
// cdecl call
// sometimes the pDispParams does not match the param info for a activex control
int nArg = wxMin(func.params.size(), pDispParams->cArgs);
for (int i = nArg - 1; i >= 0; i--)
{
VARIANTARG& va = pDispParams->rgvarg[i];
wxActiveX::ParamX &px = func.params[nArg - i - 1];
wxVariant vx;
vx.SetName(px.name);
MSWVariantToVariant(va, vx);
event.m_params.Append(vx);
};
};
if (func.hasOut)
{
int nArg = wxMin(func.params.size(), pDispParams->cArgs);
m_activeX->GetEventHandler()->ProcessEvent(event);
for (int i = 0; i < nArg; i++)
{
VARIANTARG& va = pDispParams->rgvarg[i];
wxActiveX::ParamX &px = func.params[nArg - i - 1];
if (px.IsOut())
{
wxVariant& vx = event.m_params[nArg - i - 1];
VariantToMSWVariant(vx, va);
};
};
}
else
m_activeX->GetEventHandler()->AddPendingEvent(event);
};
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS * pDispParams,
VARIANT * pVarResult, EXCEPINFO * pExcepInfo,
unsigned int * puArgErr)
{
if (wFlags & (DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
return E_NOTIMPL;
wxASSERT(m_activeX);
// find event for dispid
wxActiveX::MemberIdMap::iterator mit = m_activeX->m_eventMemberIds.find((MEMBERID) dispIdMember);
if (mit == m_activeX->m_eventMemberIds.end())
return S_OK;
// sanity check
int midx = mit->second;
if (midx < 0 || midx >= m_activeX->GetEventCount())
return S_OK;
wxActiveX::FuncX &func = m_activeX->m_events[midx];
// try to find dispid event
ActiveXDISPIDEventMap::iterator dit = sg_dispIdEventMap.find(dispIdMember);
if (dit != sg_dispIdEventMap.end())
{
// Dispatch Event
DispatchEvent(func, *(dit->second), pDispParams);
return S_OK;
};
// try named event
ActiveXNamedEventMap::iterator nit = sg_NamedEventMap.find(func.name);
if (nit == sg_NamedEventMap.end())
return S_OK;
// Dispatch Event
DispatchEvent(func, *(nit->second), pDispParams);
return S_OK;
}
};
bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc)
{
if (self->m_haveCustomId && IsEqualIID(iid, self->m_customId))
{
WXOLE_TRACE("Found Custom Dispatch Interface");
*_interface = (IUnknown *) (IDispatch *) self;
desc = "Custom Dispatch Interface";
return true;
};
return false;
};
DEFINE_OLE_TABLE(wxActiveXEvents)
OLE_IINTERFACE(IUnknown)
OLE_INTERFACE(IID_IDispatch, IDispatch)
OLE_INTERFACE_CUSTOM(wxActiveXEventsInterface)
END_OLE_TABLE;
wxString wxActiveXEvent::EventName()
{
return m_params.GetName();
};
int wxActiveXEvent::ParamCount() const
{
return m_params.GetCount();
};
wxString wxActiveXEvent::ParamType(int idx)
{
wxASSERT(idx >= 0 && idx < m_params.GetCount());
return m_params[idx].GetType();
};
wxString wxActiveXEvent::ParamName(int idx)
{
wxASSERT(idx >= 0 && idx < m_params.GetCount());
return m_params[idx].GetName();
};
static wxVariant nullVar;
wxVariant& wxActiveXEvent::operator[] (int idx)
{
wxASSERT(idx >= 0 && idx < ParamCount());
return m_params[idx];
};
wxVariant& wxActiveXEvent::operator[] (wxString name)
{
int i;
for (i = 0; i < m_params.GetCount(); i++)
{
if (name.CmpNoCase(m_params[i].GetName()) == 0)
return m_params[i];
};
wxString err = _T("wxActiveXEvent::operator[] invalid name <") + name + _T(">");
err += _T("\r\nValid Names = :\r\n");
for (i = 0; i < m_params.GetCount(); i++)
{
err += m_params[i].GetName();
err += _T("\r\n");
};
wxASSERT_MSG(false, err);
return nullVar;
};
void wxActiveX::GetTypeInfo()
{
/*
We are currently only interested in the IDispatch interface
to the control. For dual interfaces (TypeKind = TKIND_INTERFACE)
we should drill down through the inheritance
(using TYPEATTR->cImplTypes) and GetRefTypeOfImplType(n)
and retrieve all the func names etc that way, then generate a C++
header file for it.
But we don't do this and probably never will, so if we have a DUAL
interface then we query for the IDispatch
via GetRefTypeOfImplType(-1).
*/
HRESULT hret = 0;
// get type info via class info
wxAutoOleInterface<IProvideClassInfo> classInfo(IID_IProvideClassInfo, m_ActiveX);
if (! classInfo.Ok())
return;
// type info
wxAutoOleInterface<ITypeInfo> typeInfo;
hret = classInfo->GetClassInfo(typeInfo.GetRef());
if (! typeInfo.Ok())
return;
// TYPEATTR
TYPEATTR *ta = NULL;
hret = typeInfo->GetTypeAttr(&ta);
if (! ta)
return;
// this should be a TKIND_COCLASS
wxASSERT(ta->typekind == TKIND_COCLASS);
// iterate contained interfaces
for (int i = 0; i < ta->cImplTypes; i++)
{
HREFTYPE rt = 0;
// get dispatch type info handle
hret = typeInfo->GetRefTypeOfImplType(i, &rt);
if (! SUCCEEDED(hret))
continue;
// get dispatch type info interface
wxAutoOleInterface<ITypeInfo> ti;
hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef());
if (! ti.Ok())
continue;
// check if default event sink
bool defInterface = false;
bool defEventSink = false;
int impTypeFlags = 0;
typeInfo->GetImplTypeFlags(i, &impTypeFlags);
if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT)
{
if (impTypeFlags & IMPLTYPEFLAG_FSOURCE)
{
WXOLE_TRACEOUT("Default Event Sink");
defEventSink = true;
if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE)
{
WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable");
defEventSink = false;
};
}
else
{
WXOLE_TRACEOUT("Default Interface");
defInterface = true;
}
};
// process
GetTypeInfo(ti, defInterface, defEventSink);
};
// free
typeInfo->ReleaseTypeAttr(ta);
};
void ElemDescToParam(const ELEMDESC& ed, wxActiveX::ParamX& param)
{
param.flags = ed.idldesc.wIDLFlags;
param.vt = ed.tdesc.vt;
param.isPtr = (param.vt == VT_PTR);
param.isSafeArray = (param.vt == VT_SAFEARRAY);
if (param.isPtr || param.isSafeArray)
param.vt = ed.tdesc.lptdesc->vt;
};
void wxActiveX::GetTypeInfo(ITypeInfo *ti, bool defInterface, bool defEventSink)
{
// wxAutoOleInterface<> assumes a ref has already been added
ti->AddRef();
wxAutoOleInterface<ITypeInfo> typeInfo(ti);
// TYPEATTR
TYPEATTR *ta = NULL;
HRESULT hret = typeInfo->GetTypeAttr(&ta);
if (! ta)
return;
if (ta->typekind == TKIND_DISPATCH)
{
WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str());
if (defEventSink)
{
wxActiveXEvents *disp = new wxActiveXEvents(this, ta->guid);
ConnectAdvise(ta->guid, disp);
};
// Get properties
// See bug #1280715 in the wxActiveX SF project
int i;
for (i = 0; i < ta->cVars; i++) {
VARDESC FAR *vd = NULL;
typeInfo->GetVarDesc(i, &vd) ;
BSTR bstrProperty = NULL;
typeInfo->GetDocumentation(vd->memid, &bstrProperty,
NULL, NULL, NULL);
wxString propName(bstrProperty);
m_props.push_back(PropX());
int idx = m_props.size() - 1;
m_propNames[propName] = idx;
m_props[idx].name = propName;
m_props[idx].memid = vd->memid;
ParamX param;
param.isSafeArray = false;
param.isPtr = false;
param.flags = vd->elemdescVar.idldesc.wIDLFlags;
param.vt = vd->elemdescVar.tdesc.vt;
m_props[idx].arg = param;
m_props[idx].type = param;
}
// Get Function Names
for (i = 0; i < ta->cFuncs; i++)
{
FUNCDESC FAR *fd = NULL;
hret = typeInfo->GetFuncDesc(i, &fd);
if (! fd)
continue;
BSTR anames[1] = {NULL};
unsigned int n = 0;
hret = typeInfo->GetNames(fd->memid, anames, 1, &n);
if (anames[0])
{
wxString name = anames[0];
WXOLE_TRACEOUT("Name " << i << " = " << name.c_str());
SysFreeString(anames[0]);
if (defInterface || defEventSink)
{
FuncX func;
func.name = name;
func.memid = fd->memid;
func.hasOut = false;
// get Param Names
unsigned int maxPNames = fd->cParams + 1;
unsigned int nPNames = 0;
BSTR *pnames = new BSTR[maxPNames];
hret = typeInfo->GetNames(fd->memid, pnames, maxPNames, &nPNames);
int pbase = 0;
if (fd->cParams < int(nPNames))
{
pbase++;
SysFreeString(pnames[0]);
};
// params
ElemDescToParam(fd->elemdescFunc, func.retType);
for (int p = 0; p < fd->cParams; p++)
{
ParamX param;
ElemDescToParam(fd->lprgelemdescParam[p], param);
param.name = pnames[pbase + p];
SysFreeString(pnames[pbase + p]);
param.isOptional = (p > fd->cParams - fd->cParamsOpt);
func.hasOut |= (param.IsOut() || param.isPtr);
func.params.push_back(param);
};
delete [] pnames;
if (defEventSink)
{
m_events.push_back(func);
m_eventMemberIds[fd->memid] = m_events.size() - 1;
}
else
{
if (fd->invkind == INVOKE_FUNC)
{
m_methods.push_back(func);
m_methodNames[func.name] = m_methods.size() - 1;
}
else
{
NameMap::iterator it = m_propNames.find(func.name);
int idx = -1;
if (it == m_propNames.end())
{
m_props.push_back(PropX());
idx = m_props.size() - 1;
m_propNames[func.name] = idx;
m_props[idx].name = func.name;
m_props[idx].memid = func.memid;
}
else
idx = it->second;
if (fd->invkind == INVOKE_PROPERTYGET)
m_props[idx].type = func.retType;
else if (func.params.size() > 0)
{
m_props[idx].arg = func.params[0];
m_props[idx].putByRef = (fd->invkind == INVOKE_PROPERTYPUTREF);
};
};
};
};
};
typeInfo->ReleaseFuncDesc(fd);
};
}
typeInfo->ReleaseTypeAttr(ta);
};
///////////////////////////////////////////////
// Type Info exposure
const wxActiveX::FuncX& wxActiveX::GetEventDesc(int idx) const
{
wxASSERT(idx >= 0 && idx < GetEventCount());
return m_events[idx];
};
const wxActiveX::PropX& wxActiveX::GetPropDesc(int idx) const
{
if (idx < 0 || idx >= GetPropCount())
throw exception("Property index out of bounds");
return m_props[idx];
};
const wxActiveX::PropX& wxActiveX::GetPropDesc(const wxString& name) const
{
NameMap::const_iterator it = m_propNames.find(name);
if (it == m_propNames.end())
{
wxString s;
s << _T("property <") << name << _T("> not found");
throw exception(s.mb_str());
};
return GetPropDesc(it->second);
};
const wxActiveX::FuncX& wxActiveX::GetMethodDesc(int idx) const
{
if (idx < 0 || idx >= GetMethodCount())
throw exception("Method index out of bounds");
return m_methods[idx];
};
const wxActiveX::FuncX& wxActiveX::GetMethodDesc(const wxString& name) const
{
NameMap::const_iterator it = m_methodNames.find(name);
if (it == m_methodNames.end())
{
wxString s;
s << _T("method <") << name << _T("> not found");
throw exception(s.mb_str());
};
return GetMethodDesc(it->second);
};
void wxActiveX::SetProp(MEMBERID name, VARIANTARG& value)
{
DISPID pids[1] = {DISPID_PROPERTYPUT};
DISPPARAMS params = {&value, pids, 1, 1};
EXCEPINFO x;
memset(&x, 0, sizeof(x));
unsigned int argErr = 0;
HRESULT hr = m_Dispatch->Invoke(
name,
IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
¶ms, NULL, &x, &argErr);
WXOLE_WARN(hr, "Invoke Prop(...)");
};
void wxActiveX::SetProp(const wxString &name, const wxVariant &value)
{
const PropX& prop = GetPropDesc(name);
if (! prop.CanSet())
{
wxString s;
s << _T("property <") << name << _T("> is readonly");
throw exception(s.mb_str());
};
VARIANT v = {prop.arg.vt};
VariantToMSWVariant(value, v);
SetProp(prop.memid, v);
VariantClear(&v); // this releases any BSTR's etc
};
VARIANT wxActiveX::GetPropAsVariant(MEMBERID name)
{
VARIANT v;
VariantInit(&v);
DISPPARAMS params = {NULL, NULL, 0, 0};
EXCEPINFO x;
memset(&x, 0, sizeof(x));
unsigned int argErr = 0;
HRESULT hr = m_Dispatch->Invoke(
name,
IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
¶ms, &v, &x, &argErr);
WXOLE_WARN(hr, "Invoke Prop(...)");
return v;
};
VARIANT wxActiveX::GetPropAsVariant(const wxString& name)
{
const PropX& prop = GetPropDesc(name);
if (! prop.CanGet())
{
wxString s;
s << _T("property <") << name << _T("> is writeonly");
throw exception(s.mb_str());
};
return GetPropAsVariant(prop.memid);
};
wxVariant wxActiveX::GetPropAsWxVariant(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_BSTR);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
wxVariant wv;
MSWVariantToVariant(v, wv);
VariantClear(&v);
return wv;
};
wxString wxActiveX::GetPropAsString(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_BSTR);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
wxString s = v.bstrVal;
VariantClear(&v);
return s;
};
char wxActiveX::GetPropAsChar(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_I1);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
return v.cVal;
};
long wxActiveX::GetPropAsLong(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_I4);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
return v.iVal;
};
bool wxActiveX::GetPropAsBool(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_BOOL);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
return v.boolVal != 0;
};
double wxActiveX::GetPropAsDouble(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_R8);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
return v.dblVal;
};
wxDateTime wxActiveX::GetPropAsDateTime(const wxString& name)
{
wxDateTime dt;
VARIANT v = GetPropAsVariant(name);
if (! VariantToWxDateTime(v, dt))
throw exception("Unable to convert variant to wxDateTime");
return dt;
};
void *wxActiveX::GetPropAsPointer(const wxString& name)
{
VARIANT v = GetPropAsVariant(name);
HRESULT hr = VariantChangeType(&v, &v, 0, VT_BYREF);
if (! SUCCEEDED(hr))
throw exception("Unable to convert variant");
return v.byref;
};
// call methods
VARIANT wxActiveX::CallMethod(MEMBERID name, VARIANTARG args[], int argc)
{
DISPPARAMS pargs = {args, NULL, argc, 0};
VARIANT retVal;
VariantInit(&retVal);
EXCEPINFO x;
memset(&x, 0, sizeof(x));
unsigned int argErr = 0;
HRESULT hr = m_Dispatch->Invoke(
name,
IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&pargs, &retVal, &x, &argErr);
WXOLE_WARN(hr, "Invoke Method(...)");
return retVal;
};
VARIANT wxActiveX::CallMethod(const wxString& name, VARIANTARG args[], int argc)
{
const FuncX& func = GetMethodDesc(name);
if (argc < 0)
argc = func.params.size();
return CallMethod(func.memid, args, argc);
};
wxVariant wxActiveX::CallMethod(const wxString& name, wxVariant args[], int nargs)
{
const FuncX& func = GetMethodDesc(name);
if (args == NULL)
nargs = 0;
VARIANTARG *vargs = NULL;
if (nargs < 0)
nargs = func.params.size();
if (nargs > 0)
vargs = new VARIANTARG[nargs];
if (vargs)
{
int i;
// init type of vargs
for (i = 0; i < nargs; i++)
vargs[nargs - i - 1].vt = func.params[i].vt;
// put data
for (i = 0; i < nargs; i++)
VariantToMSWVariant(args[i], vargs[nargs - i - 1]);
};
VARIANT rv = CallMethod(func.memid, vargs, nargs);
// process any by ref params
if (func.hasOut)
{
for (int i = 0; i < nargs; i++)
{
VARIANTARG& va = vargs[nargs - i - 1];
const wxActiveX::ParamX &px = func.params[i];
if (px.IsOut())
{
wxVariant& vx = args[i];
MSWVariantToVariant(va, vx);
};
};
}
if (vargs)
{
for (int i = 0; i < nargs; i++)
VariantClear(&vargs[i]);
delete [] vargs;
};
wxVariant ret;
MSWVariantToVariant(rv, ret);
VariantClear(&rv);
return ret;
};
///////////////////////////////////////////////
HRESULT wxActiveX::ConnectAdvise(REFIID riid, IUnknown *events)
{
wxOleConnectionPoint cp;
DWORD adviseCookie = 0;
wxAutoOleInterface<IConnectionPointContainer> cpContainer(IID_IConnectionPointContainer, m_ActiveX);
if (! cpContainer.Ok())
return E_FAIL;
HRESULT hret = cpContainer->FindConnectionPoint(riid, cp.GetRef());
if (! SUCCEEDED(hret))
return hret;
hret = cp->Advise(events, &adviseCookie);
if (SUCCEEDED(hret))
m_connections.push_back(wxOleConnection(cp, adviseCookie));
else
{
WXOLE_WARN(hret, "ConnectAdvise");
};
return hret;
};
HRESULT wxActiveX::AmbientPropertyChanged(DISPID dispid)
{
wxAutoOleInterface<IOleControl> oleControl(IID_IOleControl, m_oleObject);
if (oleControl.Ok())
return oleControl->OnAmbientPropertyChange(dispid);
else
return S_FALSE;
};
#define HIMETRIC_PER_INCH 2540
#define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
static void PixelsToHimetric(SIZEL &sz)
{
static int logX = 0;
static int logY = 0;
if (logY == 0)
{
// initaliase
HDC dc = GetDC(NULL);
logX = GetDeviceCaps(dc, LOGPIXELSX);
logY = GetDeviceCaps(dc, LOGPIXELSY);
ReleaseDC(NULL, dc);
};
#define HIMETRIC_INCH 2540
#define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels))
sz.cx = CONVERT(sz.cx, logX);
sz.cy = CONVERT(sz.cy, logY);
#undef CONVERT
#undef HIMETRIC_INCH
}
void wxActiveX::OnSize(wxSizeEvent& event)
{
int w, h;
GetClientSize(&w, &h);
RECT posRect;
posRect.left = 0;
posRect.top = 0;
posRect.right = w;
posRect.bottom = h;
if (w <= 0 && h <= 0)
return;
// extents are in HIMETRIC units
if (m_oleObject.Ok())
{
SIZEL sz = {w, h};
PixelsToHimetric(sz);
SIZEL sz2;
m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
if (sz2.cx != sz.cx || sz.cy != sz2.cy)
m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
};
if (m_oleInPlaceObject.Ok())
m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
}
void wxActiveX::OnPaint(wxPaintEvent& event)
{
wxLogTrace(wxT(""),wxT("repainting activex win"));
wxPaintDC dc(this);
int w, h;
GetSize(&w, &h);
RECT posRect;
posRect.left = 0;
posRect.top = 0;
posRect.right = w;
posRect.bottom = h;
// Draw only when control is windowless or deactivated
if (m_viewObject)
{
::RedrawWindow(m_oleObjectHWND, NULL, NULL, RDW_INTERNALPAINT);
{
RECTL *prcBounds = (RECTL *) &posRect;
m_viewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL,
(HDC)dc.GetHDC(), prcBounds, NULL, NULL, 0);
}
}
else
{
dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle(0, 0, w, h);
dc.SetBrush(wxNullBrush);
}
}
void wxActiveX::OnMouse(wxMouseEvent& event)
{
if (m_oleObjectHWND == NULL)
{
wxLogTrace(wxT(""),wxT("no oleInPlaceObject"));
event.Skip();
return;
}
wxLogTrace(wxT(""),wxT("mouse event"));
UINT msg = 0;
WPARAM wParam = 0;
LPARAM lParam = 0;
LRESULT lResult = 0;
if (event.m_metaDown)
wParam |= MK_CONTROL;
if (event.m_shiftDown)
wParam |= MK_SHIFT;
if (event.m_leftDown)
wParam |= MK_LBUTTON;
if (event.m_middleDown)
wParam |= MK_MBUTTON;
if (event.m_rightDown)
wParam |= MK_RBUTTON;
lParam = event.m_x << 16;
lParam |= event.m_y;
if (event.LeftDown())
msg = WM_LBUTTONDOWN;
else if (event.LeftDClick())
msg = WM_LBUTTONDBLCLK;
else if (event.LeftUp())
msg = WM_LBUTTONUP;
else if (event.MiddleDown())
msg = WM_MBUTTONDOWN;
else if (event.MiddleDClick())
msg = WM_MBUTTONDBLCLK;
else if (event.MiddleUp())
msg = WM_MBUTTONUP;
else if (event.RightDown())
msg = WM_RBUTTONDOWN;
else if (event.RightDClick())
msg = WM_RBUTTONDBLCLK;
else if (event.RightUp())
msg = WM_RBUTTONUP;
else if (event.Moving() || event.Dragging())
msg = WM_MOUSEMOVE;
wxString log;
if (msg == 0)
{
wxLogTrace(wxT(""),wxT("no message"));
event.Skip(); return;
};
if (!::SendMessage(m_oleObjectHWND, msg, wParam, lParam))
{
wxLogTrace(wxT(""),wxT("msg not delivered"));
event.Skip();
return;
};
wxLogTrace(wxT(""),wxT("msg sent"));
}
bool wxActiveX::MSWTranslateMessage(WXMSG *msg){
if (msg->message == WM_KEYDOWN) {
if ( m_oleInPlaceActiveObject.Ok() )
{
HRESULT result = m_oleInPlaceActiveObject->TranslateAccelerator(msg);
return (result == S_OK);
}
}
return wxWindow::MSWTranslateMessage(msg);
}
WXLRESULT wxActiveX::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
if (m_oleObjectHWND == NULL)
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
switch(nMsg)
{
case WM_CHAR:
case WM_DEADCHAR:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
PostMessage(m_oleObjectHWND, nMsg, wParam, lParam);
default:
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
};
};
void wxActiveX::OnSetFocus(wxFocusEvent& event)
{
if (m_oleInPlaceActiveObject.Ok())
m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE);
}
void wxActiveX::OnKillFocus(wxFocusEvent& event)
{
if (m_oleInPlaceActiveObject.Ok())
m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE);
}
FrameSite::FrameSite(wxActiveX * win)
{
m_window = win;
m_bSupportsWindowlessActivation = true;
m_bInPlaceLocked = false;
m_bUIActive = false;
m_bInPlaceActive = false;
m_bWindowless = false;
m_nAmbientLocale = 0;
m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT);
m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW);
m_bAmbientShowHatching = true;
m_bAmbientShowGrabHandles = true;
m_bAmbientAppearance = true;
m_hDCBuffer = NULL;
m_hWndParent = (HWND)m_window->GetHWND();
}
FrameSite::~FrameSite()
{
}
//IDispatch
HRESULT FrameSite::GetIDsOfNames(REFIID riid, OLECHAR ** rgszNames, unsigned int cNames,
LCID lcid, DISPID * rgDispId)
{
WXOLE_TRACE("IDispatch::GetIDsOfNames");
return E_NOTIMPL;
}
HRESULT FrameSite::GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo ** ppTInfo)
{
WXOLE_TRACE("IDispatch::GetTypeInfo");
return E_NOTIMPL;
}
HRESULT FrameSite::GetTypeInfoCount(unsigned int * pcTInfo)
{
WXOLE_TRACE("IDispatch::GetTypeInfoCount");
return E_NOTIMPL;
}
HRESULT FrameSite::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS * pDispParams,
VARIANT * pVarResult, EXCEPINFO * pExcepInfo,
unsigned int * puArgErr)
{
WXOLE_TRACE("IDispatch::Invoke");
if (!(wFlags & DISPATCH_PROPERTYGET))
return S_OK;
HRESULT hr;
if (pVarResult == NULL)
return E_INVALIDARG;
//The most common case is boolean, use as an initial type
V_VT(pVarResult) = VT_BOOL;
switch (dispIdMember)
{
case DISPID_AMBIENT_MESSAGEREFLECT:
WXOLE_TRACE("Invoke::DISPID_AMBIENT_MESSAGEREFLECT");
V_BOOL(pVarResult)= FALSE;
return S_OK;
case DISPID_AMBIENT_DISPLAYASDEFAULT:
WXOLE_TRACE("Invoke::DISPID_AMBIENT_DISPLAYASDEFAULT");
V_BOOL(pVarResult)= TRUE;
return S_OK;
case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
WXOLE_TRACE("Invoke::DISPID_AMBIENT_OFFLINEIFNOTCONNECTED");
V_BOOL(pVarResult) = TRUE;
return S_OK;
case DISPID_AMBIENT_SILENT:
WXOLE_TRACE("Invoke::DISPID_AMBIENT_SILENT");
V_BOOL(pVarResult)= TRUE;
return S_OK;
case DISPID_AMBIENT_APPEARANCE:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientAppearance;
break;
case DISPID_AMBIENT_FORECOLOR:
pVarResult->vt = VT_I4;
pVarResult->lVal = (long) m_clrAmbientForeColor;
break;
case DISPID_AMBIENT_BACKCOLOR:
pVarResult->vt = VT_I4;
pVarResult->lVal = (long) m_clrAmbientBackColor;
break;
case DISPID_AMBIENT_LOCALEID:
pVarResult->vt = VT_I4;
pVarResult->lVal = (long) m_nAmbientLocale;
break;
case DISPID_AMBIENT_USERMODE:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_window->m_bAmbientUserMode;
break;
case DISPID_AMBIENT_SHOWGRABHANDLES:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientShowGrabHandles;
break;
case DISPID_AMBIENT_SHOWHATCHING:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientShowHatching;
break;
default:
return DISP_E_MEMBERNOTFOUND;
}
return S_OK;
}
//IOleWindow
HRESULT FrameSite::GetWindow(HWND * phwnd)
{
WXOLE_TRACE("IOleWindow::GetWindow");
if (phwnd == NULL)
return E_INVALIDARG;
(*phwnd) = m_hWndParent;
return S_OK;
}
HRESULT FrameSite::ContextSensitiveHelp(BOOL fEnterMode)
{
WXOLE_TRACE("IOleWindow::ContextSensitiveHelp");
return S_OK;
}
//IOleInPlaceUIWindow
HRESULT FrameSite::GetBorder(LPRECT lprectBorder)
{
WXOLE_TRACE("IOleInPlaceUIWindow::GetBorder");
if (lprectBorder == NULL)
return E_INVALIDARG;
return INPLACE_E_NOTOOLSPACE;
}
HRESULT FrameSite::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
WXOLE_TRACE("IOleInPlaceUIWindow::RequestBorderSpace");
if (pborderwidths == NULL)
return E_INVALIDARG;
return INPLACE_E_NOTOOLSPACE;
}
HRESULT FrameSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
WXOLE_TRACE("IOleInPlaceUIWindow::SetBorderSpace");
return S_OK;
}
HRESULT FrameSite::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
{
WXOLE_TRACE("IOleInPlaceUIWindow::SetActiveObject");
if (pActiveObject)
pActiveObject->AddRef();
m_window->m_oleInPlaceActiveObject = pActiveObject;
return S_OK;
}
//IOleInPlaceFrame
HRESULT FrameSite::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
WXOLE_TRACE("IOleInPlaceFrame::InsertMenus");
return S_OK;
}
HRESULT FrameSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
{
WXOLE_TRACE("IOleInPlaceFrame::SetMenu");
return S_OK;
}
HRESULT FrameSite::RemoveMenus(HMENU hmenuShared)
{
WXOLE_TRACE("IOleInPlaceFrame::RemoveMenus");
return S_OK;
}
HRESULT FrameSite::SetStatusText(LPCOLESTR pszStatusText)
{
WXOLE_TRACE("IOleInPlaceFrame::SetStatusText");
//((wxFrame*)wxGetApp().GetTopWindow())->GetStatusBar()->SetStatusText(pszStatusText);
return S_OK;
}
HRESULT FrameSite::EnableModeless(BOOL fEnable)
{
WXOLE_TRACE("IOleInPlaceFrame::EnableModeless");
return S_OK;
}
HRESULT FrameSite::TranslateAccelerator(LPMSG lpmsg, WORD wID)
{
WXOLE_TRACE("IOleInPlaceFrame::TranslateAccelerator");
// TODO: send an event with this id
if (m_window->m_oleInPlaceActiveObject.Ok())
m_window->m_oleInPlaceActiveObject->TranslateAccelerator(lpmsg);
return S_FALSE;
}
//IOleInPlaceSite
HRESULT FrameSite::CanInPlaceActivate()
{
WXOLE_TRACE("IOleInPlaceSite::CanInPlaceActivate");
return S_OK;
}
HRESULT FrameSite::OnInPlaceActivate()
{
WXOLE_TRACE("IOleInPlaceSite::OnInPlaceActivate");
m_bInPlaceActive = true;
return S_OK;
}
HRESULT FrameSite::OnUIActivate()
{
WXOLE_TRACE("IOleInPlaceSite::OnUIActivate");
m_bUIActive = true;
return S_OK;
}
HRESULT FrameSite::GetWindowContext(IOleInPlaceFrame **ppFrame,
IOleInPlaceUIWindow **ppDoc,
LPRECT lprcPosRect,
LPRECT lprcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
WXOLE_TRACE("IOleInPlaceSite::GetWindowContext");
if (ppFrame == NULL || ppDoc == NULL || lprcPosRect == NULL ||
lprcClipRect == NULL || lpFrameInfo == NULL)
{
if (ppFrame != NULL)
(*ppFrame) = NULL;
if (ppDoc != NULL)
(*ppDoc) = NULL;
return E_INVALIDARG;
}
HRESULT hr = QueryInterface(IID_IOleInPlaceFrame, (void **) ppFrame);
if (! SUCCEEDED(hr))
{
WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceFrame Error !");
return E_UNEXPECTED;
};
hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc);
if (! SUCCEEDED(hr))
{
WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceUIWindow Error !");
(*ppFrame)->Release();
*ppFrame = NULL;
return E_UNEXPECTED;
};
int w, h;
m_window->GetClientSize(&w, &h);
if (lprcPosRect)
{
lprcPosRect->left = lprcPosRect->top = 0;
lprcPosRect->right = w;
lprcPosRect->bottom = h;
};
if (lprcClipRect)
{
lprcClipRect->left = lprcClipRect->top = 0;
lprcClipRect->right = w;
lprcClipRect->bottom = h;
};
memset(lpFrameInfo, 0, sizeof(OLEINPLACEFRAMEINFO));
lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
lpFrameInfo->hwndFrame = m_hWndParent;
return S_OK;
}
HRESULT FrameSite::Scroll(SIZE scrollExtent)
{
WXOLE_TRACE("IOleInPlaceSite::Scroll");
return S_OK;
}
HRESULT FrameSite::OnUIDeactivate(BOOL fUndoable)
{
WXOLE_TRACE("IOleInPlaceSite::OnUIDeactivate");
m_bUIActive = false;
return S_OK;
}
HRESULT FrameSite::OnInPlaceDeactivate()
{
WXOLE_TRACE("IOleInPlaceSite::OnInPlaceDeactivate");
m_bInPlaceActive = false;
return S_OK;
}
HRESULT FrameSite::DiscardUndoState()
{
WXOLE_TRACE("IOleInPlaceSite::DiscardUndoState");
return S_OK;
}
HRESULT FrameSite::DeactivateAndUndo()
{
WXOLE_TRACE("IOleInPlaceSite::DeactivateAndUndo");
return S_OK;
}
HRESULT FrameSite::OnPosRectChange(LPCRECT lprcPosRect)
{
WXOLE_TRACE("IOleInPlaceSite::OnPosRectChange");
if (m_window->m_oleInPlaceObject.Ok() && lprcPosRect)
m_window->m_oleInPlaceObject->SetObjectRects(lprcPosRect, lprcPosRect);
return S_OK;
}
//IOleInPlaceSiteEx
HRESULT FrameSite::OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD dwFlags)
{
WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceActivateEx");
OleLockRunning(m_window->m_ActiveX, TRUE, FALSE);
if (pfNoRedraw)
(*pfNoRedraw) = FALSE;
return S_OK;
}
HRESULT FrameSite::OnInPlaceDeactivateEx(BOOL fNoRedraw)
{
WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceDeactivateEx");
OleLockRunning(m_window->m_ActiveX, FALSE, FALSE);
return S_OK;
}
HRESULT FrameSite::RequestUIActivate()
{
WXOLE_TRACE("IOleInPlaceSiteEx::RequestUIActivate");
return S_OK;
}
//IOleClientSite
HRESULT FrameSite::SaveObject()
{
WXOLE_TRACE("IOleClientSite::SaveObject");
return S_OK;
}
const char *OleGetMonikerToStr(DWORD dwAssign)
{
switch (dwAssign)
{
case OLEGETMONIKER_ONLYIFTHERE : return "OLEGETMONIKER_ONLYIFTHERE";
case OLEGETMONIKER_FORCEASSIGN : return "OLEGETMONIKER_FORCEASSIGN";
case OLEGETMONIKER_UNASSIGN : return "OLEGETMONIKER_UNASSIGN";
case OLEGETMONIKER_TEMPFORUSER : return "OLEGETMONIKER_TEMPFORUSER";
default : return "Bad Enum";
};
};
const char *OleGetWhicMonikerStr(DWORD dwWhichMoniker)
{
switch(dwWhichMoniker)
{
case OLEWHICHMK_CONTAINER : return "OLEWHICHMK_CONTAINER";
case OLEWHICHMK_OBJREL : return "OLEWHICHMK_OBJREL";
case OLEWHICHMK_OBJFULL : return "OLEWHICHMK_OBJFULL";
default : return "Bad Enum";
};
};
HRESULT FrameSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
IMoniker ** ppmk)
{
WXOLE_TRACEOUT("IOleClientSite::GetMoniker(" << OleGetMonikerToStr(dwAssign) << ", " << OleGetWhicMonikerStr(dwWhichMoniker) << ")");
if (! ppmk)
return E_FAIL;
/*
HRESULT hr = CreateFileMoniker(L"e:\\dev\\wxie\\bug-zap.swf", ppmk);
if (SUCCEEDED(hr))
return S_OK;
*/
*ppmk = NULL;
return E_FAIL ;
}
HRESULT FrameSite::GetContainer(LPOLECONTAINER * ppContainer)
{
WXOLE_TRACE("IOleClientSite::GetContainer");
if (ppContainer == NULL)
return E_INVALIDARG;
HRESULT hr = QueryInterface(IID_IOleContainer, (void**)(ppContainer));
wxASSERT(SUCCEEDED(hr));
return hr;
}
HRESULT FrameSite::ShowObject()
{
WXOLE_TRACE("IOleClientSite::ShowObject");
if (m_window->m_oleObjectHWND)
::ShowWindow(m_window->m_oleObjectHWND, SW_SHOW);
return S_OK;
}
HRESULT FrameSite::OnShowWindow(BOOL fShow)
{
WXOLE_TRACE("IOleClientSite::OnShowWindow");
return S_OK;
}
HRESULT FrameSite::RequestNewObjectLayout()
{
WXOLE_TRACE("IOleClientSite::RequestNewObjectLayout");
return E_NOTIMPL;
}
// IParseDisplayName
HRESULT FrameSite::ParseDisplayName(IBindCtx *pbc, LPOLESTR pszDisplayName,
ULONG *pchEaten, IMoniker **ppmkOut)
{
WXOLE_TRACE("IParseDisplayName::ParseDisplayName");
return E_NOTIMPL;
}
//IOleContainer
HRESULT FrameSite::EnumObjects(DWORD grfFlags, IEnumUnknown **ppenum)
{
WXOLE_TRACE("IOleContainer::EnumObjects");
return E_NOTIMPL;
}
HRESULT FrameSite::LockContainer(BOOL fLock)
{
WXOLE_TRACE("IOleContainer::LockContainer");
// TODO
return S_OK;
}
//IOleItemContainer
HRESULT FrameSite::GetObject(LPOLESTR pszItem, DWORD dwSpeedNeeded,
IBindCtx * pbc, REFIID riid, void ** ppvObject)
{
WXOLE_TRACE("IOleItemContainer::GetObject");
if (pszItem == NULL)
return E_INVALIDARG;
if (ppvObject == NULL)
return E_INVALIDARG;
*ppvObject = NULL;
return MK_E_NOOBJECT;
}
HRESULT FrameSite::GetObjectStorage(LPOLESTR pszItem, IBindCtx * pbc,
REFIID riid, void ** ppvStorage)
{
WXOLE_TRACE("IOleItemContainer::GetObjectStorage");
if (pszItem == NULL)
return E_INVALIDARG;
if (ppvStorage == NULL)
return E_INVALIDARG;
*ppvStorage = NULL;
return MK_E_NOOBJECT;
}
HRESULT FrameSite::IsRunning(LPOLESTR pszItem)
{
WXOLE_TRACE("IOleItemContainer::IsRunning");
if (pszItem == NULL)
return E_INVALIDARG;
return MK_E_NOOBJECT;
}
//IOleControlSite
HRESULT FrameSite::OnControlInfoChanged()
{
WXOLE_TRACE("IOleControlSite::OnControlInfoChanged");
return S_OK;
}
HRESULT FrameSite::LockInPlaceActive(BOOL fLock)
{
WXOLE_TRACE("IOleControlSite::LockInPlaceActive");
m_bInPlaceLocked = (fLock) ? true : false;
return S_OK;
}
HRESULT FrameSite::GetExtendedControl(IDispatch ** ppDisp)
{
WXOLE_TRACE("IOleControlSite::GetExtendedControl");
return E_NOTIMPL;
}
HRESULT FrameSite::TransformCoords(POINTL * pPtlHimetric, POINTF * pPtfContainer, DWORD dwFlags)
{
WXOLE_TRACE("IOleControlSite::TransformCoords");
HRESULT hr = S_OK;
if (pPtlHimetric == NULL)
return E_INVALIDARG;
if (pPtfContainer == NULL)
return E_INVALIDARG;
return E_NOTIMPL;
}
HRESULT FrameSite::TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers)
{
WXOLE_TRACE("IOleControlSite::TranslateAccelerator");
// TODO: send an event with this id
return E_NOTIMPL;
}
HRESULT FrameSite::OnFocus(BOOL fGotFocus)
{
WXOLE_TRACE("IOleControlSite::OnFocus");
return S_OK;
}
HRESULT FrameSite::ShowPropertyFrame()
{
WXOLE_TRACE("IOleControlSite::ShowPropertyFrame");
return E_NOTIMPL;
}
//IOleCommandTarget
HRESULT FrameSite::QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds,
OLECMD * prgCmds, OLECMDTEXT * pCmdTet)
{
WXOLE_TRACE("IOleCommandTarget::QueryStatus");
if (prgCmds == NULL) return E_INVALIDARG;
bool bCmdGroupFound = false;
for (ULONG nCmd = 0; nCmd < cCmds; nCmd++)
{
// unsupported by default
prgCmds[nCmd].cmdf = 0;
// TODO
}
if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; }
return S_OK;
}
HRESULT FrameSite::Exec(const GUID * pguidCmdGroup, DWORD nCmdID,
DWORD nCmdExecOpt, VARIANTARG * pVaIn,
VARIANTARG * pVaOut)
{
WXOLE_TRACE("IOleCommandTarget::Exec");
bool bCmdGroupFound = false;
if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; }
return OLECMDERR_E_NOTSUPPORTED;
}
//IAdviseSink
void STDMETHODCALLTYPE FrameSite::OnDataChange(FORMATETC * pFormatEtc, STGMEDIUM * pgStgMed)
{
WXOLE_TRACE("IAdviseSink::OnDataChange");
}
void STDMETHODCALLTYPE FrameSite::OnViewChange(DWORD dwAspect, LONG lIndex)
{
WXOLE_TRACE("IAdviseSink::OnViewChange");
// redraw the control
}
void STDMETHODCALLTYPE FrameSite::OnRename(IMoniker * pmk)
{
WXOLE_TRACE("IAdviseSink::OnRename");
}
void STDMETHODCALLTYPE FrameSite::OnSave()
{
WXOLE_TRACE("IAdviseSink::OnSave");
}
void STDMETHODCALLTYPE FrameSite::OnClose()
{
WXOLE_TRACE("IAdviseSink::OnClose");
}
/////////////////////////////////////////////
// IOleDocumentSite
HRESULT STDMETHODCALLTYPE FrameSite::ActivateMe(
/* [in] */ IOleDocumentView __RPC_FAR *pViewToActivate)
{
wxAutoOleInterface<IOleInPlaceSite> inPlaceSite(IID_IOleInPlaceSite, (IDispatch *) this);
if (!inPlaceSite.Ok())
return E_FAIL;
if (pViewToActivate)
{
m_window->m_docView = pViewToActivate;
m_window->m_docView->SetInPlaceSite(inPlaceSite);
}
else
{
wxAutoOleInterface<IOleDocument> oleDoc(IID_IOleDocument, m_window->m_oleObject);
if (! oleDoc.Ok())
return E_FAIL;
HRESULT hr = oleDoc->CreateView(inPlaceSite, NULL, 0, m_window->m_docView.GetRef());
if (hr != S_OK)
return E_FAIL;
m_window->m_docView->SetInPlaceSite(inPlaceSite);
};
m_window->m_docView->UIActivate(TRUE);
return S_OK;
};
static IMalloc *iMalloc = NULL;
IMalloc *wxOleInit::GetIMalloc()
{
assert(iMalloc);
return iMalloc;
};
wxOleInit::wxOleInit()
{
if (OleInitialize(NULL) == S_OK && iMalloc == NULL)
CoGetMalloc(1, &iMalloc);
else if (iMalloc)
iMalloc->AddRef();
};
wxOleInit::~wxOleInit()
{
if (iMalloc)
{
if (iMalloc->Release() == 0)
iMalloc = NULL;
};
OleUninitialize();
}
bool GetSysErrMessage(int err, wxString& s)
{
wxChar buf[256];
if (FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM, NULL,
err,0, buf, sizeof(buf), NULL) == 0)
return false;
buf[sizeof(buf) - 1] = 0;
s = buf;
return true;
};
wxString OLEHResultToString(HRESULT hr)
{
// try formatmessage
wxString err;
if (GetSysErrMessage(hr, err))
return err;
switch (hr)
{
case S_OK:
return wxEmptyString;
case CONNECT_E_CANNOTCONNECT:
return _T("Cannot connect to event interface (maybe not there ?) - see MSDN");
case DISP_E_MEMBERNOTFOUND:
return _T("The requested member does not exist, or the call to Invoke tried to set the value of a read-only property.");
case DISP_E_BADVARTYPE:
return _T("One of the parameters in rgvarg is not a valid variant type.");
case DISP_E_BADPARAMCOUNT:
return _T("The number of elements provided to DISPPARAMS is different from the number of parameters accepted by the method or property");
case DISP_E_EXCEPTION:
return _T("The application needs to raise an exception. In this case, the structure passed in pExcepInfo should be filled in.");
case DISP_E_TYPEMISMATCH:
return _T("One or more of the parameters could not be coerced. The index within rgvarg of the first parameter with the incorrect type is returned in the puArgErr parameter.");
case DISP_E_PARAMNOTOPTIONAL:
return _T("A required parameter was omitted.");
case DISP_E_PARAMNOTFOUND:
return _T("One of the parameter DISPIDs does not correspond to a parameter on the method. In this case, puArgErr should be set to the first parameter that contains the error.");
case OLECMDERR_E_UNKNOWNGROUP:
return _T("The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.");
case OLECMDERR_E_NOTSUPPORTED:
return _T("The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup.");
case OLECMDERR_E_DISABLED:
return _T("The command identified by nCmdID is currently disabled and cannot be executed.");
case OLECMDERR_E_NOHELP:
return _T("The caller has asked for help on the command identified by nCmdID, but no help is available.");
case OLECMDERR_E_CANCELED:
return _T("The user canceled the execution of the command.");
case E_INVALIDARG:
return _T("E_INVALIDARG");
case E_OUTOFMEMORY:
return _T("E_OUTOFMEMORY");
case E_NOINTERFACE:
return _T("E_NOINTERFACE");
case E_UNEXPECTED:
return _T("E_UNEXPECTED");
case STG_E_INVALIDFLAG:
return _T("STG_E_INVALIDFLAG");
case E_FAIL:
return _T("E_FAIL");
case E_NOTIMPL:
return _T("E_NOTIMPL");
default:
{
wxString buf;
buf.Printf(_T("Unknown - 0x%X"), hr);
return buf;
}
};
};
// borrowed from src/msw/ole/oleutils.cpp
wxString GetIIDName(REFIID riid)
{
// an association between symbolic name and numeric value of an IID
struct KNOWN_IID
{
const IID *pIid;
const wxChar *szName;
};
// construct the table containing all known interfaces
#define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
#define ADD_KNOWN_GUID(name) { &name, _T(#name) }
static const KNOWN_IID aKnownIids[] =
{
ADD_KNOWN_IID(ServiceProvider),
ADD_KNOWN_IID(AdviseSink),
ADD_KNOWN_IID(AdviseSink2),
ADD_KNOWN_IID(BindCtx),
ADD_KNOWN_IID(ClassFactory),
#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
ADD_KNOWN_IID(ContinueCallback),
ADD_KNOWN_IID(EnumOleDocumentViews),
ADD_KNOWN_IID(OleCommandTarget),
ADD_KNOWN_IID(OleDocument),
ADD_KNOWN_IID(OleDocumentSite),
ADD_KNOWN_IID(OleDocumentView),
ADD_KNOWN_IID(Print),
#endif
ADD_KNOWN_IID(DataAdviseHolder),
ADD_KNOWN_IID(DataObject),
ADD_KNOWN_IID(Debug),
ADD_KNOWN_IID(DebugStream),
ADD_KNOWN_IID(DfReserved1),
ADD_KNOWN_IID(DfReserved2),
ADD_KNOWN_IID(DfReserved3),
ADD_KNOWN_IID(Dispatch),
ADD_KNOWN_IID(DropSource),
ADD_KNOWN_IID(DropTarget),
ADD_KNOWN_IID(EnumCallback),
ADD_KNOWN_IID(EnumFORMATETC),
ADD_KNOWN_IID(EnumGeneric),
ADD_KNOWN_IID(EnumHolder),
ADD_KNOWN_IID(EnumMoniker),
ADD_KNOWN_IID(EnumOLEVERB),
ADD_KNOWN_IID(EnumSTATDATA),
ADD_KNOWN_IID(EnumSTATSTG),
ADD_KNOWN_IID(EnumString),
ADD_KNOWN_IID(EnumUnknown),
ADD_KNOWN_IID(EnumVARIANT),
ADD_KNOWN_IID(ExternalConnection),
ADD_KNOWN_IID(InternalMoniker),
ADD_KNOWN_IID(LockBytes),
ADD_KNOWN_IID(Malloc),
ADD_KNOWN_IID(Marshal),
ADD_KNOWN_IID(MessageFilter),
ADD_KNOWN_IID(Moniker),
ADD_KNOWN_IID(OleAdviseHolder),
ADD_KNOWN_IID(OleCache),
ADD_KNOWN_IID(OleCache2),
ADD_KNOWN_IID(OleCacheControl),
ADD_KNOWN_IID(OleClientSite),
ADD_KNOWN_IID(OleContainer),
ADD_KNOWN_IID(OleInPlaceActiveObject),
ADD_KNOWN_IID(OleInPlaceFrame),
ADD_KNOWN_IID(OleInPlaceObject),
ADD_KNOWN_IID(OleInPlaceSite),
ADD_KNOWN_IID(OleInPlaceUIWindow),
ADD_KNOWN_IID(OleItemContainer),
ADD_KNOWN_IID(OleLink),
ADD_KNOWN_IID(OleManager),
ADD_KNOWN_IID(OleObject),
ADD_KNOWN_IID(OlePresObj),
ADD_KNOWN_IID(OleWindow),
ADD_KNOWN_IID(PSFactory),
ADD_KNOWN_IID(ParseDisplayName),
ADD_KNOWN_IID(Persist),
ADD_KNOWN_IID(PersistFile),
ADD_KNOWN_IID(PersistStorage),
ADD_KNOWN_IID(PersistStream),
ADD_KNOWN_IID(ProxyManager),
ADD_KNOWN_IID(RootStorage),
ADD_KNOWN_IID(RpcChannel),
ADD_KNOWN_IID(RpcProxy),
ADD_KNOWN_IID(RpcStub),
ADD_KNOWN_IID(RunnableObject),
ADD_KNOWN_IID(RunningObjectTable),
ADD_KNOWN_IID(StdMarshalInfo),
ADD_KNOWN_IID(Storage),
ADD_KNOWN_IID(Stream),
ADD_KNOWN_IID(StubManager),
ADD_KNOWN_IID(Unknown),
ADD_KNOWN_IID(ViewObject),
ADD_KNOWN_IID(ViewObject2),
ADD_KNOWN_GUID(IID_IDispatch),
ADD_KNOWN_GUID(IID_IWebBrowser),
ADD_KNOWN_GUID(IID_IWebBrowserApp),
ADD_KNOWN_GUID(IID_IWebBrowser2),
ADD_KNOWN_GUID(IID_IWebBrowser),
ADD_KNOWN_GUID(DIID_DWebBrowserEvents2),
ADD_KNOWN_GUID(DIID_DWebBrowserEvents),
};
// don't clobber preprocessor name space
#undef ADD_KNOWN_IID
#undef ADD_KNOWN_GUID
// try to find the interface in the table
for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ )
{
if ( riid == *aKnownIids[ui].pIid )
{
return aKnownIids[ui].szName;
}
}
// unknown IID, just transform to string
LPOLESTR str = NULL;
StringFromIID(riid, &str);
if (str)
{
wxString s = str;
CoTaskMemFree(str);
return s;
}
else
return _T("StringFromIID() error");
}
|