summaryrefslogblamecommitdiffstats
path: root/private/mvdm/wow32/wuwind.c
blob: da66bfcc47cc594745add82d11a081fee29d9b69 (plain) (tree)
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
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                 
/*++
 *
 *  WOW v1.0
 *
 *  Copyright (c) 1991, Microsoft Corporation
 *
 *  WUWIND.C
 *  WOW32 16-bit User API support
 *
 *  History:
 *  Created 07-Mar-1991 by Jeff Parsons (jeffpar)
 *  12-FEB-92 mattfe changed WU32EnumTaskWindows to access 16 bit TDB
--*/

#include "precomp.h"
#pragma hdrstop

MODNAME(wuwind.c);

// From wumsg.c [SendDlgItemMesssage caching]
extern HWND hdlgSDIMCached ;

// From wuman.c [Identify thunked system class WndProcs]
extern WORD gUser16CS;

// dwExStyle is used by the CreateWindow and CreateWindowEx thunks
// so that they can use a common procedure (don't worry, the current
// task cannot be preempted during its use)

STATIC ULONG dwExStyle;

// Some apps (DASHboard from HP) try to get PROGMAN to save its settings
// in a funky way.  This variable is used to help detect these guys.
// Bobday 5/29/93
HWND hwndProgman = (HWND)0;

/*++
    void AdjustWindowRect(<lpRect>, <dwStyle>, <bMenu>)
    LPRECT <lpRect>;
    DWORD <dwStyle>;
    BOOL <bMenu>;

    The %AdjustWindowRect% function computes the required size of the window
    rectangle based on the desired client-rectangle size. The window rectangle
    can then be passed to the %CreateWindow% function to create a window whose
    client area is the desired size. A client rectangle is the smallest
    rectangle that completely encloses a client area. A window rectangle is the
    smallest rectangle that completely encloses the window. The dimensions of
    the resulting window rectangle depend on the window styles and on whether
    the window has a menu.

    <lpRect>
        Points to a %RECT% structure that contains the coordinates of the
        client rectangle.

    <dwStyle>
        Specifies the window styles of the window whose client rectangle
        is to be converted.

    <bMenu>
        Specifies whether the window has a menu.

    This function does not return a value.

    This function assumes a single menu row. If the menu bar wraps to two or
    more rows, the coordinates are incorrect.
--*/

ULONG FASTCALL WU32AdjustWindowRect(PVDMFRAME pFrame)
{
    RECT t1;
    register PADJUSTWINDOWRECT16 parg16;

    GETARGPTR(pFrame, sizeof(ADJUSTWINDOWRECT16), parg16);
    WOW32VERIFY(GETRECT16(parg16->f1, &t1));

    AdjustWindowRect(
    &t1,
    LONG32(parg16->f2),
    BOOL32(parg16->f3)
    );

    PUTRECT16(parg16->f1, &t1);
    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    void AdjustWindowRectEx(<lpRect>, <dwStyle>, <bMenu>, <dwExStyle>)
    LPRECT <lpRect>;
    DWORD <dwStyle>;
    BOOL <bMenu>;
    DWORD <dwExStyle>;

    The %AdjustWindowRectEx% function computes the required size of the
    rectangle of a window with extended style based on the desired
    client-rectangle size. The window rectangle can then be passed to the
    %CreateWindowEx% function to create a window whose client area is the
    desired size.

    A client rectangle is the smallest rectangle that completely encloses a
    client area. A window rectangle is the smallest rectangle that completely
    encloses the window. The dimensions of the resulting window rectangle
    depends on the window styles and on whether the window has a menu.

    <lpRect>
        Points to a %RECT% structure that contains the coordinates of the
        client rectangle.

    <dwStyle>
        Specifies the window styles of the window whose client rectangle
        is to be converted.

    <bMenu>
        Specifies whether the window has a menu.

    <dwExStyle>
        Specifies the extended style of the window being created.

    This function does not return a value.

    This function assumes a single menu row. If the menu bar wraps to two or
    more rows, the coordinates are incorrect.
--*/

ULONG FASTCALL WU32AdjustWindowRectEx(PVDMFRAME pFrame)
{
    RECT t1;
    register PADJUSTWINDOWRECTEX16 parg16;

    GETARGPTR(pFrame, sizeof(ADJUSTWINDOWRECTEX16), parg16);
    WOW32VERIFY(GETRECT16(parg16->f1, &t1));

    AdjustWindowRectEx(
    &t1,
    LONG32(parg16->f2),
    BOOL32(parg16->f3),
    DWORD32(parg16->f4)
    );

    PUTRECT16(parg16->f1, &t1);
    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    BOOL AnyPopup(VOID)

    The %AnyPopup% function indicates whether a pop-up window exists on the
    screen. It searches the entire Windows screen, not just the caller's client
    area. The %AnyPopup% function returns TRUE even if a pop-up window is
    completely covered by another window.

    This function has no parameters.

    The return value is TRUE if a pop-up window exists. Otherwise, it is
    FALSE.
--*/

ULONG FASTCALL WU32AnyPopup(PVDMFRAME pFrame)
{
    ULONG ul;

    UNREFERENCED_PARAMETER(pFrame);

    ul = GETBOOL16(AnyPopup());

    RETURN(ul);
}


/*++
    WORD ArrangeIconicWindows(<hwnd>)
    HWND <hwnd>;

    The %ArrangeIconicWindows% function arranges all the minimized (iconic)
    child windows of the window specified by the <hwnd> parameter.

    <hwnd>
        Identifies the window.

    The return value is the height of one row of icons, or zero if there were no
    icons.

    Applications that maintain their own iconic child windows call this function
    to arrange icons in a client window. This function also arranges icons on
    the desktop window, which covers the entire screen. The %GetDesktopWindow%
    function retrieves the window handle of the desktop window.

    To arrange iconic MDI child windows in an MDI client window, an application
    sends the WM_MDIICONARRANGE message to the MDI client window.
--*/

ULONG FASTCALL WU32ArrangeIconicWindows(PVDMFRAME pFrame)
{
    ULONG ul;
    register PARRANGEICONICWINDOWS16 parg16;

    GETARGPTR(pFrame, sizeof(ARRANGEICONICWINDOWS16), parg16);

    ul = GETWORD16(ArrangeIconicWindows(
    HWND32(parg16->hwnd)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    HANDLE BeginDeferWindowPos(<nNumWindows>)
    int <nNumWindows>;

    The %BeginDeferWindowPos% function allocates memory to contain a multiple
    window-position data structure and returns a handle to the structure. The
    %DeferWindowPos% function fills this structure with information about the
    target position for a window that is about to be moved. The
    %EndDeferWindowPos% function accepts this structure and instantaneously
    repositions the windows using the information stored in the structure.

    <nNumWindows>
        Specifies the initial number of windows for which position information
        is to be stored in the structure. The %DeferWindowPos% function
        increases the size of the structure if needed.

    The return value identifies the multiple window-position structure. The
    return value is NULL if system resources are not available to allocate the
    structure.
--*/

ULONG FASTCALL WU32BeginDeferWindowPos(PVDMFRAME pFrame)
{
    ULONG ul;
    register PBEGINDEFERWINDOWPOS16 parg16;

    GETARGPTR(pFrame, sizeof(BEGINDEFERWINDOWPOS16), parg16);

    ul = GETHDWP16(BeginDeferWindowPos(
    INT32(parg16->f1)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    BOOL BringWindowToTop(<hwnd>)
    HWND <hwnd>;

    The %BringWindowToTop% function brings a pop-up or child window to the top
    of a stack of overlapping windows. In addition, it activates pop-up and
    top-level windows. The %BringWindowToTop% function should be used to uncover
    any window that is partially or completely obscured by any overlapping
    windows.

    <hwnd>
        Identifies the pop-up or child window that is to be brought to the top.

    The return value is nonzero if the function is successful. Otherwise it is
    zero.  (updated for Win3.1 compatability -- this returned void for Win3.0)
--*/

ULONG FASTCALL WU32BringWindowToTop(PVDMFRAME pFrame)
{
    ULONG ul;
    register PBRINGWINDOWTOTOP16 parg16;

    GETARGPTR(pFrame, sizeof(BRINGWINDOWTOTOP16), parg16);

    ul = GETBOOL16(BringWindowToTop(HWND32(parg16->f1)));

    FREEARGPTR(parg16);

    RETURN(ul);
}


/*++
    HWND ChildWindowFromPoint(<hwndParent>, <Point>)
    HWND <hwndParent>;
    POINT <Point>;

    The %ChildWindowFromPoint% function determines which, if any, of the child
    windows belonging to the given parent window contains the specified point.

    <hwndParent>
        Identifies the parent window.

    <Point>
        Specifies the client coordinates of the point to be tested.

    The return value identifies the child window that contains the point. It is
    NULL if the given point lies outside the parent window. If the point is
    within the parent window but is not contained within any child window, the
    handle of the parent window is returned.
--*/

ULONG FASTCALL WU32ChildWindowFromPoint(PVDMFRAME pFrame)
{
    ULONG ul;
    POINT t2;
    register PCHILDWINDOWFROMPOINT16 parg16;

    GETARGPTR(pFrame, sizeof(CHILDWINDOWFROMPOINT16), parg16);
    COPYPOINT16(parg16->f2, t2);

    ul = GETHWND16(ChildWindowFromPoint(HWND32(parg16->f1), t2));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    void CloseWindow(<hwnd>)
    HWND <hwnd>;

    The %CloseWindow% function minimizes the specified window. If the window is
    an overlapped window, it is minimized by removing the client area and
    caption of the open window from the display screen and moving the window's
    icon into the icon area of the screen.

    <hwnd>
        Identifies the window to be minimized.

    This function does not return a value.

    This function has no effect if the <hwnd> parameter is a handle to a pop-up
    or child window.
--*/

ULONG FASTCALL WU32CloseWindow(PVDMFRAME pFrame)
{
    register PCLOSEWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(CLOSEWINDOW16), parg16);

    CloseWindow(
    HWND32(parg16->f1)
    );

    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    HWND CreateWindow(<lpClassName>, <lpWindowName>, <dwStyle>, <X>, <Y>,
        <nWidth>, <nHeight>, <hwndParent>, <hMenu>, <hInstance>, <lpParam>)
    LPSTR <lpClassName>;
    LPSTR <lpWindowName>;
    DWORD <dwStyle>;
    int <X>;
    int <Y>;
    int <nWidth>;
    int <nHeight>;
    HWND <hwndParent>;
    HMENU <hMenu>;
    HANDLE <hInstance>;
    LPSTR <lpParam>;

    The %CreateWindow% function creates an overlapped, pop-up, or child
    window. The %CreateWindow% function specifies the window class, window
    title, window style, and (optionally) initial position and size of the
    window. The %CreateWindow% function also specifies the window's parent (if
    any) and menu.

    For overlapped, pop-up, and child windows, the %CreateWindow% function sends
    WM_CREATE, WM_GETMINMAXINFO, and WM_NCCREATE messages to the window. The
    <lParam> parameter of the WM_CREATE message contains a pointer to a
    %CREATESTRUCT% structure. If WS_VISIBLE style is given, %CreateWindow%
    sends the window all the messages required to activate and show the window.

    If the window style specifies a title bar, the window title pointed to by
    the <lpWindowName> parameter is displayed in the title bar. When using
    %CreateWindow% to create controls such as buttons, check boxes, and text
    controls, the <lpWindowName> parameter specifies the text of the control.

    <lpClassName>
        Points to a null-terminated string that names the window class. The
        class name can be any name registered with the RegisterClass function or
        any of the predefined control-class names specified in Table T.2,
        "Control Classes."

    <lpWindowName>
        Points to a null-terminated string that represents the window name.

    <dwStyle>
        Specifies the style of window being created. It can be any
        combination of the styles given in Table *** <$R[C#]> ***.3, Window
        Styles the control styles given in Table 4.4, Control Styles, or a
        combination of styles created by using the bitwise OR operator. ,

    <X>
        Specifies the initial <x>-position of the window. For an
        overlapped or pop-up window, the <X> parameter is the initial
        <x>-coordinate of the window's upper-left corner (in screen
        coordinates). If this value is CW_USEDEFAULT, Windows selects the
        default position for the window's upper-left corner. For a child window,
        <X> is the <x>-coordinate of the upper-left corner of the window in the
        client area of its parent window.

    <Y>
        Specifies the initial <y>-position of the window. For an
        overlapped window, the <Y> parameter is the initial <y>-coordinate of
        the window's upper-left corner. For a pop-up window, <Y> is the
        <y>-coordinate (in screen coordinates) of the upper-left corner of the
        pop-up window. For list-box controls, <Y> is the <y>-coordinate of the
        upper-left corner of the control's client area. For a child window, <Y>
        is the <y>-coordinate of the upper-left corner of the child window. All
        of these coordinates are for the window, not the window's client area.

    <nWidth>
        Specifies the width (in device units) of the window. For
        overlapped windows, the <nWidth> parameter is either the window's width
        (in screen coordinates) or CW_USEDEFAULT. If <nWidth> is CW_USEDEFAULT,
        Windows selects a default width and height for the window (the default
        width extends from the initial <x>-position to the right edge of the
        screen, and the default height extends from the initial <y>-position to
        the top of the icon area).

    <nHeight>
        Specifies the height (in device units) of the window. For
        overlapped windows, the <nHeight> parameter is the window's height in
        screen coordinates. If the <nWidth> parameter is CW_USEDEFAULT, Windows
        ignores <nHeight>.

    <hwndParent>
        Identifies the parent or owner window of the window being
        created. A valid window handle must be supplied when creating a child
        window or an owned window. An owned window is an overlapped window that
        is destroyed when its owner window is destroyed, hidden when its owner
        is made iconic, and which is always displayed on top of its owner
        window. For pop-up windows, a handle can be supplied, but is not
        required. If the window does not have a parent or is not owned by
        another window, the <hwndParent> parameter must be set to NULL.

    <hMenu>
        Identifies a menu or a child-window identifier. The meaning
        depends on the window style. For overlapped or pop-up windows, the
        <hMenu> parameter identifies the menu to be used with the window. It can
        be NULL, if the class menu is to be used. For child windows, <hMenu>
        specifies the child-window identifier, an integer value that is used by
        a dialog-box control to notify its parent of events (such as the
        EN_HSCROLL message). The child-window identifier is determined by the
        application and should be unique for all child windows with the same
        parent window.

    <hInstance>
        Identifies the instance of the module to be associated with the
        window.

    <lpParam>
        Points to a value that is passed to the window through the
        %CREATESTRUCT% structure referenced by the <lParam> parameter of
        the WM_CREATE message. If an application is calling %CreateWindow% to
        create a multiple document interface (MDI) client window, <lpParam> must
        point to a %CLIENTCREATESTRUCT% structure.

    The return value identifies the new window. It is NULL if the window is not
    created.

    The %CreateWindow% function sends a WM_CREATE message to to the window
    procedure before it returns.

    For overlapped windows where the <X> parameter is CW_USEDEFAULT, the <Y>
    parameter can be one of the show-style parameters described with the
    %ShowWindow% function, or, for the first overlapped window to be created by
    the application, it can be the <nCmdShow> parameter passed to the WinMain
    function.

    BUTTON
        Designates a small rectangular child window that represents a button the
        user can turn on or off by clicking it. Button controls can be used
        alone or in groups, and can either be labeled or appear without text.
        Button controls typically change appearance when the user clicks them.

    COMBOBOX
        Designates a control consisting of a selection field similar to an edit
        control plus a list box. The list box may be displayed at all times or
        may be dropped down when the user selects a pop box next to the
        selection field.

        Depending on the style of the combo box, the user can or cannot edit the
        contents of the selection field. If the list box is visible, typing
        characters into the selection box will cause the first list box entry
        that matches the characters typed to be highlighted. Conversely,
        selecting an item in the list box displays the selected text in the
        selection field.

    EDIT
        Designates a rectangular child window in which the user can enter text
        from the keyboard. The user selects the control, and gives it the input
        focus by clicking it or moving to it by using the ^TAB^ key. The user
        can enter text when the control displays a flashing caret. The mouse can
        be used to move the cursor and select characters to be replaced, or to
        position the cursor for inserting characters. The ^BACKSPACE^ key can be
        used to delete characters.

        Edit controls use the variable-pitch system font and display ANSI
        characters. Applications compiled to run with previous versions of
        Windows display text with a fixed-pitch system font unless they have
        been marked by the Windows 3.0 %MARK% utility with the %MEMORY FONT%
        option. An application can also send the WM_SETFONT message to the edit
        control to change the default font.

        Edit controls expand tab characters into as many space characters as are
        required to move the cursor to the next tab stop. Tab stops are assumed
        to be at every eighth character position.

    LISTBOX
        Designates a list of character strings. This control is used whenever an
        application needs to present a list of names, such as filenames, that
        the user can view and select. The user can select a string by pointing
        to it and clicking. When a string is selected, it is highlighted and a
        notification message is passed to the parent window. A vertical or
        horizontal scroll bar can be used with a list-box control to scroll
        lists that are too long for the control window. The list box
        automatically hides or shows the scroll bar as needed.

    MDICLIENT
        Designates an MDI client window. The MDI client window receives messages
        which control the MDI application's child windows. The recommended style
        bits are WS_CLIPCHILDREN and WS_CHILD. To create a scrollable MDI client
        window which allows the user to scroll MDI child windows into view, an
        application can also use the WS_HSCROLL and WS_VSCROLL styles.

    SCROLLBAR
        Designates a rectangle that contains a thumb and has direction arrows at
        both ends. The scroll bar sends a notification message to its parent
        window whenever the user clicks the control. The parent window is
        responsible for updating the thumb position, if necessary. Scroll-bar
        controls have the same appearance and function as scroll bars used in
        ordinary windows. Unlike scroll bars, scroll-bar controls can be
        positioned anywhere in a window and used whenever needed to provide
        scrolling input for a window.

        The scroll-bar class also includes size-box controls. A size-box control
        is a small rectangle that the user can expand to change the size of the
        window.

    STATIC
        Designates a simple text field, box, or rectangle that can be used to
        label, box, or separate other controls. Static controls take no input
        and provide no output.

    DS_LOCALEDIT
        Specifies that edit controls in the dialog box will use memory in the
        application's data segment. By default, all edit controls in dialog
        boxes use memory outside the application's data segment. This feature
        may be suppressed by adding the DS_LOCALEDIT flag to the STYLE command
        for the dialog box. If this flag is not used, EM_GETHANDLE and
        EM_SETHANDLE messages must not be used since the storage for the control
        is not in the application's data segment. This feature does not affect
        edit controls created outside of dialog boxes.

    DS_MODALFRAME
        Creates a dialog box with a modal dialog-box frame that can be combined
        with a title bar and System menu by specifying the WS_CAPTION and
        WS_SYSMENU styles.

    DS_NOIDLEMSG
        Suppresses WM_ENTERIDLE messages that Windows would otherwise send to
        the owner of the dialog box while the dialog box is displayed.

    DS_SYSMODAL
        Creates a system-modal dialog box.

    WS_BORDER
        Creates a window that has a border.

    WS_CAPTION
        Creates a window that has a title bar (implies the WS_BORDER style).
        This style cannot be used with the WS_DLGFRAME style.

    WS_CHILD
        Creates a child window. Cannot be used with the WS_POPUP style.

    WS_CHILDWINDOW
        Creates a child window that has the WS_CHILD style.

    WS_CLIPCHILDREN
        Excludes the area occupied by child windows when drawing within the
        parent window. Used when creating the parent window.

    WS_CLIPSIBLINGS
        Clips child windows relative to each other; that is, when a particular
        child window receives a paint message, the WS_CLIPSIBLINGS style clips
        all other overlapped child windows out of the region of the child window
        to be updated. (If WS_CLIPSIBLINGS is not given and child windows
        overlap, it is possible, when drawing within the client area of a child
        window, to draw within the client area of a neighboring child window.)
        For use with the WS_CHILD style only.

    WS_DISABLED
        Creates a window that is initially disabled.

    WS_DLGFRAME
        Creates a window with a double border but no title.

    WS_GROUP
        Specifies the first control of a group of controls in which the user can
        move from one control to the next by using the ^DIRECTION^ keys. All
        controls defined with the WS_GROUP style after the first control belong
        to the same group. The next control with the WS_GROUP style ends the
        style group and starts the next group (that is, one group ends where the
        next begins). Only dialog boxes use this style.

    WS_HSCROLL
        Creates a window that has a horizontal scroll bar.

    WS_ICONIC
        Creates a window that is initially iconic. For use with the
        WS_OVERLAPPED style only.

    WS_MAXIMIZE
        Creates a window of maximum size.

    WS_MAXIMIZEBOX
        Creates a window that has a maximize box.

    WS_MINIMIZE
        Creates a window of minimum size.

    WS_MINIMIZEBOX
        Creates a window that has a minimize box.

    WS_OVERLAPPED
        Creates an overlapped window. An overlapped window has a caption and a
        border.

    WS_OVERLAPPEDWINDOW
        Creates an overlapped window having the WS_OVERLAPPED, WS_CAPTION,
        WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.

    WS_POPUP
        Creates a pop-up window. Cannot be used with the WS_CHILD style.

    WS_POPUPWINDOW
        Creates a pop-up window that has the WS_BORDER, WS_POPUP, and WS_SYSMENU
        styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW
        style to make the system menu visible.

    WS_SYSMENU
        Creates a window that has a System-menu box in its title bar. Used only
        for windows with title bars.

    WS_TABSTOP
        Specifies one of any number of controls through which the user can move
        by using the ^TAB^ key. The ^TAB^ key moves the user to the next control
        specified by the WS_TABSTOP style. Only dialog boxes use this style.

    WS_THICKFRAME
        Creates a window with a thick frame that can be used to size the
        window.

    WS_VISIBLE
        Creates a window that is initially visible. This applies to overlapped
        and pop-up windows. For overlapped windows, the <Y> parameter is used as
        a %ShowWindow% function parameter.

    WS_VSCROLL
        Creates a window that has a vertical scroll bar.
--*/

ULONG FASTCALL WU32CreateWindow(PVDMFRAME pFrame)
{
    dwExStyle = 0;
    return W32CreateWindow(pFrame);
}


/*++
    HWND CreateWindowEx(<dwExStyle>, <lpszClass>, <lpszName>,
        <dwStyle>, <x>, <y>, <cx>, <cy>, <hwndParent>, <hMenu>,
        <hInstance>, <lpCreateParams>)
    DWORD <dwExStyle>;
    LPSTR <lpszClass>;
    LPSTR <lpszName>;
    DWORD <dwStyle>;
    int <x>;
    int <y>;
    int <cx>;
    int <cy>;
    HWND <hwndParent>;
    HMENU <hMenu>;
    HANDLE <hInstance>;
    LPSTR <lpCreateParams>;

    The %CreateWindowEx% function creates an overlapped, pop-up, or child window
    with an extended style specified in the <dwExStyle> parameter. Otherwise,
    this function is identical to the %CreateWindow% function. See the
    description of the %CreateWindow% function for more information on creating
    a window and for a full descriptions of the other parameters of
    %CreateWindowEx%.

    <dwExStyle>
        Specifies the extended style of the window being created. It may be one
        of the following values:

    WS_EX_DLGMODALFRAME
        Designates a window with a double border that may optionally be created
        with a title bar by specifying the WS_CAPTION style flag in the
        <dwStyle> parameter.

    WS_EX_NOPARENTNOTIFY
        Specifies that a child window created with this style will not send the
        WM_PARENTNOTIFY message to its parent window when the child window is
        created or destroyed.

    WS_EX_TOPMOST
        ???

    WS_EX_ACCEPTFILES
        ???

    <lpszClass>
        Points to a null-terminated string containing the name of the window
        class.

    <lpszName>
        Points to a null-terminated string containing the window name.

    <dwStyle>
        Specifies the style of window being created.

    <x>
        Specifies the initial left side position of the window.

    <y>
        Specifies the initial top position of the window.

    <cx>
        Specifies the width (in device units) of the window.

    <cy>
        Specifies the height (in device units) of the window.

    <hwndParent>
        Identifies the parent or owner window of the window being
        created.

    <hMenu>
        Identifies a menu or a child-window identifier. The meaning
        depends on the window style.

    <hInstance>
        Identifies the instance of the module to be associated with the
        window.

    <lpCreateParams>
        Contains any application-specific creation parameters. The window being
        created may access this data when the %CREATESTRUCT% structure is passed
        to the window via the WM_NCCREATE and WM_CREATE messages.

    The return value identifies the new window. It is NULL if the window is not
    created.

    The %CreateWindowEx% function sends the following messages to the window
    being created:

         WM_NCCREATE
         WM_NCCALCSIZE
         WM_CREATE
         WM_OTHERWINDOWCREATED
--*/

ULONG FASTCALL WU32CreateWindowEx(PVDMFRAME pFrame)
{
    register PCREATEWINDOWEX16 parg16;

    GETARGPTR(pFrame, sizeof(CREATEWINDOWEX16), parg16);
    dwExStyle = DWORD32(parg16->f1);
    FREEARGPTR(parg16);
    RETURN(W32CreateWindow(pFrame));
}

ULONG FASTCALL W32CreateWindow(PVDMFRAME pFrame)
{
    PSZ     psz1;
    PSZ     pszClass;
    PSZ     psz2;
    HWND    hwnd32;
    HMENU   hmenu32;
    PWC     pwc;
    WW      ww;
    register PCREATEWINDOW16 parg16;
    CLIENTCREATESTRUCT  clientcreatestruct;
    LPVOID  vpparam;
    CHAR    szAtomName[WOWCLASS_ATOM_NAME];
    DWORD   dwStyle;
    INT     iClass;

    GETARGPTR(pFrame, sizeof(CREATEWINDOW16), parg16);
    GETPSZIDPTR(parg16->vpszClass, psz1);
    GETPSZPTR(parg16->vpszWindow, psz2);

    if ( HIWORD(psz1) == 0 ) {
        pszClass = szAtomName;
        GetAtomName( (ATOM)psz1, pszClass, WOWCLASS_ATOM_NAME );
    } else {
        pszClass = psz1;
    }

    //
    // For child windows, the hMenu parameter is just a child window ID
    //
    if (DWORD32(parg16->dwStyle) & WS_CHILD) {
        hmenu32 = (HMENU)parg16->hMenu;

        // Invalidate SendDlgItemMessage cache
        hdlgSDIMCached = NULL ;
    }
    else
        hmenu32 = (HMENU32(parg16->hMenu));

    if (_stricmp(pszClass, "MDIClient")) {
        vpparam = (LPVOID)DWORD32(parg16->vpParam);
    } else {
        GETCLIENTCREATESTRUCT16(parg16->vpParam, &clientcreatestruct );
        vpparam = &clientcreatestruct;
    }

    dwStyle = DWORD32(parg16->dwStyle);

    //
    // Fill in the WOW WORDs (WW) structure. This contains all the
    // handle aliasing information in it.
    //
    pwc = FindClass16(pszClass, parg16->hInstance);

    if (pwc) {

        if (iClass = GetStdClassNumber(pszClass)) {
            ww.iClass       = iClass;
            ww.vpfnWndProc  = 0;
        }
        else {
            // Look to see if the 16:16 proc is a thunk for a 32-bit proc.
            // QUICKEN: registers wow class with 16bit listboxwndproc
            //          We treat this window as a WOWCLASS and therfore all
            //          LB_* messages remain unthunked (they remained > WM_USER).
            //
            //          The following code checks for such a wndproc and
            //          sets the system class appropriately.

            if (HIWORD(pwc->vpfnWndProc) == gUser16CS) {
                LOGDEBUG(LOG_WARNING,("Creating Private Class window with System WndProc\n"));
                IsThunkWindowProc((DWORD)pwc->vpfnWndProc, &iClass);
                ww.iClass       = iClass;
            }
            else {
                ww.iClass       = WOWCLASS_WIN16;
            }

            ww.vpfnWndProc  = pwc->vpfnWndProc;
        }
        ww.vpfnDlgProc  = 0;
        ww.flState      = WWSTATE_ICLASSISSET;



        hwnd32 = (pfnOut.pfnCsCreateWindowEx)(
                   dwExStyle,
                   pszClass,
                   psz2,
                   dwStyle,
                   INT32DEFAULT(parg16->x),
                   INT32DEFAULT(parg16->y),
                   INT32DEFAULT(parg16->cx),
                   INT32DEFAULT(parg16->cy),
                   HWND32(parg16->hwndParent),
                   hmenu32,
                   HMODINST32(parg16->hInstance),
                   vpparam,
                   CW_FLAGS_ANSI,
                   (LPDWORD)&ww);

    } else {        // The class doesn't exist.

        hwnd32 = NULL;

    }

#ifdef DEBUG
    if (hwnd32) {
        CHAR    szClassName[80];

        LOGDEBUG(LOG_WARNING,("  Window %04x created on class = %s\n", GETHWND16(hwnd32),
                (GetClassName(hwnd32, szClassName, sizeof(szClassName)) ? szClassName : "Unknown")));
    } else {
        LOGDEBUG(LOG_WARNING,("  CreateWindow failed, class = %s\n", pszClass));
    }
#endif

    FREEPSZPTR(psz1);
    FREEPSZPTR(psz2);
    FREEARGPTR(parg16);
    RETURN((ULONG) GETHWND16(hwnd32));
}


/*++
    HANDLE BeginDeferWindowPos(<nNumWindows>)
    int <nNumWindows>;

    The %BeginDeferWindowPos% function allocates memory to contain a multiple
    window-position data structure and returns a handle to the structure. The
    %DeferWindowPos% function fills this structure with information about the
    target position for a window that is about to be moved. The
    %EndDeferWindowPos% function accepts this structure and instantaneously
    repositions the windows using the information stored in the structure.

    <nNumWindows>
        Specifies the initial number of windows for which position information
        is to be stored in the structure. The %DeferWindowPos% function
        increases the size of the structure if needed.

    The return value identifies the multiple window-position structure. The
    return value is NULL if system resources are not available to allocate the
    structure.
--*/

ULONG FASTCALL WU32DeferWindowPos(PVDMFRAME pFrame)
{
    ULONG ul;
    HDWP  h32;
    register PDEFERWINDOWPOS16 parg16;

    GETARGPTR(pFrame, sizeof(DEFERWINDOWPOS16), parg16);

    h32 = HDWP32(parg16->f1);

    ul = (ULONG) DeferWindowPos(
    h32,
    HWND32(parg16->f2),
    HWNDIA32(parg16->f3),
    INT32(parg16->f4),
    INT32(parg16->f5),
    INT32(parg16->f6),
    INT32(parg16->f7),
    WORD32(parg16->f8) & SWP_VALID
    );

    if (ul != (ULONG) h32) {
        ul = GETHDWP16(ul);
        LOGDEBUG (12, ("WOW::DeferWindowsPos: ul = %08x, h32 = %08x\n", ul, h32));
    }
    else {
        ul = parg16->f1;
        LOGDEBUG (12, ("WOW::DeferWindowsPos: ul = %08x, parg = %08x\n", ul, parg16->f1));
    }


    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    BOOL DestroyWindow(<hwnd>)
    HWND <hwnd>;

    The %DestroyWindow% function destroys the specified window. The
    %DestroyWindow% function sends appropriate messages to the window to
    deactivate it and remove the input focus. It also destroys the window's
    menu, flushes the application queue, destroys outstanding timers, removes
    clipboard ownership, and breaks the clipboard-viewer chain, if the window is
    at the top of the viewer chain. It sends WM_DESTROY and WM_NCDESTROY
    messages to the window.

    If the given window is the parent of any windows, these child windows are
    automatically destroyed when the parent window is destroyed. The
    %DestroyWindow% function destroys child windows first, and then the window
    itself.

    The %DestroyWindow% function also destroys modeless dialog boxes created by
    the %CreateDialog% function.

    <hwnd>
        Identifies the window to be destroyed.

    The return value specifies whether or not the specified window is destroyed.
    It is TRUE if the window is destroyed. Otherwise, it is FALSE.

    If the window being destroyed is a top-level window, a
    WM_OTHERWINDOWDESTROYED message will be broadcast to all top-level windows.

    If the window being destroyed is a child window and does not have the
    WS_NOPARENTNOTIFY style set, then a WM_PARENTNOTIFY message is sent to the
    parent.
--*/

ULONG FASTCALL WU32DestroyWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    register PDESTROYWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(DESTROYWINDOW16), parg16);

    ul = GETBOOL16(DestroyWindow(HWND32(parg16->f1)));

    // Invalidate SendDlgItemMessage cache
    hdlgSDIMCached = NULL ;

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    BOOL EnableWindow(<hwnd>, <bEnable>)
    HWND <hwnd>;
    BOOL <bEnable>;

    The %EnableWindow% function enables or disables mouse and keyboard input to
    the specified window or control. When input is disabled, input such as mouse
    clicks and key presses are ignored by the window. When input is enabled, all
    input is processed.

    The %EnableWindow% function enables mouse and keyboard input to a window if
    the <bEnable> parameter is TRUE, and disables it if <bEnable> is FALSE.

    <hwnd>
        Identifies the window to be enabled or disabled.

    <bEnable>
        Specifies whether the given window is to be enabled or disabled.

    The return value indicates the state of the window before the %EnableWindow%
    function was called. A return value of TRUE indicates mouse and keyboard was
    originally disabled. A return value of FALSE indicates it was enabled. A
    return value of FALSE is also returned if the window handle specified by
    the <hwnd> parameter is invalid.

    A window must be enabled before it can be activated. For example, if an
    application is displaying a modeless dialog box and has disabled its main
    window, the main window must be enabled before the dialog box is destroyed.
    Otherwise, another window will get the input focus and be activated. If a
    child window is disabled, it is ignored when Windows tries to determine
    which window should get mouse messages.

    Initially, all windows are enabled by default. %EnableWindow% must be used
    to disable a window explicitly.
--*/

ULONG FASTCALL WU32EnableWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    register PENABLEWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(ENABLEWINDOW16), parg16);

    ul = GETBOOL16(EnableWindow(
    HWND32(parg16->f1),
    BOOL32(parg16->f2)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    void EndDeferWindowPos(<hWinPosInfo>)
    HANDLE <hWinPosInfo>;

    The %EndDeferWindowPos% function simultaneously updates the position and
    size of one or more windows in a single screen-refresh cycle. The
    <hWinPosInfo> parameter identifies a multiple window-position structure that
    contains the update information for the windows. The %DeferWindowPos%
    function stores the update information in the structure; the
    %BeginDeferWindowPos% function creates the initial structure used by these
    functions.

    <hWinPosInfo>
        Identifies a multiple window-position structure that contains size
        and position information for one or more windows. This structure is
        returned by the %BeginDeferWindowPos% function or the most recent call to
        the %DeferWindowPos% function.

    This function does not return a value.
--*/

ULONG FASTCALL WU32EndDeferWindowPos(PVDMFRAME pFrame)
{
    ULONG ul;
    register PENDDEFERWINDOWPOS16 parg16;

    GETARGPTR(pFrame, sizeof(ENDDEFERWINDOWPOS16), parg16);

    ul = (ULONG)EndDeferWindowPos(HDWP32(parg16->f1));
    FREEHDWP16(parg16->f1);

    FREEARGPTR(parg16);
    RETURN(ul);
}


BOOL W32EnumWindowFunc(HWND hwnd, DWORD lParam)
{
    BOOL fReturn;
    PARM16 Parm16;

    WOW32ASSERT(lParam);

    Parm16.EnumWndProc.hwnd = GETHWND16(hwnd);
    STOREDWORD(Parm16.EnumWndProc.lParam, ((PWNDDATA)lParam)->dwUserWndParam);
    CallBack16(RET_ENUMWINDOWPROC, &Parm16, ((PWNDDATA)lParam)->vpfnEnumWndProc, (PVPVOID)&fReturn);

    return (BOOL16)fReturn;
}


/*++
    BOOL EnumChildWindows(<hwndParent>, <lpEnumFunc>, <lParam>)
    HWND <hwndParent>;
    FARPROC <lpEnumFunc>;
    DWORD <lParam>;

    The %EnumChildWindows% function enumerates the child windows that belong to
    the specified parent window by passing the handle of each child window, in
    turn, to the application-supplied callback function pointed to by the
    <lpEnumFunc> parameter.

    The %EnumChildWindows% function continues to enumerate windows until the
    called function returns zero or until the last child window has been
    enumerated.

    <hwndParent>
        Identifies the parent window whose child windows are to be enumerated.

    <lpEnumFunc>
        Is the procedure-instance address of the callback function.

    <lParam>
        Specifies the value to be passed to the callback function for
        the application's use.

    The return value is TRUE if all child windows have been enumerated.
    Otherwise, it is FALSE.

    This function does not enumerate pop-up windows that belong to the
    <hwndParent> parameter.

    The address passed as the <lpEnumFunc> parameter must be created by using
    the %MakeProcInstance% function.

    The callback function must use the Pascal calling convention and must be
    declared %FAR%.

    Callback Function:

    BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
    HWND <hwnd>;
    DWORD <lParam>;

    <EnumFunc> is a placeholder for the application-supplied function name. The
    actual name must be exported by including it in an %EXPORTS% statement in
    the application's module-definition file.

    <hwnd>
        Identifies the window handle.

    <lParam>
        Specifies the long parameter argument of the %EnumChildWindows%
        function.

    The callback function should return TRUE to continue enumeration; it should
    return FALSE to stop enumeration.
--*/

ULONG FASTCALL WU32EnumChildWindows(PVDMFRAME pFrame)
{
    ULONG    ul;
    WNDDATA  WndData;
    register PENUMCHILDWINDOWS16 parg16;

    GETARGPTR(pFrame, sizeof(ENUMCHILDWINDOWS16), parg16);

    WndData.vpfnEnumWndProc = DWORD32(parg16->f2);
    WndData.dwUserWndParam  = DWORD32(parg16->f3);

    ul = GETBOOL16(EnumChildWindows(HWND32(parg16->f1),
                                    (WNDENUMPROC)W32EnumWindowFunc,
                                    (LONG)&WndData));
    FREEARGPTR(parg16);
    RETURN(ul);
}



/*++
    BOOL EnumTaskWindows(<hTask>, <lpEnumFunc>, <lParam>)
    HANDLE <hTask>;
    FARPROC <lpEnumFunc>;
    DWORD <lParam>;

    The %EnumTaskWindows% function enumerates all windows associated with the
    <hTask> parameter, which is returned by the %GetCurrentTask% function. (A
    task is any program that executes as an independent unit. All applications
    are executed as tasks and each instance of an application is a task.) The
    enumeration terminates when the callback function, pointed to by
    <lpEnumFunc>, returns FALSE.

    <hTask>
        Identifies the specified task. The GetCurrentTask function returns this
        handle.

    <lpEnumFunc>
        Specifies the procedure-instance address of the window's callback
        function.

    <lParam>
        Specifies the 32-bit value that contains additional parameters
        that are sent to the callback function pointed to by <lpEnumFunc>.

    The return value specifies the outcome of the function. It is TRUE if all
    the windows associated with a particular task are enumerated. Otherwise, it
    is FALSE.

    The callback function must use the Pascal calling convention and must be
    declared %FAR%. The callback function must have the following form:

    Callback Function:

    BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
    HWND <hwnd>;
    DWORD <lParam>;

    <EnumFunc> is a placeholder for the application-supplied function name. The
    actual name must be exported by including it in an %EXPORTS% statement in
    the application's module-definition file.

    <hwnd>
        Identifies a window associated with the current task.

    <lParam>
        Specifies the same argument that was passed to the %EnumTaskWindows%
        function.

    The callback function can carry out any desired task. It must return TRUE to
    continue enumeration, or FALSE to stop it.
--*/

ULONG FASTCALL WU32EnumTaskWindows(PVDMFRAME pFrame)
{
    ULONG    ul;
    WNDDATA  WndData;
    register PENUMTASKWINDOWS16 parg16;

    GETARGPTR(pFrame, sizeof(ENUMTASKWINDOWS16), parg16);

    WndData.vpfnEnumWndProc = DWORD32(parg16->f2);
    WndData.dwUserWndParam  = DWORD32(parg16->f3);

    ul = GETBOOL16(EnumThreadWindows(THREADID32(parg16->f1),
                                     (WNDENUMPROC)W32EnumWindowFunc,
                                     (LONG)&WndData));
    FREEARGPTR(parg16);
    RETURN(ul);
}



/*++
    BOOL EnumWindows(<lpEnumFunc>, <lParam>)
    FARPROC <lpEnumFunc>;
    DWORD <lParam>;

    The %EnumWindows% function enumerates all parent windows on the screen by
    passing the handle of each window, in turn, to the callback function pointed
    to by the <lpEnumFunc> parameter. Child windows are not enumerated.

    The %EnumWindows% function continues to enumerate windows until the called
    function returns zero or until the last window has been enumerated.

    <lpEnumFunc>
        Is the procedure-instance address of the callback function. See the
        following "Comments" section for details.

    <lParam>
        Specifies the value to be passed to the callback function for
        the application's use.

    The return value is TRUE if all windows have been enumerated. Otherwise, it
    is FALSE.

    The address passed as the <lpEnumFunc> parameter must be created by using
    the %MakeProcInstance% function.

    The callback function must use the Pascal calling convention and must be
    declared %FAR%. The callback function must have the following form:

    Callback Function:

    BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
    HWND <hwnd>;
    DWORD <lParam>;

    <EnumFunc> is a placeholder for the application-supplied function name. The
    actual name must be exported by including it in an %EXPORTS% statement in
    the application's module-definition file.

    <hwnd>
        Identifies the window handle.

    <lParam>
        Specifies the 32-bit argument of the %EnumWindows% function.

    The function must return TRUE to continue enumeration, or FALSE to stop it.
--*/

ULONG FASTCALL WU32EnumWindows(PVDMFRAME pFrame)
{
    ULONG    ul;
    WNDDATA  WndData;
    register PENUMWINDOWS16 parg16;

    GETARGPTR(pFrame, sizeof(ENUMWINDOWS16), parg16);

    WndData.vpfnEnumWndProc = DWORD32(parg16->f1);
    WndData.dwUserWndParam  = DWORD32(parg16->f2);

    ul = GETBOOL16(EnumWindows((WNDENUMPROC)W32EnumWindowFunc, (LONG)&WndData));

    FREEARGPTR(parg16);
    RETURN(ul);
}




/*++
    HWND FindWindow(<lpClassName>, <lpWindowName>)
    LPSTR <lpClassName>;
    LPSTR <lpWindowName>;

    The %FindWindow% function returns the handle of the window whose class is
    given by the <lpClassName> parameter and whose window name, or caption, is
    given by the <lpWindowName> parameter. This function does not search child
    windows.

    <lpClassName>
        Points to a null-terminated string that specifies the window's class
        name. If lpClassName is NULL, all class names match.

    <lpWindowName>
        Points to a null-terminated string that specifies the window name (the
        window's text caption). If <lpWindowName> is NULL, all window names
        match.

    The return value identifies the window that has the specified class name and
    window name. It is NULL if no such window is found.
--*/

ULONG FASTCALL WU32FindWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz1;
    PSZ psz2;
    PSZ pszClass;
    register PFINDWINDOW16 parg16;
    CHAR    szAtomName[WOWCLASS_ATOM_NAME];

    GETARGPTR(pFrame, sizeof(FINDWINDOW16), parg16);
    GETPSZIDPTR(parg16->f1, psz1);
    GETOPTPTR(parg16->f2, 0, psz2);

    if ( psz1 && HIWORD(psz1) == 0 ) {
        pszClass = szAtomName;
        GetAtomName( (ATOM)psz1, pszClass, WOWCLASS_ATOM_NAME );
    } else {
        pszClass = psz1;
    }


    // Some apps during their installation try to find Program Manager's
    // window handle by doing FindWindow. Once they get the window handle
    // then they do DDE with program manager to create app group. An app
    // can call FindWindow in one of the three ways.
    //
    //   FindWindow ("progman", NULL)
    //   FindWindow (NULL, "program manager")
    //   FindWindow ("progman", "program manager")
    //
    // The case 2 and 3 of the above will fail on NT because the title of
    // the program manager window under NT is "Program Manager - xxx\yyy".
    // Where xxx is the domain name and yyy is the user name.
    //
    // To provide the Win 3.1 compatibility to the 16 bit apps, we check for
    // the above cases. For these cases we call FindWindow ("progman", NULL)
    // to get the window handle of the program manager's top level window.
    //
    // AmiPro calls FindWindow as case two of the above to find the window
    // handle of the program manager to do DDE with.
    // ChandanC, 5/18/93
    //

    // Some apps send WM_SYSCOMMAND - SC_CLOSE messages to program manager
    // with the shift key down to get it to save its settings.  They do
    // this by 1st finding the program manager window...

    if ((pszClass && !_stricmp (pszClass, "progman")) ||
        (psz2 && !_stricmp (psz2, "program manager"))) {

        ul = GETHWND16(FindWindow("progman", NULL));

        // Some apps send WM_SYSCOMMAND - SC_CLOSE messages to program manager
        // with the shift key down to get it to save its settings.      They do
        // this by 1st finding the program manager window...
        // So, save this window handle for later.
        hwndProgman = (HWND)ul;
    }
    else {
        ul = GETHWND16(FindWindow(pszClass, psz2));
    }

    FREEPSZPTR(psz1);
    FREEPSZPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    BOOL FlashWindow(<hwnd>, <bInvert>)
    HWND <hwnd>;
    BOOL <bInvert>;

    The %FlashWindow% function flashes the given window once. Flashing a window
    means changing the appearance of its caption bar as if the window were
    changing from inactive to active status, or vice versa. (An inactive caption
    bar changes to an active caption bar; an active caption bar changes to an
    inactive caption bar.)

    Typically, a window is flashed to inform the user that the window requires
    attention, but that it does not currently have the input focus.

    <hwnd>
        Identifies the window to be flashed. The window can be either open or
        iconic.

    <bInvert>
        Specifies whether the window is to be flashed or returned to its
        original state. The window is flashed from one state to the other if the
        <bInvert> parameter is TRUE. If the <bInvert> parameter is FALSE, the
        window is returned to its original state (either active or inactive).

    The return value specifies the window's state before call to the
    %FlashWindow% function. It is TRUE if the window was active before the
    call. Otherwise, it is FALSE.

    The %FlashWindow% function flashes the window only once; for successive
    flashing, the application should create a system timer.

    The <bInvert> parameter should be FALSE only when the window is getting the
    input focus and will no longer be flashing; it should be TRUE on
    successive calls while waiting to get the input focus.

    This function always returns TRUE for iconic windows. If the window is
    iconic, %FlashWindow% will simply flash the icon; <bInvert> is ignored for
    iconic windows.
--*/

ULONG FASTCALL WU32FlashWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    register PFLASHWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(FLASHWINDOW16), parg16);

    ul = GETBOOL16(FlashWindow(
    HWND32(parg16->f1),
    BOOL32(parg16->f2)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    HWND GetActiveWindow(VOID)

    The %GetActiveWindow% function retrieves the window handle of the active
    window. The active window is either the window that has the current input
    focus, or the window explicitly made active by the %SetActiveWindow%
    function.

    This function has no parameters.

    The return value identifies the active window.
--*/

ULONG FASTCALL WU32GetActiveWindow(PVDMFRAME pFrame)
{
    ULONG ul;

    UNREFERENCED_PARAMETER(pFrame);

    ul = (ULONG)GetActiveWindow();

    // GetActiveWindow returned NULL. So try GetForegroundWindow.
    // Some apps like Toolbook donot paint if GetActiveWindow returns NULL.
    //
    // Alternatively we can return the wowexec's window handle.. basically
    // something NON-NULL
    //
    // NOTE: Win31 and Win32 GetActiveWindow differ semantically and hence
    //       the need for fooling with this API.
    //
    //                                              - Nanduri Ramakrishna
    //
    // We need to do something different now, since JimA recently changed
    // GetForegroundWindow() so that it can return NULL if the caller doesn't
    // have access to the foreground window.
    //
    //                                              - Dave Hart
    //
    // When GetForegroundWindow() returns null, now we return wowexec's
    // window handle. This theoretically could have some strange effects
    // since it is a hidden window. It might be better to return, say,
    // the desktop window. However, for reasons currently unknown, 
    // this screws a shutdown scenario with Micrografix Designer (it
    // gpfaults).
    //                                              - Neil Sandlin

    if (ul == (ULONG)NULL) {
        ul = (ULONG)GetForegroundWindow();
    }

    if (ul == (ULONG)NULL) {
        ul = (ULONG)ghwndShell;
    }

    ul = GETHWND16(ul);

    WOW32ASSERT(ul);
    RETURN(ul);
}


/*++
    HDC GetWindowDC(<hwnd>)
    HWND <hwnd>;

    The %GetWindowDC% function retrieves the display context for the entire
    window, including caption bar, menus, and scroll bars. A window display
    context permits painting anywhere in a window, including the caption bar,
    menus, and scroll bars, since the origin of the context is the upper-left
    corner of the window instead of the client area.

    %GetWindowDC% assigns default attributes to the display context each time it
    retrieves the context. Previous attributes are lost.

    <hwnd>
        Identifies the window whose display context is to be retrieved.

    The return value identifies the display context for the given window if the
    function is successful. Otherwise, it is NULL.

    The %GetWindowDC% function is intended to be used for special painting
    effects within a window's nonclient area. Painting in nonclient areas of any
    window is not recommended.

    The %GetSystemMetrics% function can be used to retrieve the dimensions of
    various parts of the nonclient area, such as the caption bar, menu, and
    scroll bars.

    After painting is complete, the %ReleaseDC% function must be called to
    release the display context. Failure to release a window display context
    will have serious effects on painting requested by applications.
--*/

ULONG FASTCALL WU32GetWindowDC(PVDMFRAME pFrame)
{
    ULONG ul;
    register PGETWINDOWDC16 parg16;
    HAND16 htask16 = pFrame->wTDB;

    GETARGPTR(pFrame, sizeof(GETWINDOWDC16), parg16);

    ReleaseCachedDCs(htask16, parg16->f1, 0, 0, SRCHDC_TASK16_HWND16);

    ul = GETHDC16(GetWindowDC(
    HWND32(parg16->f1)
    ));

    if (ul)
        StoreDC(htask16, parg16->f1, (HAND16)ul);

    FREEARGPTR(parg16);
    RETURN(ul);
}

/*++
    LONG GetWindowLong(<hwnd>, <nIndex>)
    HWND <hwnd>;
    int <nIndex>;

    The %GetWindowLong% function retrieves information about the window
    identified by the <hwnd> parameter.

    <hwnd>
        Identifies the window.

    <nIndex>
        Specifies the byte offset of the value to be retrieved. It can
        also be one of the following values:

    GWL_EXSTYLE
        Extended window style.

    GWL_STYLE
        Window style

    GWL_WNDPROC
        Long pointer to the window function

    The return value specifies information about the given window.

    To access any extra four-byte values allocated when the window-class
    structure was created, use a positive byte offset as the index specified by
    the <nIndex> parameter, starting at zero for the first four-byte value in
    the extra space, 4 for the next four-byte value and so on.
--*/

ULONG FASTCALL WU32GetWindowLong(PVDMFRAME pFrame)
{
    ULONG ul;
    INT iOffset;
    register PWW pww;
    register PGETWINDOWLONG16 parg16;

    GETARGPTR(pFrame, sizeof(GETWINDOWLONG16), parg16);

    // Make sure Win32 didn't change offsets for GWL constants

#if (GWL_WNDPROC != (-4) || GWL_STYLE != (-16) || GWL_EXSTYLE != (-20))
#error Win16/Win32 GWL constants differ
#endif

#ifndef WIN16_GWW_HINSTANCE
#define WIN16_GWW_HINSTANCE     (-6)
#define WIN16_GWW_HWNDPARENT    (-8)
#define WIN16_GWW_ID            (-12)
#endif

    // Make sure the 16-bit app is requesting allowable offsets

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GWL_WNDPROC  ||
        iOffset == GWL_STYLE || iOffset == GWL_EXSTYLE ||
        iOffset == WIN16_GWW_HINSTANCE  ||
        iOffset == WIN16_GWW_HWNDPARENT ||
        iOffset == WIN16_GWW_ID         );

    ul = 0;
    switch( iOffset ) {
        case DWL_DLGPROC:
            if (pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN)) {

                //
                // if vpfnDlgProc exists then assume this is a dialog
                //

                if (pww->vpfnDlgProc) {
                    ul = pww->vpfnDlgProc;
                }
                else if (pww->iClass == WOWCLASS_DIALOG ||
                            (pww->flState & WWSTATE_FAKEDIALOGCLASS)) {

                    //
                    // this is some dialog we don't know about, like
                    // the window created by a call to MessageBox().
                    //

                    DWORD dwDlgProc32Cur;
                    dwDlgProc32Cur = GetWindowLong(HWND32(parg16->f1), DWL_DLGPROC);

                    if (dwDlgProc32Cur) {
                        ul = GetThunkWindowProc(dwDlgProc32Cur, 0, pww, HWND32(parg16->f1));
                    } else {
                        ul = 0;
                    }
                }
                else {
                    // not a dialog.  default processing

                    goto defgwl;
                }
            }
            break;

        case GWL_WNDPROC:
            if (pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN)) {
                DWORD dwWndProc32Cur;

                dwWndProc32Cur = GetWindowLong(HWND32(parg16->f1), GWL_WNDPROC);

                if ( dwWndProc32Cur & WNDPROC_WOW ) {
                    if ( HIWORD(dwWndProc32Cur) == WNDPROC_HANDLE ) {
                        /*
                        ** Has a 32-bit WindowProc that is a handle-based value
                        ** (if it needs a 32-bit Ansi-Unicode transition, or
                        ** vice versa.)
                        */
                        ul = GetThunkWindowProc( dwWndProc32Cur, NULL, pww, HWND32(parg16->f1) );
                    } else {
                        /*
                        ** Has a WOW WindowProc
                        */
                        ul = dwWndProc32Cur & WNDPROC_MASK;

                        //
                        // if the actual selector had the high bit on then we turned off
                        // bit 2 of the selector (the LDT bit, which will always be on)
                        //
                        if (!(ul & WOWCLASS_VIRTUAL_NOT_BIT31)) {
                            ul |= (WNDPROC_WOW | WOWCLASS_VIRTUAL_NOT_BIT31);
                        }
                    }
                } else {
                    /*
                    ** Has a 32-bit WindowProc
                    */
                    ul = GetThunkWindowProc( dwWndProc32Cur, NULL, pww, HWND32(parg16->f1) );
                }
            }
            break;

        case GWL_EXSTYLE:
            // Lotus Approach needs the WS_EX_TOPMOST bit cleared on
            // GetWindowLong of NETDDE AGENT window.
            ul = GetWindowLong(HWND32(parg16->f1), iOffset);
            if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLCLRTOPMOST) {
                char szBuf[40];

                if (GetClassName(HWND32(parg16->f1), szBuf, sizeof(szBuf))) {
                    if (!_stricmp(szBuf, "NDDEAgnt")) {
                        ul &= !WS_EX_TOPMOST;
                    }
                }
            }

            break;

defgwl:
        default:

            // This is a real HACK for PowerBuild 3.0. Before we change the offset
            // from 2 to 4, we nneed to make sure that we are doing it correctly for
            // this specific class.
            // The class in this case is "PaList".
            //
            // ChandanC Marh 9th 1994
            //

            if (iOffset == 2) {
                if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLINDEX2TO4) {
                    char Buffer[40];

                    if (GetClassName (HWND32(parg16->f1), Buffer, sizeof(Buffer))) {
                        if (!_stricmp (Buffer, "PaList")) {
                            iOffset = 4;
                        }
                    }
                }
            }

            ul = GetWindowLong(HWND32(parg16->f1), iOffset);
            break;

        case WIN16_GWW_HINSTANCE:
            /*
            ** We might need to set the high 16-bits to
            ** some mysterious value (See Win 3.1 WND structure)
            */
            ul = (ULONG)((WORD)GetWindowLong(HWND32(parg16->f1),
                                                          GWL_HINSTANCE));
            break;
        case WIN16_GWW_HWNDPARENT:
            /*
            ** We might need to set the high 16-bits to
            ** some mysterious value (See Win 3.1 WND structure)
            */

            ul = (ULONG)GETHWND16((HAND32)GetWindowLong(HWND32(parg16->f1),
                                                        GWL_HWNDPARENT));
            break;

        case WIN16_GWW_ID:
            /*
            ** We might need to set the high 16-bits to
            ** some mysterious value (See Win 3.1 WND structure)
            */
            ul = (ULONG)((WORD)GetWindowLong(HWND32(parg16->f1), GWL_ID));
            break;

    }

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    HANDLE GetWindowTask(<hwnd>)
    HWND <hwnd>;

    The %GetWindowTask% function searches for the handle of a task associated
    with the <hwnd> parameter. A task is any program that executes as an
    independent unit. All applications are executed as tasks. Each instance of
    an application is a task.

    <hwnd>
        Identifies the window for which a task handle is retrieved.

    The return value identifies the task associated with a particular window.
--*/

ULONG FASTCALL WU32GetWindowTask(PVDMFRAME pFrame)
{
    register PGETWINDOWTASK16 parg16;
    DWORD dwThreadID, dwProcessID;
    PTD ptd;

    GETARGPTR(pFrame, sizeof(GETWINDOWTASK16), parg16);

    dwThreadID = GetWindowThreadProcessId(HWND32(parg16->f1), &dwProcessID);

    //
    // return corresponding htask16 if window belongs to a WOW thread
    // else return WowExec's htask.
    //

    ptd = ThreadProcID32toPTD(dwThreadID, dwProcessID);

    if (ptd == NULL) {
        ptd = gptdShell;
    }

    FREEARGPTR(parg16);
    return (ULONG)ptd->htask16;
}


/*++
    int GetWindowText(<hwnd>, <lpString>, <nMaxCount>)
    HWND <hwnd>;
    LPSTR <lpString>;
    int <nMaxCount>;

    The %GetWindowText% function copies the given window's caption title (if it
    has one) into the buffer pointed to by the <lpString> parameter. If the
    <hwnd> parameter identifies a control, the %GetWindowText% function copies
    the text within the control instead of copying the caption.

    <hwnd>
        Identifies the window or control whose caption or text is to be copied.

    <lpString>
        Points to the buffer that is to receive the copied string.

    <nMaxCount>
        Specifies the maximum number of characters to be copied to the
        buffer. If the string is longer than the number of characters specified
        in the <nMaxCount> parameter, it is truncated.

    The return value specifies the length of the copied string. It is zero if
    the window has no caption or if the caption is empty.

    This function causes a WM_GETTEXT message to be sent to the given window or
    control.
--*/

ULONG FASTCALL WU32GetWindowText(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz2;
    register PGETWINDOWTEXT16 parg16;

    GETARGPTR(pFrame, sizeof(GETWINDOWTEXT16), parg16);
    ALLOCVDMPTR(parg16->f2, parg16->f3, psz2);

    ul = GETINT16(GetWindowText(
        HWND32(parg16->f1),
        psz2,
        WORD32(parg16->f3)
    ));

    FLUSHVDMPTR(parg16->f2, (USHORT)ul+1, psz2);
    FREEVDMPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    int GetWindowTextLength(<hwnd>)
    HWND <hwnd>;

    The %GetWindowTextLength% function returns the length of the given window's
    caption title. If the <hwnd> parameter identifies a control, the
    %GetWindowTextLength% function returns the length of the text within the
    control instead of the caption.

    <hwnd>
        Identifies the window or control.

    The return value specifies the text length. It is zero if no such text
    exists.
--*/

ULONG FASTCALL WU32GetWindowTextLength(PVDMFRAME pFrame)
{
    ULONG ul;
    register PGETWINDOWTEXTLENGTH16 parg16;

    GETARGPTR(pFrame, sizeof(GETWINDOWTEXTLENGTH16), parg16);

    ul = GETINT16(GetWindowTextLength(
    HWND32(parg16->f1)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    WORD GetWindowWord(<hwnd>, <nIndex>)
    HWND <hwnd>;
    int <nIndex>;

    The %GetWindowWord% function retrieves information about the window
    identified by <hwnd>.

    <hwnd>
        Identifies the window.

    <nIndex>
        Specifies the byte offset of the value to be retrieved. It can
        also be one of the following values:

    GWL_HINSTANCE
        Instance handle of the module that owns the window.

    GWL_HWNDPARENT
        Handle of the parent window, if any. The %SetParent% function changes
        the parent window of a child window. An application should not call the
        %SetWindowLong% function to change the parent of a child window.

    GWL_ID
        Control ID of the child window.

    The return value specifies information about the given window.


    To access any extra two-byte values allocated when the window-class
    structure was created, use a positive byte offset as the index specified by
    the <nIndex> parameter, starting at zero for the first two-byte value in the
    extra space, 2 for the next two-byte value and so on.
--*/

ULONG FASTCALL WU32GetWindowWord(PVDMFRAME pFrame)
{
    ULONG ul;
    HWND hwnd;
    INT iOffset;
    PWW pww;
    PGETWINDOWWORD16 parg16;
    DWORD dwThreadID32, dwProcessID32;
    HTASK16 htask16;
    PWOAINST pWOA;
    PTD ptd;

    GETARGPTR(pFrame, sizeof(GETWINDOWWORD16), parg16);

    // Make sure Win32 didn't change offsets

#if (GWL_HINSTANCE != (-6) || GWL_HWNDPARENT != (-8) || GWL_ID != (-12))
#error Win16/Win32 window-word constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GWL_HINSTANCE  ||
        iOffset == GWL_STYLE      ||
        iOffset == GWL_HWNDPARENT || iOffset == GWL_ID);

    hwnd = HWND32(parg16->f1);

    switch(iOffset) {
    case GWL_STYLE:
        // Wordperfect for windows calls GetWindowWord with GWL_STYLE.
        ul = (ULONG)GetWindowLong(hwnd, iOffset);
        break;

    case GWL_HINSTANCE:
        ul = (ULONG)GetWindowLong(hwnd, iOffset);

        //
        // Special hack for OLE 2.0 busy dialog, see WOLE2.C for long
        // comment.
        //
        // The below if does not exclude window's whose HINSTANCE is zero.
        // This is because some 32-bit applications put 0 in the HINSTANCE
        // stuff for their window (its optional for 32-bit windows).
        //
        if ( !ISINST16(ul) ) {
            // here if ul = NULL or ul = 0xZZZZ0000
            //
            // if (ul is 0xZZZZ0000) return 16bit user.exe instance.
            // PowerBuilder 3.0 does
            //     hInst =  GetWindowWord(Dialog, GWL_HINSTANCE)
            //     hIcon =  CreateIcon(... hInst ...);
            // CreateIcon will fail if hInst is invalid (say BOGUSGDT). So
            // we return 16bit user.exe hinstance in all such cases.
            //

            dwProcessID32 = (DWORD)-1;
            dwThreadID32 = GetWindowThreadProcessId( hwnd, &dwProcessID32 );

            //
            // Check if this window belongs to a task we spawned via
            // WinOldAp, if so, return WinOldAp's hmodule.
            //

            ptd = CURRENTPTD();
            pWOA = ptd->pWOAList;
            while (pWOA && pWOA->dwChildProcessID != dwProcessID32) {
                pWOA = pWOA->pNext;
            }

            if (pWOA) {
                ul = pWOA->ptdWOA->hInst16;
                LOGDEBUG(LOG_ALWAYS, ("WOW32 GetWindowWord(0x%x, GWW_HINSTANCE) returning 0x%04x\n",
                                      hwnd, ul));
            } else {

                ul = (ul) ? gUser16hInstance : ul;

                if (cHtaskAliasCount != 0 ) {

                    //
                    // Must be some 32-bit process, not a wow app's window
                    //

                    if ( dwThreadID32 != 0 ) {

                        htask16 = FindHtaskAlias( dwThreadID32 );

                        if ( htask16 != 0 ) {
                            ul = (ULONG)htask16;
                        }
                    }
                }
            }
        }
        break;

    case GWL_HWNDPARENT:
        ul = (ULONG)GETHWND16((HAND32)GetWindowLong(hwnd, iOffset));
        break;

    case GWL_ID:
        ul = GetWindowLong(hwnd, iOffset);
        if (!(GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD)) {
            ul = (ULONG)GETHMENU16(ul);
        }
        break;

    // Under Windows index 4 of a static control could be the icon
    case 4:
        pww = FindPWW(hwnd, WOWCLASS_UNKNOWN);
        if (pww) {
            if ((GetWindowLong(hwnd, GWL_STYLE) & SS_ICON) && (pww->iClass == WOWCLASS_STATIC)) {
                ul = SendMessage(hwnd, STM_GETICON, 0, 0);
                return GETHICON16(ul);
            }
        }
        // FALL THROUGH!


    default:
        //
        // Offset is non-negative, this is the cbWndExtra bytes that
        // are fair game.
        //

        //
        // Gross app hack for Adonis' Clip-Art Window Shopper online
        // clipart software that comes with CA-Cricket Presents.
        // These bozos SetWindowWord(hwnd, 3, wWhatever), thereby
        // overwriting the 4th and 5th bytes of per-window data.
        // The edit control itself only uses the first 2 bytes
        // on 3.1, and has 6 bytes reserved, so this works.  On
        // NT the first 4 bytes are used (32-bit handle), and so
        // this P.O.S. overwrites the high byte of the handle.
        // So if it's the compatibility flag is set and the class name
        // matches the one this bogus app uses, and it's storing a
        // word at offset 3, change it to 4.  This is safe because
        // the NT edit control only uses the first 4 of its 6
        // reserved window extra bytes.
        //

        if (3 == iOffset && (CURRENTPTD()->dwWOWCompatFlags & WOWCF_EDITCTRLWNDWORDS)) {

            char szClassName[30];

            if (GetClassName(hwnd, szClassName, sizeof(szClassName)) &&
                !strcmp(szClassName, "SuperPassEdit")) {

                iOffset = 4;

                LOGDEBUG(LOG_ALWAYS,("WOW WU32GetWindowWord: SHOPPER hack triggered, using offset 4, rc = %x.\n",
                         GetWindowWord(hwnd, iOffset)));

            }
        }

        ul = GetWindowWord(hwnd, iOffset);
        break;
    }

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    BOOL MoveWindow(<hwnd>, <left>, <top>, <width>, <height>, <fRepaint>)
    HWND <hwnd>;
    int <left>;
    int <top>;
    int <width>;
    int <height>;
    BOOL <fRepaint>;

    The %MoveWindow% function changes the position and dimensions of a window.

    <hwnd>
        Identifies the window to change.

    <left>
        Specifies the new position of the left side of the window.

    <top>
        Specifies the new position of the top of the window.

    <width>
        Specifies the new width of the window.

    <height>
        Specifies the new height of the window.

    <fRepaint>
        Specifies whether or not the window is to be repainted. If this
        parameter is TRUE, the window is repainted.

    The return value is nonzero if the function is successful. Otherwise it is
    zero.  (updated for Win3.1 compatability -- this returned void for Win3.0)

    For top-level windows the <left> and <top> parameters are relative to the
    upper-left corner of the screen. For child windows, they are relative to the
    upper-left corner of the parent window's client area.

    The %MoveWindow% function sends a WM_GETMINMAXINFO message to the window
    being moved. This gives the window being moved the opportunity to modify
    the default values for the largest and smallest possible windows. If the
    parameters to the %MoveWindow% function exceed these values, the values will
    be replaced by the minimum or maximum values specified in the
    WM_GETMINMAXINFO message.
--*/

ULONG FASTCALL WU32MoveWindow(PVDMFRAME pFrame)
{
    ULONG    ul;
    register PMOVEWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(MOVEWINDOW16), parg16);

    if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DBASEHANDLEBUG) {
        RECT ParentRect;
        RECT ScreenRect;

        GetWindowRect(GetDesktopWindow(), &ScreenRect);
        if ((INT32(parg16->f2) > ScreenRect.right) ||
            (INT32(parg16->f3) > ScreenRect.bottom) ||
            (INT32(parg16->f4) > ScreenRect.right) ||
            (INT32(parg16->f5) > ScreenRect.bottom)) {
            int x, y, cx, cy;

            GetWindowRect(GetParent(HWND32(parg16->f1)), &ParentRect);
            x  = ParentRect.left;
            y  = ParentRect.top;
            cx = ParentRect.right - ParentRect.left;
            cy = ParentRect.bottom - ParentRect.top;


            ul = GETBOOL16(MoveWindow(HWND32(parg16->f1), x, y, cx, cy,
                                      BOOL32(parg16->f6)));
            FREEARGPTR(parg16);
            RETURN(ul);
        }
    }

    ul = GETBOOL16(MoveWindow(HWND32(parg16->f1),
                              INT32(parg16->f2),
                              INT32(parg16->f3),
                              INT32(parg16->f4),
                              INT32(parg16->f5),
                              BOOL32(parg16->f6)));


    FREEARGPTR(parg16);

    RETURN(ul);
}


/*++
    void ScrollWindow(<hwnd>, <XAmount>, <YAmount>, <lpRect>, <lpClipRect>)
    HWND <hwnd>;
    int <XAmount>;
    int <YAmount>;
    LPRECT <lpRect>;
    LPRECT <lpClipRect>;

    The %ScrollWindow% function scrolls a window by moving the contents of the
    window's client area the number of units specified by the <XAmount>
    parameter along the screen's <x>-axis and the number of units specified by
    the <YAmount> parameter along the <y>-axis. The scroll moves right if
    <XAmount> is positive and left if it is negative. The scroll moves down if
    <YAmount> is positive and up if it is negative.

    <hwnd>
        Identifies the window whose client area is to be scrolled.

    <XAmount>
        Specifies the amount (in device units) to scroll in the <x>
        direction.

    <YAmount>
        Specifies the amount (in device units) to scroll in the <y>
        direction.

    <lpRect>
        Points to a %RECT% structure that specifies the portion of
        the client area to be scrolled. If <lpRect> is NULL, the entire client
        area is scrolled.

    <lpClipRect>
        Points to a %RECT% structure that specifies the clipping
        rectangle to be scrolled. Only bits inside this rectangle are scrolled.
        If <lpClipRect> is NULL, the entire window is scrolled.

    This function does not return a value.

    If the caret is in the window being scrolled, %ScrollWindow% automatically
    hides the caret to prevent it from being erased, then restores the caret
    after the scroll is finished. The caret position is adjusted accordingly.

    The area uncovered by the %ScrollWindow% function is not repainted, but is
    combined into the window's update region. The application will eventually
    receive a WM_PAINT message notifying it that the region needs repainting. To
    repaint the uncovered area at the same time the scrolling is done, call the
    %UpdateWindow% function immediately after calling %ScrollWindow%.

    If the <lpRect> parameter is NULL, the positions of any child windows in the
    window are offset by the amount specified by <XAmount> and <YAmount>, and
    any invalid (unpainted) areas in the window are also offset. %ScrollWindow%
    is faster when <lpRect> is NULL.

    If the <lpRect> parameter is not NULL, the positions of child windows are
    <not> changed, and invalid areas in the window are <not> offset. To prevent
    updating problems when <lpRect> is not NULL, call the %UpdateWindow%
    function to repaint the window before calling %ScrollWindow%.
--*/

ULONG FASTCALL WU32ScrollWindow(PVDMFRAME pFrame)
{
    RECT t4, *p4;
    RECT t5, *p5;
    register PSCROLLWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(SCROLLWINDOW16), parg16);
    p4 = GETRECT16(parg16->f4, &t4);
    p5 = GETRECT16(parg16->f5, &t5);

    ScrollWindow(
    HWND32(parg16->f1),
    INT32(parg16->f2),
    INT32(parg16->f3),
    p4,
    p5
    );

    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    HWND SetActiveWindow(<hwnd>)
    HWND <hwnd>;

    The %SetActiveWindow% function makes a top-level window the active window.

    <hwnd>
        Identifies the top-level window to be activated.

    The return value identifies the window that was previously active. The
    %SetActiveWindow% function should be used with care since it allows an
    application to arbitrarily take over the active window and input focus.
    Normally, Windows takes care of all activation.
--*/

ULONG FASTCALL WU32SetActiveWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    register PSETACTIVEWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(SETACTIVEWINDOW16), parg16);

    ul = GETHWND16(SetActiveWindow(HWND32(parg16->f1)));


    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    HWND SetParent(<hwndChild>, <hwndNewParent>)
    HWND <hwndChild>;
    HWND <hwndNewParent>;

    The %SetParent% function changes the parent window of a child window. If the
    window identified by the <hwndChild> parameter is visible, Windows performs
    the appropriate redrawing and repainting.

    <hwndChild>
        Identifies the child window.

    <hwndNewParent>
        Identifies the new parent window.

    The return value identifies the previous parent window.
--*/

ULONG FASTCALL WU32SetParent(PVDMFRAME pFrame)
{
    ULONG ul;
    register PSETPARENT16 parg16;

    GETARGPTR(pFrame, sizeof(SETPARENT16), parg16);

    ul = GETHWND16(SetParent(HWND32(parg16->f1),
                             HWND32(parg16->f2)));

    FREEARGPTR(parg16);
    RETURN(ul);
}



/*++
    LONG SetWindowLong(<hwnd>, <nIndex>, <dwNewLong>)
    HWND <hwnd>;
    int <nIndex>;
    DWORD <dwNewLong>;

    The %SetWindowLong% function changes an attribute of the window specified by
    the <hwnd> parameter.

    <hwnd>
        Identifies the window.

    <nIndex>
        Specifies the byte offset of the attribute to be changed. It may
        also be one of the following values:

    GWL_EXSTYLE
        Sets a new extended window style.

    GWL_STYLE
        Sets a new window style.

    GWL_WNDPROC
        Sets a new long pointer to the window procedure.

    <dwNewLong>
        Specifies the replacement value.

    The return value specifies the previous value of the specified long
    integer.

    If the %SetWindowLong% function and the GWL_WNDPROC index are used to set a
    new window function, that function must have the window-function form and be
    exported in the module-definition file of the application. For more
    information, see the %RegisterClass% function, earlier in this chapter.

    Calling %SetWindowLong% with the GCL_WNDPROC index creates a subclass of the
    window class used to create the window. See Chapter 1, Window Manager
    Interface Functions, for more information on window subclassing. An
    application should not attempt to create a window subclass for standard
    Windows controls such as combo boxes and buttons.

    To access any extra four-byte values allocated when the window-class
    structure was created, use a positive byte offset as the index specified by
    the <nIndex> parameter, starting at zero for the first four-byte value in
    the extra space, 4 for the next four-byte value and so on.
--*/
ULONG FASTCALL WU32SetWindowLong(PVDMFRAME pFrame)
{
    ULONG ul;
    INT iOffset, iClass;
    register PWW pww;
    register PSETWINDOWLONG16 parg16;

    GETARGPTR(pFrame, sizeof(SETWINDOWLONG16), parg16);

    // Make sure Win32 didn't change offsets for GWL constants

#if (GWL_WNDPROC != (-4) || GWL_STYLE != (-16) || GWL_EXSTYLE != (-20))
#error Win16/Win32 GWL constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GWL_WNDPROC  ||
        iOffset == GWL_STYLE || iOffset == GWL_EXSTYLE);

    ul = 0;
    if (iOffset == GWL_WNDPROC) {

        if (pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN)) {
            DWORD dwWndProc32Old;
            DWORD dwWndProc32New;

            // Look to see if the new 16:16 proc is a thunk for a 32-bit proc.
            dwWndProc32New = IsThunkWindowProc(LONG32(parg16->f3), &iClass );

            if ( dwWndProc32New != 0 ) {
                //
                // They are attempting to set the window proc to an existing
                // 16-bit thunk that is really just a thunk for a 32-bit
                // routine.  We can just set it back to the 32-bit routine.
                //
                dwWndProc32Old = SetWindowLong(HWND32(parg16->f1), GWL_WNDPROC, dwWndProc32New);

                // If the 32 bit set failed, perhaps because its another process,
                // then we want to fail too
                if (!dwWndProc32Old)
                    goto SWL_Cleanup;

                SETWL(HWND32(parg16->f1), GWL_WOWvpfnWndProc, 0 );
                SETWL(HWND32(parg16->f1), GWL_WOWiClassAndflState,
                      MAKECLASSANDSTATE(iClass, pww->flState | WWSTATE_ICLASSISSET));
            } else {
                //
                // They are attempting to set it to a real 16:16 proc.
                //
                LONG    l;

                l = LONG32(parg16->f3);

                //
                // FEATURE-O-RAMA
                //
                // if the selector already has the high bit on then turn off
                // bit 2 of the selector (the LDT bit, which should always be
                // on).  we need a way to not blindly strip off the high bit
                // in our wndproc.
                //

                if (l & WNDPROC_WOW) {
                    WOW32ASSERT(l & WOWCLASS_VIRTUAL_NOT_BIT31);
                    l &= ~WOWCLASS_VIRTUAL_NOT_BIT31;
                }

                dwWndProc32Old = SetWindowLong(HWND32(parg16->f1), GWL_WNDPROC, l | WNDPROC_WOW);

                // If the 32 bit set failed, perhaps because its another process,
                // then we want to fail too
                if (!dwWndProc32Old)
                    goto SWL_Cleanup;

                SETWL(HWND32(parg16->f1), GWL_WOWvpfnWndProc, LONG32(parg16->f3));
            }

            if ( dwWndProc32Old & WNDPROC_WOW ) {
                if ( HIWORD(dwWndProc32Old) == WNDPROC_HANDLE ) {
                    //
                    // If the return value was a handle to a proc (due to
                    // the need for unicode-ansi transitions, or vice versa)
                    // then treat it as a 32-bit thunk.
                    //
                    ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
                } else {
                    //
                    // Previous proc was a 16:16 proc
                    //
                    ul = dwWndProc32Old & WNDPROC_MASK;

                    //
                    // if the actual selector had the high bit on then we turned off
                    // bit 2 of the selector (the LDT bit, which will always be on)
                    //

                    if (!(ul & WOWCLASS_VIRTUAL_NOT_BIT31)) {
                        ul |= (WNDPROC_WOW | WOWCLASS_VIRTUAL_NOT_BIT31);
                    }
                }
            } else {
                //
                // Previous proc was a 32-bit proc, use an allocated thunk
                //
                ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
            }
        }

    }
    else if (iOffset == DWL_DLGPROC) {
        if (pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN)) {
            DWORD dwDlgProc32Old;
            DWORD dwDlgProc32New;

            //
            // first see if this is a dialog or not
            //

            if (!(pww->vpfnDlgProc || pww->iClass == WOWCLASS_DIALOG ||
                (pww->flState & WWSTATE_FAKEDIALOGCLASS))) {

                goto defswp;    // not a dialog
            }

            // Look to see if the new 16:16 proc is a thunk for a 32-bit proc.
            dwDlgProc32New = IsThunkWindowProc(LONG32(parg16->f3), NULL);

            if ( dwDlgProc32New != 0 ) {
                //
                // They want to set the dialog proc to an existing
                // 16-bit thunk that is really just a thunk for a 32-bit
                // routine.  We can just set it back to the 32-bit routine.
                // assume they had already changed the dlgproc once and
                // return the old vpfnDlgProc.
                //
                SetWindowLong(HWND32(parg16->f1), DWL_DLGPROC, dwDlgProc32New);
                ul = pww->vpfnDlgProc;
                SETWL(HWND32(parg16->f1), GWL_WOWvpfnDlgProc, 0);

            } else { // subclass this dialogproc

                dwDlgProc32Old = SetWindowLong(HWND32(parg16->f1), iOffset,
                                    (parg16->f3) ? (LONG)W32DialogFunc : 0);

                if (dwDlgProc32Old == (DWORD)W32DialogFunc) {
                    ul = pww->vpfnDlgProc;

                } else if (dwDlgProc32Old) {
                    ul = GetThunkWindowProc(dwDlgProc32Old, 0, pww, HWND32(parg16->f1));

                } else {
                    ul = 0;
                }

                SETWL(HWND32(parg16->f1), GWL_WOWvpfnDlgProc, LONG32(parg16->f3));
            }
        }
    }
    else {    // not GWL_WNDPROC or GWL_DLGPROC
defswp:

    // This is a real HACK for PowerBuild 3.0. Before we change the offset
    // from 2 to 4, we nneed to make sure that we are doing it for this
    // specific class.
    // The class in this case is "PaList".
    //
    // ChandanC Marh 9th 1994
    //

        if (iOffset == 2) {
            if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLINDEX2TO4) {
                char Buffer[40];

                if (GetClassName (HWND32(parg16->f1), Buffer, sizeof(Buffer))) {
                    if (!_stricmp (Buffer, "PaList")) {
                        iOffset = 4;
                    }
                }
            }
        }

        ul = SetWindowLong(HWND32(parg16->f1), iOffset, LONG32(parg16->f3));
    }

SWL_Cleanup:
    FREEARGPTR(parg16);
    RETURN(ul);
}

/*++
    BOOL SetWindowPos(<hwnd>, <hwndInsertAfter>, <X>, <Y>, <cx>, <cy>, <wFlags>)
    HWND <hwnd>;
    HWND <hwndInsertAfter>;
    int <X>;
    int <Y>;
    int <cx>;
    int <cy>;
    WORD <wFlags>;

    The %SetWindowPos% function changes the size, position, and ordering of
    child, pop-up, and top-level windows. Child, pop-up, and top-level windows
    are ordered according to their appearance on the screen; the topmost window
    receives the highest rank, and it is the first window in the list. This
    ordering is recorded in a window list.

    <hwnd>
        Identifies the window that will be positioned.

    <hwndInsertAfter>
        Identifies a window in the window-manager's list that will
        precede the positioned window.

    <X>
        Specifies the <x->coordinate of the window's upper-left corner.

    <Y>
        Specifies the <y->coordinate of the window's upper-left corner.

    <cx>
        Specifies the new window's width.

    <cy>
        Specifies the new window's height.

    <wFlags>
        Specifies one of eight possible 16-bit values that affect the
        sizing and positioning of the window. It must be one of the following
        values:

    SWP_DRAWFRAME
        Draws a frame (defined in the window's class description) around the
        window.

    SWP_HIDEWINDOW
        Hides the window.

    SWP_NOACTIVATE
        Does not activate the window.

    SWP_NOMOVE
        Retains current position (ignores the <x> and <y> parameters).

    SWP_NOSIZE
        Retains current size (ignores the <cx> and <cy> parameters).

    SWP_NOREDRAW
        Does not redraw changes.

    SWP_NOZORDER
        Retains current ordering (ignores the <hwndInsertAfter> parameter).

    SWP_SHOWWINDOW
        Displays the window.

    The return value is nonzero if the function is successful. Otherwise it is
    zero.  (updated for Win3.1 compatability -- this returned void for Win3.0)

    If the SWP_NOZORDER flag is not specified, Windows places the window
    identified by the <hwnd> parameter in the position following the window
    identified by the <hwndInsertAfter> parameter. If <hwndInsertAfter> is NULL,
    Windows places the window identified by <hwnd> at the top of the list. If
    <hwndInsertAfter> is set to 1, Windows places the window identified by
    <hwnd> at the bottom of the list.

    If the SWP_SHOWWINDOW or the SWP_HIDEWINDOW flags are set, scrolling and
    moving cannot be done simultaneously.

    All coordinates for child windows are relative to the upper-left corner of
    the parent window's client area.
--*/

ULONG FASTCALL WU32SetWindowPos(PVDMFRAME pFrame)
{
    ULONG    ul;
    register PSETWINDOWPOS16 parg16;

    GETARGPTR(pFrame, sizeof(SETWINDOWPOS16), parg16);

    ul = GETBOOL16(SetWindowPos(HWND32(parg16->f1),
                                HWNDIA32(parg16->f2),
                                INT32(parg16->f3),
                                INT32(parg16->f4),
                                INT32(parg16->f5),
                                INT32(parg16->f6),
                                WORD32(parg16->f7) & SWP_VALID));

    FREEARGPTR(parg16);

    RETURN(ul);
}


/*++
    void SetWindowText(<hwnd>, <lpString>)

    The %SetWindowText% function sets the given window's caption title (if one
    exists) to the string pointed to by the <lpString> parameter. If the <hwnd>
    parameter is a handle to a control, the %SetWindowText% function sets the
    text within the control instead of within the caption.

    <hwnd>
        Identifies the window or control whose text is to be changed.

    <lpString>
        Points to a null-terminated string.

    This function does not return a value.
--*/

ULONG FASTCALL WU32SetWindowText(PVDMFRAME pFrame)
{
    PSZ psz2;
    register PSETWINDOWTEXT16 parg16;
    HANDLE handle;

    GETARGPTR(pFrame, sizeof(SETWINDOWTEXT16), parg16);
    GETPSZPTR(parg16->f2, psz2);
    handle = HWND32(parg16->f1);

    if (NULL != psz2) {
        AddParamMap((DWORD)psz2, FETCHDWORD(parg16->f2));
    }

    if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DBASEHANDLEBUG) {

        if (NULL == handle) {
            handle = (HANDLE) ((PTDB)SEGPTR(pFrame->wTDB,0))->TDB_CompatHandle;
        }
    }

    SetWindowText(handle, psz2);

    // if we used param map successfully - then nuke there

    if (NULL != psz2) {
        DeleteParamMap((DWORD)psz2, PARAM_32, NULL);
    }

    FREEPSZPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    WORD SetWindowWord(<hwnd>, <nIndex>, <wNewWord>)

    The %SetWindowWord% function changes an attribute of the window specified by
    the <hwnd> parameter.

    <hwnd>
        Identifies the window to be modified.

    <nIndex>
        Specifies the byte offset of the word to be changed. It can also
        be one of the following values:

    GWL_HINSTANCE
        Instance handle of the module that owns the window.

    GWL_ID
        Control ID of the child window.

    <wNewWord>
        Specifies the replacement value.

    The return value specifies the previous value of the specified word.

    To access any extra two-byte values allocated when the window-class
    structure was created, use a positive byte offset as the index specified by
    the <nIndex> parameter, starting at zero for the first two-byte value in the
    extra space, 2 for the next two-byte value and so on.
--*/

ULONG FASTCALL WU32SetWindowWord(PVDMFRAME pFrame)
{
    ULONG ul;
    HWND hwnd;
    INT iOffset;
    PSETWINDOWWORD16 parg16;
    PWW pww;

    GETARGPTR(pFrame, sizeof(SETWINDOWWORD16), parg16);

    // Make sure Win32 didn't change offsets

#if (GWL_HINSTANCE != (-6) || GWL_HWNDPARENT != (-8) || GWL_ID != (-12))
#error Win16/Win32 window-word constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GWL_HINSTANCE || iOffset == GWL_ID ||
        iOffset == GWL_HWNDPARENT);

    hwnd = HWND32(parg16->f1);
    ul = WORD32(parg16->f3);

    switch(iOffset) {
        case GWL_HINSTANCE:
            ul = GETHINST16(SetWindowLong(hwnd,
                                          iOffset,
                                          (LONG)HMODINST32(parg16->f3)));
            break;

        case GWL_HWNDPARENT:
            //    ul = 0;         // not allowed to set this
            ul = SetWindowLong(hwnd, iOffset, (LONG)HWND32(parg16->f3));
            ul = GETHWND16((HAND32)ul);
            break;

        case GWL_ID:
            {
                // if this isn't a child window then the value should be a
                // menu handle
                BOOL    fChild = (GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD);
                ul = SetWindowLong(hwnd,
                                   iOffset,
                                   fChild ? (LONG)ul : (LONG)HMENU32(parg16->f3));

                if (!fChild)
                    ul = (ULONG)GETHMENU16(ul);

                // Invalidate the SendDlgItemMessage cache
                hdlgSDIMCached = NULL ;
            }
            break;

        // Under Windows index 4 of a static control could be the icon
        case 4:
            pww = FindPWW(hwnd, WOWCLASS_UNKNOWN);
            if (pww) {
                if ((GetWindowLong(hwnd, GWL_STYLE) & SS_ICON) && (pww->iClass == WOWCLASS_STATIC)) {
                    ul = SendMessage(hwnd, STM_SETICON, (WPARAM)HICON32(ul), 0);
                    return GETHICON16(ul);
                }
            }
            // FALL THROUGH!

        default:
            //
            // Offset is non-negative, this is the cbWndExtra bytes that
            // are fair game.
            //

            //
            // Gross app hack for Adonis' Clip-Art Window Shopper online
            // clipart software that comes with CA-Cricket Presents.
            // These bozos SetWindowWord(hwnd, 3, wWhatever), thereby
            // overwriting the 4th and 5th bytes of per-window data.
            // The edit control itself only uses the first 2 bytes
            // on 3.1, and has 6 bytes reserved, so this works.  On
            // NT the first 4 bytes are used (32-bit handle), and so
            // this P.O.S. overwrites the high byte of the handle.
            // So if it's an app called "SHOPPER" and it's storing a
            // word at offset 3, change it to 4.  This is safe because
            // the NT edit control only uses the first 4 of its 6
            // reserved window extra bytes.
            //

            if (3 == iOffset && (CURRENTPTD()->dwWOWCompatFlags & WOWCF_EDITCTRLWNDWORDS)) {

                char szClassName[30];

                if (GetClassName(hwnd, szClassName, sizeof(szClassName)) &&
                    !strcmp(szClassName, "SuperPassEdit")) {

                    iOffset = 4;

                    LOGDEBUG(LOG_ALWAYS,("WOW WU32SetWindowWord: SHOPPER hack triggered, using offset 4.\n"));
                }
            }

            ul = SetWindowWord(hwnd, iOffset, (WORD)ul);
            break;
    }

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++
    void ShowScrollBar(<hwnd>, <wBar>, <bShow>)

    The %ShowScrollBar% function displays or hides a scroll bar, depending on
    the value of the <bShow> parameter. If <bShow> is TRUE, the scroll bar is
    displayed; if <bShow> is FALSE, the scroll bar is hidden.

    <hwnd>
        Identifies a window that contains a scroll bar in its nonclient area if
        the wBar parameter is SB_HORZ, SB_VERT, or SB_BOTH. If wBar is SB_CTL,
        hwnd identifies a scroll-bar control.

    <wBar>
        %WORD% Specifies whether the scroll bar is a control or part of a
        window's nonclient area. If it is part of the nonclient area, <wBar>
        also indicates whether the scroll bar is positioned horizontally,
        vertically, or both. It must be one of the following values:

    SB_BOTH  Specifies the window's horizontal and vertical scroll bars.
    SB_CTL   Specifies that the scroll bar is a control.
    SB_HORZ  Specifies the window's horizontal scroll bar.
    SB_VERT  Specifies the window's vertical scroll bar.

    <bShow>
        Specifies whether or not Windows hides the scroll bar. If <bShow> is
        FALSE, the scroll bar is hidden. Otherwise, the scroll bar is
        displayed.

    This function does not return a value.

    An application should not call this function to hide a scroll bar while
    processing a scroll-bar notification message.
--*/

ULONG FASTCALL WU32ShowScrollBar(PVDMFRAME pFrame)
{
    register PSHOWSCROLLBAR16 parg16;

    GETARGPTR(pFrame, sizeof(SHOWSCROLLBAR16), parg16);

    ShowScrollBar(
    HWND32(parg16->f1),
    WORD32(parg16->f2),
    BOOL32(parg16->f3)
    );

    FREEARGPTR(parg16);
    RETURN(0);
}


/*++
    BOOL ShowWindow(<hwnd>, <nCmdShow>)

    The %ShowWindow% function displays or removes the given window, as specified
    by the <nCmdShow> parameter.

    <hwnd>
        Identifies the window.

    <nCmdShow>
        Specifies how the window is to be shown. It must be one of the
        following values:

    SW_HIDE
        Hides the window and passes activation to another window.

    SW_MINIMIZE
        Minimizes the specified window and activates the top-level window in the
        window-manager's list.

    SW_RESTORE
        Same as SW_SHOWNORMAL.

    SW_SHOW
        Activates a window and displays it in its current size and position.

    SW_SHOWMAXIMIZED
        Activates the window and displays it as a maximized window.

    SW_SHOWMINIMIZED
        Activates the window and displays it as iconic.

    SW_SHOWMINNOACTIVE
        Displays the window as iconic. The window that is currently active
        remains active.

    SW_SHOWNA
        Displays the window in its current state. The window that is currently
        active remains active.

    SW_SHOWNOACTIVATE
        Displays a window in its most recent size and position. The window that
        is currently active remains active.

    SW_SHOWNORMAL
        Activates and displays a window. If the window is minimized or
        maximized, Windows restores it to its original size and position.

    The return value specifies the previous state of the window. It is TRUE
    if the window was previously visible. It is FALSE if the window was
    previously hidden.

    The %ShowWindow% function must be called only once per program with the
    <nCmdShow> parameter from the WinMain function. Subsequent calls to
    %ShowWindow% must use one of the values listed above, instead of one
    specified by the <nCmdShow> parameter from the WinMain function.
--*/

ULONG FASTCALL WU32ShowWindow(PVDMFRAME pFrame)
{
    ULONG ul;
    register PSHOWWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(SHOWWINDOW16), parg16);

    ul = GETBOOL16(ShowWindow(
    HWND32(parg16->f1),
    INT32(parg16->f2)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}


/*++          user
    void UpdateWindow(<hwnd>)

    The %UpdateWindow% function updates the client area of the given window by
    sending a WM_PAINT message to the window if the update region for the window
    is not empty. The %UpdateWindow% function sends a WM_PAINT message directly
    to the window function of the given window, bypassing the application
    queue. If the update region is empty, no message is sent.

    <hwnd>
        Identifies the window to be updated.

    This function does not return a value.
--*/

ULONG FASTCALL WU32UpdateWindow(PVDMFRAME pFrame)
{
    register PUPDATEWINDOW16 parg16;

    GETARGPTR(pFrame, sizeof(UPDATEWINDOW16), parg16);

    UpdateWindow(
    HWND32(parg16->f1)
    );

    FREEARGPTR(parg16);
    RETURN(0xcdef);         // ack!     same as win31
}


/*++
    HWND WindowFromPoint(<Point>)

    The %WindowFromPoint% function identifies the window that contains the given
    point; <Point> must specify the screen coordinates of a point on the screen.

    <Point>
        Specifies a %POINT% structure that defines the point to be checked.

    The return value identifies the window in which the point lies. It is NULL
    if no window exists at the given point.
--*/

ULONG FASTCALL WU32WindowFromPoint(PVDMFRAME pFrame)
{
    ULONG ul;
    POINT t1;
    register PWINDOWFROMPOINT16 parg16;

    GETARGPTR(pFrame, sizeof(WINDOWFROMPOINT16), parg16);
    COPYPOINT16(parg16->f1, t1);

    ul = GETHWND16(WindowFromPoint(t1));

    FREEARGPTR(parg16);
    RETURN(ul);
}