-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessage.sml
More file actions
3867 lines (2870 loc) · 164 KB
/
Copy pathMessage.sml
File metadata and controls
3867 lines (2870 loc) · 164 KB
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
(*
Copyright (c) 2001-7, 2015, 2019, 2021
David C.J. Matthews
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
structure Message: MESSAGE =
struct
local
open Foreign
open Memory
open Base
open Globals
open WinBase
fun user name = getSymbol(loadLibrary "user32.dll") name
val toAddr = Memory.sysWord2VoidStar
and fromAddr = Memory.voidStar2Sysword
val RegisterMessage = winCall1 (user "RegisterWindowMessageA") cString cUint
(* Used in WM_WINDOWPOSXXX and also WM_NCCALCSIZE *)
val WINDOWPOS = cStruct7(cHWND, cHWND, cInt, cInt, cInt, cInt, cWINDOWPOSITIONSTYLE)
local (* WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED. The C structure is the same
but WM_WINDOWPOSCHANGING has refs in the ML to allow the call-back to
change the position. *)
val {load=fromCwindowpos, store=toCwindowpos, ctype={size=sizeCwp, ...}, ...} = breakConversion WINDOWPOS
type wmWINDOWPOSCHANGED =
{ hwnd: HWND, front: HWND, x: int, y: int, width: int, height: int, flags: WindowPositionStyle list }
and wmWINDOWPOSCHANGING =
{
hwnd: HWND, front: HWND ref, x: int ref, y: int ref,
width: int ref, height: int ref, flags: WindowPositionStyle list ref
}
in
fun cToMLWindowPosChanging{wp=_, lp}: wmWINDOWPOSCHANGING =
let
val (wh,front,x,y,width,height,flags) = fromCwindowpos(toAddr lp)
in
{hwnd = wh, front = ref front, x = ref x, y = ref y,
width = ref width, height = ref height, flags = ref flags}
end
and cToMLWindowPosChanged{wp=_, lp}: wmWINDOWPOSCHANGED =
let
val (wh,front,x,y,width,height,flags) = fromCwindowpos(toAddr lp)
in
{hwnd = wh, front = front, x = x, y = y, width = width, height = height, flags = flags}
end
fun mlToCWindowPosChanging(msgNo, {hwnd, front=ref front, x=ref x, y=ref y,
width=ref width, height=ref height, flags=ref flags}: wmWINDOWPOSCHANGING) =
let
open Memory
val mem = malloc sizeCwp
val freeCwp = toCwindowpos(mem, (hwnd, front, x, y, width, height, flags))
in
(msgNo, 0w0, fromAddr mem, fn() => (freeCwp(); free mem))
end
and mlToCWindowPosChanged(msgNo, {hwnd, front, x, y, width, height, flags}: wmWINDOWPOSCHANGED) =
let
open Memory
val mem = malloc sizeCwp
val freeCwp = toCwindowpos(mem, (hwnd, front, x, y, width, height, flags))
in
(msgNo, 0w0, fromAddr mem, fn() => (freeCwp(); free mem))
end
fun updateCfromMLwmWindowPosChanging(
{wp=_, lp}, { front, x, y, width, height, flags, ...}:wmWINDOWPOSCHANGING) =
let
val (_,newfront,newx,newy,newwidth,newheight,newflags) = fromCwindowpos(toAddr lp)
in
front := newfront;
x := newx;
y := newy;
width := newwidth;
height := newheight;
flags := newflags
end
and updateWindowPosChangingParms({wp=_, lp}, { hwnd, front=ref front, x=ref x, y=ref y,
width=ref width, height=ref height, flags=ref flags}) =
ignore(toCwindowpos(toAddr lp, (hwnd, front, x, y, width, height, flags)))
end
datatype ControlType = ODT_MENU | ODT_LISTBOX | ODT_COMBOBOX | ODT_BUTTON | ODT_STATIC
local
val
tab = [
(ODT_MENU, 1),
(ODT_LISTBOX, 2),
(ODT_COMBOBOX, 3),
(ODT_BUTTON, 4),
(ODT_STATIC, 5)
]
in
val cCONTROLTYPE = tableConversion(tab, NONE) cUint
end
fun structAsAddr strConv =
let
val {load, store, ctype={size, ...}, ...} = breakConversion strConv
fun make v =
let
open Memory
val mem = malloc size
val freeS = store(mem, v)
in
(fromAddr mem, fn () => (freeS(); free mem))
end
in
(load o toAddr, make)
end
val (_, makePointStructAddr) = structAsAddr cPoint
local
val MDICREATESTRUCT = cStruct9(cCLASS,cString,cHINSTANCE,cInt,cInt,cInt,cInt,cDWORD,cLPARAM)
in
val (toMdiCreate, fromMdiCreate) = structAsAddr MDICREATESTRUCT
end
local (* WM_COMPAREITEM *)
val COMPAREITEMSTRUCT = cStruct8(cCONTROLTYPE,cUint,cHWND,cUint,cUINT_PTRw,cUint,cUINT_PTRw, cDWORD)
val MEASUREITEMSTRUCT = cStruct6(cCONTROLTYPE,cUint,cUint,cUint,cUint,cULONG_PTR)
val DELETEITEMSTRUCT = cStruct5(cCONTROLTYPE,cUint,cUint,cHWND,cULONG_PTR)
val {store=toMeasureItem, ...} = breakConversion MEASUREITEMSTRUCT
in
val (toMLCompareItem, fromMLCompareItem) = structAsAddr COMPAREITEMSTRUCT
and (toMLMeasureItem, fromMLMeasureItem) = structAsAddr MEASUREITEMSTRUCT
and (toMLDeleteItem, fromMLDeleteItem) = structAsAddr DELETEITEMSTRUCT
fun updateMeasureItemFromWpLp({itemWidth, itemHeight, ...}, {wp=_, lp}) =
let
val (_, _, _, iWidth, iHeight, _) = toMLMeasureItem lp
in
itemWidth := iWidth;
itemHeight := iHeight
end
and updateMeasureItemParms({wp=_, lp}, {itemWidth=ref itemWidth, itemHeight=ref itemHeight, ...}) =
let
val (ctlType, ctlID, itemID, _, _, itemData) = toMLMeasureItem lp
in
ignore(toMeasureItem(toAddr lp, (ctlType, ctlID, itemID, itemWidth, itemHeight, itemData)))
end
end
local (* WM_CREATE and WM_NCCREATE *)
val CREATESTRUCT = cStruct12(cPointer,cHINSTANCE,cHMENU,cHWND,cInt,cInt,cInt,cInt,cUlongw,cString,cCLASS,cDWORD)
val (toMLCreate, fromMLCreate) = structAsAddr CREATESTRUCT
in
fun decompileCreate{wp=_, lp} =
let
val (cp,inst,menu,parent, cy,cx,y,x, style, name,class, extendedstyle) = toMLCreate lp
in
{ instance = inst, creation = cp, menu = menu, parent = parent, cy = cy, cx = cx,
y = y, x = x, style = Style.fromWord(Word32.toLargeWord style), name = name,
class = class, extendedstyle = extendedstyle }
end
and compileCreate(code, { instance, creation, menu, parent, cy, cx,
y, x, style, name, class, extendedstyle}) =
let
val (addr, free) =
fromMLCreate(creation, instance, menu, parent,
cy, cx, y, x, Word32.fromLargeWord(Style.toWord style), name, class,
extendedstyle)
in
(code, 0w0, addr, free)
end
end
local
val MINMAXINFO = cStruct5(cPoint,cPoint,cPoint,cPoint,cPoint)
val {store=toCminmaxinfo, ...} = breakConversion MINMAXINFO
val (toMLMinMax, fromMLMinMax) = structAsAddr MINMAXINFO
in
fun decompileMinMax{wp=_, lp} =
let
val (_, ptms, ptmp, ptts, ptmts) = toMLMinMax lp
in
{ maxSize = ref ptms, maxPosition = ref ptmp,
minTrackSize = ref ptts, maxTrackSize = ref ptmts}
end
and compileMinMax(code, { maxSize=ref maxSize, maxPosition=ref maxPosition,
minTrackSize=ref minTrackSize, maxTrackSize=ref maxTrackSize}) =
let
val (addr, free) = fromMLMinMax({x=0,y=0}, maxSize, maxPosition, minTrackSize, maxTrackSize)
in
(code, 0w0, addr, free)
end
fun updateMinMaxFromWpLp({maxSize, maxPosition, minTrackSize, maxTrackSize}, {wp=_, lp}) =
let
val (_, ptms, ptmp, ptts, ptmts) = toMLMinMax lp
in
maxSize := ptms;
maxPosition := ptmp;
minTrackSize := ptts;
maxTrackSize := ptmts
end
and updateMinMaxParms({wp=_, lp}, {maxSize=ref maxSize, maxPosition=ref maxPosition,
minTrackSize=ref minTrackSize, maxTrackSize=ref maxTrackSize}) =
let
val (ptres, _, _, _, _) = toMLMinMax lp
in
ignore(toCminmaxinfo(toAddr lp, (ptres, maxSize, maxPosition, minTrackSize, maxTrackSize)))
end
end
local
val DRAWITEMSTRUCT = cStruct9(cCONTROLTYPE,cUint,cUint,cUint,cUint,cHWND,cHDC,cRect,cULONG_PTR)
in
val (toMLDrawItem, fromMLDrawItem) = structAsAddr DRAWITEMSTRUCT
end
local (* WM_NCCALCSIZE *)
val NCCALCSIZE_PARAMS = cStruct4(cRect,cRect,cRect, cConstStar WINDOWPOS)
val {load=loadStruct, store=storeStruct, ctype={size=sizeStr, ...}, ...} = breakConversion NCCALCSIZE_PARAMS
val {load=loadRect, store=storeRect, ctype={size=sizeRect, ...}, ...} = breakConversion cRect
in
fun decompileNCCalcSize{wp=0w1, lp} =
let
val (newrect,oldrect,oldclientarea,winpos) = loadStruct (toAddr lp)
val (wh,front,x,y,cx,cy,style) = winpos
in
{ validarea = true, newrect = ref newrect, oldrect = oldrect,
oldclientarea = oldclientarea, hwnd = wh, insertAfter = front,
x = x, y = y, cx = cx, cy = cy, style = style }
end
| decompileNCCalcSize{wp=_, lp} =
let
val newrect = loadRect (toAddr lp)
val zeroRect = {left=0, top=0, right=0, bottom=0}
in
{ validarea = false, newrect = ref newrect, oldrect = zeroRect,
oldclientarea = zeroRect, insertAfter = hwndNull, hwnd = hwndNull,
x = 0, y = 0, cx = 0, cy = 0, style = [] }
end
and compileNCCalcSize{validarea=true, newrect=ref newrect, oldrect, oldclientarea,
hwnd, insertAfter, x, y, cx, cy, style} =
let
open Memory
val mem = malloc sizeStr
val freeRect =
storeStruct(mem, (newrect,oldrect,oldclientarea,
(hwnd,insertAfter,x,y,cx,cy, style)))
in
(0x0083, 0w1, fromAddr mem, fn () => (freeRect(); free mem))
end
| compileNCCalcSize{validarea=false, newrect=ref newrect, ...} =
let
open Memory
val mem = malloc sizeRect
val () = ignore(storeRect(mem, newrect))
in
(0x0083, 0w0, fromAddr mem, fn () => free mem)
end
end
local
val HELPINFO = cStruct6(cUint, cInt, cInt, cPointer (* HANDLE *), cDWORD, cPoint)
val {ctype={size=sizeHelpInfo, ...}, ...} = breakConversion HELPINFO
val (toHelpInfo, fromHelpInfo) = structAsAddr HELPINFO
in
datatype HelpHandle = MenuHandle of HMENU | WindowHandle of HWND
fun compileHelpInfo(code, {ctrlId, itemHandle, contextId, mousePos}) =
let
val (ctype, handl) =
case itemHandle of
MenuHandle m => (2, voidStarOfHandle m)
| WindowHandle w => (1, voidStarOfHandle w)
val (addr, free) =
fromHelpInfo(Word.toInt sizeHelpInfo, ctype, ctrlId, handl, contextId, mousePos)
in
(code, 0w0, addr, free)
end
and decompileHelpInfo{wp=_, lp} =
let
val (_, ctype, ctrlId, itemHandle, contextId, mousePos) = toHelpInfo lp
val hndl =
if ctype = 2 then MenuHandle(handleOfVoidStar itemHandle)
else WindowHandle(handleOfVoidStar itemHandle)
in
{ ctrlId = ctrlId, itemHandle = hndl, contextId = contextId, mousePos = mousePos}
end
end
local
val {store=storeScrollInfo, ctype = {size=sizeStruct, ...}, ...} =
breakConversion ScrollBase.cSCROLLINFOSTRUCT
val (toScrollInfoStruct, fromScrollInfoStruct) = structAsAddr ScrollBase.cSCROLLINFOSTRUCT
in
fun toScrollInfo lp =
let
val (_, options, minPos, maxPos, pageSize, pos, trackPos) = toScrollInfoStruct lp
val info = { minPos = minPos, maxPos = maxPos, pageSize = pageSize, pos = pos, trackPos = trackPos }
in
(info, options)
end
and fromScrollInfo({minPos, maxPos, pageSize, pos, trackPos}, options) =
fromScrollInfoStruct(Word.toInt sizeStruct, options, minPos, maxPos, pageSize, pos, trackPos)
and updateScrollInfo({wp=_, lp=lp}, {info=ref {minPos, maxPos, pageSize, pos, trackPos}, options}) =
ignore(storeScrollInfo(toAddr lp, (Word.toInt sizeStruct, options, minPos, maxPos, pageSize, pos, trackPos)))
end
local
val {store=storeWord, load=loadWord, ctype={size=sizeWord, ...}, ...} = breakConversion cWORD
in
(* We have to allocate a buffer big enough to receive the text and
set the first word to the length of the buffer. *)
fun compileGetLine {lineNo, size, ...} =
let
open Memory
(* Allocate one extra byte so there's space for a null terminator. *)
val vec = malloc (Word.max(Word.fromInt(size+1), sizeWord))
in
ignore(storeWord(vec, size+1));
(0x00C5, SysWord.fromInt lineNo, fromAddr vec, fn () => free vec)
end
and decompileGetLine{wp, lp} =
let
(* The first word is supposed to contain the length *)
val size = loadWord(toAddr lp)
in
{ lineNo = SysWord.toInt wp, size = size(*-1 ? *), result = ref "" }
end
end
val {load=loadInt, store=storeInt, ctype={size=sizeInt, ...}, ...} = breakConversion cInt
local (* EM_SETTABSTOPS and LB_SETTABSTOPS *)
open Memory
infix 6 ++
in
fun decompileTabStops{wp, lp} =
let
val v = toAddr lp
fun getTab i = loadInt(v ++ Word.fromInt i * sizeInt)
in
IntVector.tabulate(SysWord.toInt wp, getTab)
end
and compileTabStops(code, tabs) =
let
val cTabs = IntVector.length tabs
val vec = malloc(Word.fromInt cTabs * sizeInt)
fun setVec(tab, addr) = (ignore(storeInt(addr, tab)); addr ++ sizeInt)
val _ = IntVector.foldl setVec vec tabs
in
(code, SysWord.fromInt cTabs, fromAddr vec, fn () => free vec)
end
end
local
open Memory IntArray
infix 6 ++
in
fun compileGetSelItems(code, {items}) =
(* Allocate a buffer to receive the items. Set each element of the buffer
to ~1 so that the values are defined if not all of them are set. *)
let
open Memory IntArray
val itemCount = length items
infix 6 ++
val v = malloc(Word.fromInt itemCount * sizeInt)
in
appi(fn (i, s) => ignore(storeInt(v ++ Word.fromInt i * sizeInt, s))) items;
(code, SysWord.fromInt itemCount, fromAddr v, fn () => free v)
end
fun updateGetSelItemsParms({wp=_, lp=lp}, {items}) =
let
val v = toAddr lp
in
appi(fn (i, s) => ignore(storeInt(v ++ Word.fromInt i * sizeInt, s))) items
end
and updateGetSelItemsFromWpLp({items}, {wp=_, lp, reply}) =
let
(* The return value is the actual number of items copied *)
val nItems = SysWord.toIntX reply
val b = toAddr lp
open Memory
infix 6 ++
fun newValue (i, old) = if i < nItems then loadInt(b ++ sizeInt * Word.fromInt i) else old
in
IntArray.modifyi newValue items
end
end
(* Passed in the lpParam argument of a WM_NOTIFY message.
TODO: Many of these have additional information. *)
datatype Notification =
NM_OUTOFMEMORY
| NM_CLICK
| NM_DBLCLK
| NM_RETURN
| NM_RCLICK
| NM_RDBLCLK
| NM_SETFOCUS
| NM_KILLFOCUS
| NM_CUSTOMDRAW
| NM_HOVER
| NM_NCHITTEST
| NM_KEYDOWN
| NM_RELEASEDCAPTURE
| NM_SETCURSOR
| NM_CHAR
| NM_TOOLTIPSCREATED
| NM_LDOWN
| NM_RDOWN
| NM_THEMECHANGED
| LVN_ITEMCHANGING
| LVN_ITEMCHANGED
| LVN_INSERTITEM
| LVN_DELETEITEM
| LVN_DELETEALLITEMS
| LVN_BEGINLABELEDIT
| LVN_ENDLABELEDIT
| LVN_COLUMNCLICK
| LVN_BEGINDRAG
| LVN_BEGINRDRAG
| LVN_GETDISPINFO
| LVN_SETDISPINFO
| LVN_KEYDOWN
| LVN_GETINFOTIP
| HDN_ITEMCHANGING
| HDN_ITEMCHANGED
| HDN_ITEMCLICK
| HDN_ITEMDBLCLICK
| HDN_DIVIDERDBLCLICK
| HDN_BEGINTRACK
| HDN_ENDTRACK
| HDN_TRACK
| HDN_ENDDRAG
| HDN_BEGINDRAG
| HDN_GETDISPINFO
| TVN_SELCHANGING
| TVN_SELCHANGED
| TVN_GETDISPINFO
| TVN_SETDISPINFO
| TVN_ITEMEXPANDING
| TVN_ITEMEXPANDED
| TVN_BEGINDRAG
| TVN_BEGINRDRAG
| TVN_DELETEITEM
| TVN_BEGINLABELEDIT
| TVN_ENDLABELEDIT
| TVN_KEYDOWN
| TVN_GETINFOTIP
| TVN_SINGLEEXPAND
| TTN_GETDISPINFO of string ref
| TTN_SHOW
| TTN_POP
| TCN_KEYDOWN
| TCN_SELCHANGE
| TCN_SELCHANGING
| TBN_GETBUTTONINFO
| TBN_BEGINDRAG
| TBN_ENDDRAG
| TBN_BEGINADJUST
| TBN_ENDADJUST
| TBN_RESET
| TBN_QUERYINSERT
| TBN_QUERYDELETE
| TBN_TOOLBARCHANGE
| TBN_CUSTHELP
| TBN_DROPDOWN
| TBN_HOTITEMCHANGE
| TBN_DRAGOUT
| TBN_DELETINGBUTTON
| TBN_GETDISPINFO
| TBN_GETINFOTIP
| UDN_DELTAPOS
| RBN_GETOBJECT
| RBN_LAYOUTCHANGED
| RBN_AUTOSIZE
| RBN_BEGINDRAG
| RBN_ENDDRAG
| RBN_DELETINGBAND
| RBN_DELETEDBAND
| RBN_CHILDSIZE
| CBEN_GETDISPINFO
| CBEN_DRAGBEGIN
| IPN_FIELDCHANGED
| SBN_SIMPLEMODECHANGE
| PGN_SCROLL
| PGN_CALCSIZE
| NM_OTHER of int (* Catch-all for other cases. *)
local
(* Notification structures *)
val NMHDR = cStruct3(cHWND, cUINT_PTR, cUint)
val (toMLNmhdr, fromMLNmhdr) = structAsAddr NMHDR
val CHARARRAY80 = cCHARARRAY 80
val NMTTDISPINFO =
cStruct6(NMHDR, cPointer (* String or resource id *), CHARARRAY80, cHINSTANCE, cUint, cLPARAM);
val (toMLNMTTDISPINFO, fromMLNMTTDISPINFO) = structAsAddr NMTTDISPINFO
in
fun compileNotification (from, idFrom, NM_OUTOFMEMORY) = fromMLNmhdr(from, idFrom, ~1)
| compileNotification (from, idFrom, NM_CLICK) = fromMLNmhdr(from, idFrom, ~2)
| compileNotification (from, idFrom, NM_DBLCLK) = fromMLNmhdr(from, idFrom, ~3)
| compileNotification (from, idFrom, NM_RETURN) = fromMLNmhdr(from, idFrom, ~4)
| compileNotification (from, idFrom, NM_RCLICK) = fromMLNmhdr(from, idFrom, ~5)
| compileNotification (from, idFrom, NM_RDBLCLK) = fromMLNmhdr(from, idFrom, ~6)
| compileNotification (from, idFrom, NM_SETFOCUS) = fromMLNmhdr(from, idFrom, ~7)
| compileNotification (from, idFrom, NM_KILLFOCUS) = fromMLNmhdr(from, idFrom, ~8)
| compileNotification (from, idFrom, NM_CUSTOMDRAW) = fromMLNmhdr(from, idFrom, ~12)
| compileNotification (from, idFrom, NM_HOVER) = fromMLNmhdr(from, idFrom, ~13)
| compileNotification (from, idFrom, NM_NCHITTEST) = fromMLNmhdr(from, idFrom, ~14)
| compileNotification (from, idFrom, NM_KEYDOWN) = fromMLNmhdr(from, idFrom, ~15)
| compileNotification (from, idFrom, NM_RELEASEDCAPTURE) = fromMLNmhdr(from, idFrom, ~16)
| compileNotification (from, idFrom, NM_SETCURSOR) = fromMLNmhdr(from, idFrom, ~17)
| compileNotification (from, idFrom, NM_CHAR) = fromMLNmhdr(from, idFrom, ~18)
| compileNotification (from, idFrom, NM_TOOLTIPSCREATED) = fromMLNmhdr(from, idFrom, ~19)
| compileNotification (from, idFrom, NM_LDOWN) = fromMLNmhdr(from, idFrom, ~20)
| compileNotification (from, idFrom, NM_RDOWN) = fromMLNmhdr(from, idFrom, ~21)
| compileNotification (from, idFrom, NM_THEMECHANGED) = fromMLNmhdr(from, idFrom, ~22)
| compileNotification (from, idFrom, LVN_ITEMCHANGING) = fromMLNmhdr(from, idFrom, ~100)
| compileNotification (from, idFrom, LVN_ITEMCHANGED) = fromMLNmhdr(from, idFrom, ~101)
| compileNotification (from, idFrom, LVN_INSERTITEM) = fromMLNmhdr(from, idFrom, ~102)
| compileNotification (from, idFrom, LVN_DELETEITEM) = fromMLNmhdr(from, idFrom, ~103)
| compileNotification (from, idFrom, LVN_DELETEALLITEMS) = fromMLNmhdr(from, idFrom, ~104)
| compileNotification (from, idFrom, LVN_BEGINLABELEDIT) = fromMLNmhdr(from, idFrom, ~105)
| compileNotification (from, idFrom, LVN_ENDLABELEDIT) = fromMLNmhdr(from, idFrom, ~106)
| compileNotification (from, idFrom, LVN_COLUMNCLICK) = fromMLNmhdr(from, idFrom, ~108)
| compileNotification (from, idFrom, LVN_BEGINDRAG) = fromMLNmhdr(from, idFrom, ~109)
| compileNotification (from, idFrom, LVN_BEGINRDRAG) = fromMLNmhdr(from, idFrom, ~111)
| compileNotification (from, idFrom, LVN_GETDISPINFO) = fromMLNmhdr(from, idFrom, ~150)
| compileNotification (from, idFrom, LVN_SETDISPINFO) = fromMLNmhdr(from, idFrom, ~151)
| compileNotification (from, idFrom, LVN_KEYDOWN) = fromMLNmhdr(from, idFrom, ~155)
| compileNotification (from, idFrom, LVN_GETINFOTIP) = fromMLNmhdr(from, idFrom, ~157)
| compileNotification (from, idFrom, HDN_ITEMCHANGING) = fromMLNmhdr(from, idFrom, ~300)
| compileNotification (from, idFrom, HDN_ITEMCHANGED) = fromMLNmhdr(from, idFrom, ~301)
| compileNotification (from, idFrom, HDN_ITEMCLICK) = fromMLNmhdr(from, idFrom, ~302)
| compileNotification (from, idFrom, HDN_ITEMDBLCLICK) = fromMLNmhdr(from, idFrom, ~303)
| compileNotification (from, idFrom, HDN_DIVIDERDBLCLICK) = fromMLNmhdr(from, idFrom, ~305)
| compileNotification (from, idFrom, HDN_BEGINTRACK) = fromMLNmhdr(from, idFrom, ~306)
| compileNotification (from, idFrom, HDN_ENDTRACK) = fromMLNmhdr(from, idFrom, ~307)
| compileNotification (from, idFrom, HDN_TRACK) = fromMLNmhdr(from, idFrom, ~308)
| compileNotification (from, idFrom, HDN_ENDDRAG) = fromMLNmhdr(from, idFrom, ~311)
| compileNotification (from, idFrom, HDN_BEGINDRAG) = fromMLNmhdr(from, idFrom, ~310)
| compileNotification (from, idFrom, HDN_GETDISPINFO) = fromMLNmhdr(from, idFrom, ~309)
| compileNotification (from, idFrom, TVN_SELCHANGING) = fromMLNmhdr(from, idFrom, ~401)
| compileNotification (from, idFrom, TVN_SELCHANGED) = fromMLNmhdr(from, idFrom, ~402)
| compileNotification (from, idFrom, TVN_GETDISPINFO) = fromMLNmhdr(from, idFrom, ~403)
| compileNotification (from, idFrom, TVN_SETDISPINFO) = fromMLNmhdr(from, idFrom, ~404)
| compileNotification (from, idFrom, TVN_ITEMEXPANDING) = fromMLNmhdr(from, idFrom, ~405)
| compileNotification (from, idFrom, TVN_ITEMEXPANDED) = fromMLNmhdr(from, idFrom, ~406)
| compileNotification (from, idFrom, TVN_BEGINDRAG) = fromMLNmhdr(from, idFrom, ~407)
| compileNotification (from, idFrom, TVN_BEGINRDRAG) = fromMLNmhdr(from, idFrom, ~408)
| compileNotification (from, idFrom, TVN_DELETEITEM) = fromMLNmhdr(from, idFrom, ~409)
| compileNotification (from, idFrom, TVN_BEGINLABELEDIT) = fromMLNmhdr(from, idFrom, ~410)
| compileNotification (from, idFrom, TVN_ENDLABELEDIT) = fromMLNmhdr(from, idFrom, ~411)
| compileNotification (from, idFrom, TVN_KEYDOWN) = fromMLNmhdr(from, idFrom, ~412)
| compileNotification (from, idFrom, TVN_GETINFOTIP) = fromMLNmhdr(from, idFrom, ~413)
| compileNotification (from, idFrom, TVN_SINGLEEXPAND) = fromMLNmhdr(from, idFrom, ~415)
| compileNotification (from, idFrom, TTN_GETDISPINFO(ref s)) =
fromMLNMTTDISPINFO((from, idFrom, ~520), Memory.null, s, Globals.hNull, 0, 0)
| compileNotification (from, idFrom, TTN_SHOW) = fromMLNmhdr(from, idFrom, ~521)
| compileNotification (from, idFrom, TTN_POP) = fromMLNmhdr(from, idFrom, ~522)
| compileNotification (from, idFrom, TCN_KEYDOWN) = fromMLNmhdr(from, idFrom, ~550)
| compileNotification (from, idFrom, TCN_SELCHANGE) = fromMLNmhdr(from, idFrom, ~551)
| compileNotification (from, idFrom, TCN_SELCHANGING) = fromMLNmhdr(from, idFrom, ~552)
| compileNotification (from, idFrom, TBN_GETBUTTONINFO) = fromMLNmhdr(from, idFrom, ~700)
| compileNotification (from, idFrom, TBN_BEGINDRAG) = fromMLNmhdr(from, idFrom, ~701)
| compileNotification (from, idFrom, TBN_ENDDRAG) = fromMLNmhdr(from, idFrom, ~702)
| compileNotification (from, idFrom, TBN_BEGINADJUST) = fromMLNmhdr(from, idFrom, ~703)
| compileNotification (from, idFrom, TBN_ENDADJUST) = fromMLNmhdr(from, idFrom, ~704)
| compileNotification (from, idFrom, TBN_RESET) = fromMLNmhdr(from, idFrom, ~705)
| compileNotification (from, idFrom, TBN_QUERYINSERT) = fromMLNmhdr(from, idFrom, ~706)
| compileNotification (from, idFrom, TBN_QUERYDELETE) = fromMLNmhdr(from, idFrom, ~707)
| compileNotification (from, idFrom, TBN_TOOLBARCHANGE) = fromMLNmhdr(from, idFrom, ~708)
| compileNotification (from, idFrom, TBN_CUSTHELP) = fromMLNmhdr(from, idFrom, ~709)
| compileNotification (from, idFrom, TBN_DROPDOWN) = fromMLNmhdr(from, idFrom, ~710)
| compileNotification (from, idFrom, TBN_HOTITEMCHANGE) = fromMLNmhdr(from, idFrom, ~713)
| compileNotification (from, idFrom, TBN_DRAGOUT) = fromMLNmhdr(from, idFrom, ~714)
| compileNotification (from, idFrom, TBN_DELETINGBUTTON) = fromMLNmhdr(from, idFrom, ~715)
| compileNotification (from, idFrom, TBN_GETDISPINFO) = fromMLNmhdr(from, idFrom, ~716)
| compileNotification (from, idFrom, TBN_GETINFOTIP) = fromMLNmhdr(from, idFrom, ~718)
| compileNotification (from, idFrom, UDN_DELTAPOS) = fromMLNmhdr(from, idFrom, ~722)
| compileNotification (from, idFrom, RBN_GETOBJECT) = fromMLNmhdr(from, idFrom, ~832)
| compileNotification (from, idFrom, RBN_LAYOUTCHANGED) = fromMLNmhdr(from, idFrom, ~833)
| compileNotification (from, idFrom, RBN_AUTOSIZE) = fromMLNmhdr(from, idFrom, ~834)
| compileNotification (from, idFrom, RBN_BEGINDRAG) = fromMLNmhdr(from, idFrom, ~835)
| compileNotification (from, idFrom, RBN_ENDDRAG) = fromMLNmhdr(from, idFrom, ~836)
| compileNotification (from, idFrom, RBN_DELETINGBAND) = fromMLNmhdr(from, idFrom, ~837)
| compileNotification (from, idFrom, RBN_DELETEDBAND) = fromMLNmhdr(from, idFrom, ~838)
| compileNotification (from, idFrom, RBN_CHILDSIZE) = fromMLNmhdr(from, idFrom, ~839)
| compileNotification (from, idFrom, CBEN_GETDISPINFO) = fromMLNmhdr(from, idFrom, ~800)
| compileNotification (from, idFrom, CBEN_DRAGBEGIN) = fromMLNmhdr(from, idFrom, ~808)
| compileNotification (from, idFrom, IPN_FIELDCHANGED) = fromMLNmhdr(from, idFrom, ~860)
| compileNotification (from, idFrom, SBN_SIMPLEMODECHANGE) = fromMLNmhdr(from, idFrom, ~880)
| compileNotification (from, idFrom, PGN_SCROLL) = fromMLNmhdr(from, idFrom, ~901)
| compileNotification (from, idFrom, PGN_CALCSIZE) = fromMLNmhdr(from, idFrom, ~902)
| compileNotification (from, idFrom, NM_OTHER code) = fromMLNmhdr(from, idFrom, code)
local
fun decompileNotifyArg (_, ~1) = NM_OUTOFMEMORY
| decompileNotifyArg (_, ~2) = NM_CLICK
| decompileNotifyArg (_, ~3) = NM_DBLCLK
| decompileNotifyArg (_, ~4) = NM_RETURN
| decompileNotifyArg (_, ~5) = NM_RCLICK
| decompileNotifyArg (_, ~6) = NM_RDBLCLK
| decompileNotifyArg (_, ~7) = NM_SETFOCUS
| decompileNotifyArg (_, ~8) = NM_KILLFOCUS
| decompileNotifyArg (_, ~12) = NM_CUSTOMDRAW
| decompileNotifyArg (_, ~13) = NM_HOVER
| decompileNotifyArg (_, ~14) = NM_NCHITTEST
| decompileNotifyArg (_, ~15) = NM_KEYDOWN
| decompileNotifyArg (_, ~16) = NM_RELEASEDCAPTURE
| decompileNotifyArg (_, ~17) = NM_SETCURSOR
| decompileNotifyArg (_, ~18) = NM_CHAR
| decompileNotifyArg (_, ~19) = NM_TOOLTIPSCREATED
| decompileNotifyArg (_, ~20) = NM_LDOWN
| decompileNotifyArg (_, ~21) = NM_RDOWN
| decompileNotifyArg (_, ~22) = NM_THEMECHANGED
| decompileNotifyArg (_, ~100) = LVN_ITEMCHANGING
| decompileNotifyArg (_, ~101) = LVN_ITEMCHANGED
| decompileNotifyArg (_, ~102) = LVN_INSERTITEM
| decompileNotifyArg (_, ~103) = LVN_DELETEITEM
| decompileNotifyArg (_, ~104) = LVN_DELETEALLITEMS
| decompileNotifyArg (_, ~105) = LVN_BEGINLABELEDIT
| decompileNotifyArg (_, ~106) = LVN_ENDLABELEDIT
| decompileNotifyArg (_, ~108) = LVN_COLUMNCLICK
| decompileNotifyArg (_, ~109) = LVN_BEGINDRAG
| decompileNotifyArg (_, ~111) = LVN_BEGINRDRAG
| decompileNotifyArg (_, ~150) = LVN_GETDISPINFO
| decompileNotifyArg (_, ~151) = LVN_SETDISPINFO
| decompileNotifyArg (_, ~155) = LVN_KEYDOWN
| decompileNotifyArg (_, ~157) = LVN_GETINFOTIP
| decompileNotifyArg (_, ~300) = HDN_ITEMCHANGING
| decompileNotifyArg (_, ~301) = HDN_ITEMCHANGED
| decompileNotifyArg (_, ~302) = HDN_ITEMCLICK
| decompileNotifyArg (_, ~303) = HDN_ITEMDBLCLICK
| decompileNotifyArg (_, ~305) = HDN_DIVIDERDBLCLICK
| decompileNotifyArg (_, ~306) = HDN_BEGINTRACK
| decompileNotifyArg (_, ~307) = HDN_ENDTRACK
| decompileNotifyArg (_, ~308) = HDN_TRACK
| decompileNotifyArg (_, ~311) = HDN_ENDDRAG
| decompileNotifyArg (_, ~310) = HDN_BEGINDRAG
| decompileNotifyArg (_, ~309) = HDN_GETDISPINFO
| decompileNotifyArg (_, ~401) = TVN_SELCHANGING
| decompileNotifyArg (_, ~402) = TVN_SELCHANGED
| decompileNotifyArg (_, ~403) = TVN_GETDISPINFO
| decompileNotifyArg (_, ~404) = TVN_SETDISPINFO
| decompileNotifyArg (_, ~405) = TVN_ITEMEXPANDING
| decompileNotifyArg (_, ~406) = TVN_ITEMEXPANDED
| decompileNotifyArg (_, ~407) = TVN_BEGINDRAG
| decompileNotifyArg (_, ~408) = TVN_BEGINRDRAG
| decompileNotifyArg (_, ~409) = TVN_DELETEITEM
| decompileNotifyArg (_, ~410) = TVN_BEGINLABELEDIT
| decompileNotifyArg (_, ~411) = TVN_ENDLABELEDIT
| decompileNotifyArg (_, ~412) = TVN_KEYDOWN
| decompileNotifyArg (_, ~413) = TVN_GETINFOTIP
| decompileNotifyArg (_, ~415) = TVN_SINGLEEXPAND
| decompileNotifyArg (lp, ~520) =
let
val nmt = toMLNMTTDISPINFO lp
(* Just look at the byte data at the moment. *)
in
TTN_GETDISPINFO(ref(#3 nmt))
end
| decompileNotifyArg (_, ~521) = TTN_SHOW
| decompileNotifyArg (_, ~522) = TTN_POP
| decompileNotifyArg (_, ~550) = TCN_KEYDOWN
| decompileNotifyArg (_, ~551) = TCN_SELCHANGE
| decompileNotifyArg (_, ~552) = TCN_SELCHANGING
| decompileNotifyArg (_, ~700) = TBN_GETBUTTONINFO
| decompileNotifyArg (_, ~701) = TBN_BEGINDRAG
| decompileNotifyArg (_, ~702) = TBN_ENDDRAG
| decompileNotifyArg (_, ~703) = TBN_BEGINADJUST
| decompileNotifyArg (_, ~704) = TBN_ENDADJUST
| decompileNotifyArg (_, ~705) = TBN_RESET
| decompileNotifyArg (_, ~706) = TBN_QUERYINSERT
| decompileNotifyArg (_, ~707) = TBN_QUERYDELETE
| decompileNotifyArg (_, ~708) = TBN_TOOLBARCHANGE
| decompileNotifyArg (_, ~709) = TBN_CUSTHELP
| decompileNotifyArg (_, ~710) = TBN_DROPDOWN
| decompileNotifyArg (_, ~713) = TBN_HOTITEMCHANGE
| decompileNotifyArg (_, ~714) = TBN_DRAGOUT
| decompileNotifyArg (_, ~715) = TBN_DELETINGBUTTON
| decompileNotifyArg (_, ~716) = TBN_GETDISPINFO
| decompileNotifyArg (_, ~718) = TBN_GETINFOTIP (*<<<*)
| decompileNotifyArg (_, ~722) = UDN_DELTAPOS
| decompileNotifyArg (_, ~832) = RBN_GETOBJECT
| decompileNotifyArg (_, ~833) = RBN_LAYOUTCHANGED
| decompileNotifyArg (_, ~834) = RBN_AUTOSIZE
| decompileNotifyArg (_, ~835) = RBN_BEGINDRAG
| decompileNotifyArg (_, ~836) = RBN_ENDDRAG
| decompileNotifyArg (_, ~837) = RBN_DELETINGBAND
| decompileNotifyArg (_, ~838) = RBN_DELETEDBAND
| decompileNotifyArg (_, ~839) = RBN_CHILDSIZE
| decompileNotifyArg (_, ~800) = CBEN_GETDISPINFO
| decompileNotifyArg (_, ~808) = CBEN_DRAGBEGIN
| decompileNotifyArg (_, ~860) = IPN_FIELDCHANGED
| decompileNotifyArg (_, ~880) = SBN_SIMPLEMODECHANGE
| decompileNotifyArg (_, ~901) = PGN_SCROLL
| decompileNotifyArg (_, ~902) = PGN_CALCSIZE
| decompileNotifyArg (_, code) = NM_OTHER code
in
fun decompileNotify {wp, lp} =
let
val (hwndFrom, idFrom, code) = toMLNmhdr lp
val notification = decompileNotifyArg (lp, code)
in
{ idCtrl = SysWord.toInt wp, from = hwndFrom, idFrom = idFrom, notification = notification}
end
end
end
local
val cFINDREPLACE =
cStruct11(cDWORD, cHWND, cHINSTANCE, FindReplaceFlags.cFindReplaceFlags, cString, cString,
cWORD, cWORD, cPointer, cPointer, cPointer)
val {load=loadFindReplace, store=storeFindReplace, ctype={size=sizeFindReplace, ...}, ...} =
breakConversion cFINDREPLACE
type findMsg = { flags: FindReplaceFlags.flags, findWhat: string, replaceWith: string }
in
fun compileFindMsg({flags, findWhat, replaceWith}: findMsg) =
let
open Memory
val vec = malloc sizeFindReplace
(* Is this right? It's supposed to create a buffer to store the result. *)
val freeFR =
storeFindReplace(vec,
(Word.toInt sizeFindReplace, hNull, hNull, flags,
findWhat, replaceWith, 0, 0, null, null, null))
in
(RegisterMessage "commdlg_FindReplace", 0w0, fromAddr vec, fn() => (freeFR(); free vec))
end
fun decompileFindMsg{wp=_, lp}: findMsg =
let
val (_, _, _, flags, findwhat, replace, _, _, _, _, _) =
loadFindReplace(toAddr lp)
(* The argument is really a FINDREPLACE struct. *)
in
{flags=flags, findWhat=findwhat, replaceWith=replace}
end
end
val toHMENU: SysWord.word -> HMENU = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHMENU: HMENU -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHWND: SysWord.word -> HWND = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHWND: HWND -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHDC: SysWord.word -> HDC = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHDC: HDC -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHFONT: SysWord.word -> HFONT = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHFONT: HFONT -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHRGN: SysWord.word -> HRGN = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHRGN: HRGN -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHDROP: SysWord.word -> HDROP = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHDROP: HDROP -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHICON: SysWord.word -> HICON = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHICON: HICON -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
val toHGDIOBJ: SysWord.word -> HGDIOBJ = handleOfVoidStar o Memory.sysWord2VoidStar
and fromHGDIOBJ: HGDIOBJ -> SysWord.word = Memory.voidStar2Sysword o voidStarOfHandle
(* Maybe we should have two different types for horizontal and vertical. *)
datatype ScrollDirection =
SB_BOTTOM | SB_ENDSCROLL | SB_LINEDOWN | SB_LINEUP | SB_PAGEDOWN | SB_PAGEUP |
SB_THUMBPOSITION | SB_THUMBTRACK | SB_TOP | SB_LEFT | SB_RIGHT | SB_LINELEFT |
SB_LINERIGHT | SB_PAGELEFT | SB_PAGERIGHT
local
val tab = [
(SB_LINEUP, 0w0: word),
(SB_LINELEFT, 0w0),
(SB_LINEDOWN, 0w1),
(SB_LINERIGHT, 0w1),
(SB_PAGEUP, 0w2),
(SB_PAGELEFT, 0w2),
(SB_PAGEDOWN, 0w3),
(SB_PAGERIGHT, 0w3),
(SB_THUMBPOSITION, 0w4),
(SB_THUMBTRACK, 0w5),
(SB_TOP, 0w6),
(SB_LEFT, 0w6),
(SB_BOTTOM, 0w7),
(SB_RIGHT, 0w7),
(SB_ENDSCROLL, 0w8)
]
in
val (toCsd, fromCsd) = tableLookup(tab, NONE)
end
(* This is a bit of a mess. Various operations take or return handles to
these types of image and also take this value as a parameter. *)
datatype ImageType = IMAGE_BITMAP | IMAGE_CURSOR | IMAGE_ENHMETAFILE | IMAGE_ICON
local
val tab = [
(IMAGE_BITMAP, 0),
(IMAGE_ICON, 1),
(IMAGE_CURSOR, 2),
(IMAGE_ENHMETAFILE, 3)
]
in
val (toCit, fromCit) = tableLookup(tab, NONE)
end
val (toCcbf, fromCcbf) = clipLookup
datatype MouseKeyFlags = MK_LBUTTON | MK_RBUTTON | MK_SHIFT | MK_CONTROL | MK_MBUTTON
local
val tab = [
(MK_LBUTTON, 0wx0001),
(MK_RBUTTON, 0wx0002),
(MK_SHIFT, 0wx0004),
(MK_CONTROL, 0wx0008),
(MK_MBUTTON, 0wx0010)
]
in
val (toCmkf, fromCmkf) = tableSetLookup(tab, NONE)
end
datatype MDITileFlags = MDITILE_VERTICAL | MDITILE_HORIZONTAL | MDITILE_SKIPDISABLED
local
val tab = [
(MDITILE_VERTICAL, 0wx0000),
(MDITILE_HORIZONTAL, 0wx0001),
(MDITILE_SKIPDISABLED, 0wx0002)
]
in
val (toCmdif, fromCmdif) = tableSetLookup(tab, NONE)
end
datatype WMPrintOption =
PRF_CHECKVISIBLE | PRF_NONCLIENT | PRF_CLIENT | PRF_ERASEBKGND |
PRF_CHILDREN | PRF_OWNED
local
val tab = [
(PRF_CHECKVISIBLE, 0wx00000001),
(PRF_NONCLIENT, 0wx00000002),
(PRF_CLIENT, 0wx00000004),
(PRF_ERASEBKGND, 0wx00000008),
(PRF_CHILDREN, 0wx00000010),
(PRF_OWNED, 0wx00000020)
]
in
val (toCwmpl, fromCwmpl) = tableSetLookup(tab, NONE)
end
val (toCcbal, fromCcbal) = ComboBase.CBDIRATTRS
val (toCesbf, fromCesbf) = ScrollBase.ENABLESCROLLBARFLAG
(*fun itob i = i <> 0*)
(* These deal with signed quantities. LOWORD/HIWORD deal with words *)
local
val shift32 = Word.fromInt(SysWord.wordSize-32)
and shift16 = Word.fromInt(SysWord.wordSize-16)
open SysWord
infix 5 << ~>>
infix 7 andb
infix 6 orb
(* Y is the high order word, X is the low order word. *)
in
fun getYLParam (i: SysWord.word) = toIntX((i << shift32) ~>> shift16)
and getXLParam (i: SysWord.word) = toIntX((i << shift16) ~>> shift16)
fun makeXYParam (x, y) = ((fromInt y andb 0wxffff) << 0w16) orb (fromInt x andb 0wxffff)
end
in
type flags = WinBase.Style.flags
and WindowPositionStyle = WinBase.WindowPositionStyle
datatype ControlType = datatype ControlType
datatype ScrollDirection = datatype ScrollDirection
datatype HitTest =
HTBORDER
| HTBOTTOM
| HTBOTTOMLEFT
| HTBOTTOMRIGHT
| HTCAPTION
| HTCLIENT
| HTCLOSE
| HTERROR
| HTGROWBOX
| HTHELP
| HTHSCROLL
| HTLEFT
| HTMENU
| HTMAXBUTTON
| HTMINBUTTON
| HTNOWHERE
| HTREDUCE
| HTRIGHT
| HTSIZE
| HTSYSMENU
| HTTOP
| HTTOPLEFT
| HTTOPRIGHT
| HTTRANSPARENT
| HTVSCROLL
| HTZOOM
datatype LRESULT =
LRESINT of int
| LRESHANDLE of HGDIOBJ
datatype ImageType = datatype ImageType
(* WM_SIZE options. *)
datatype WMSizeOptions =
SIZE_RESTORED | SIZE_MINIMIZED | SIZE_MAXIMIZED | SIZE_MAXSHOW | SIZE_MAXHIDE
local
val tab = [
(SIZE_RESTORED, 0w0: SysWord.word),
(SIZE_MINIMIZED, 0w1),
(SIZE_MAXIMIZED, 0w2),
(SIZE_MAXSHOW, 0w3),
(SIZE_MAXHIDE, 0w4)
]
in
val (fromWMSizeOpt, toWMSizeOpt) = tableLookup(tab, NONE)
end
(* WM_ACTIVATE options *)
datatype WMActivateOptions = WA_INACTIVE | WA_ACTIVE | WA_CLICKACTIVE
local
val
tab = [
(WA_INACTIVE, 0w0: word),
(WA_ACTIVE, 0w1),
(WA_CLICKACTIVE, 0w2)
]
in
val (fromWMactive, toWMactive) = tableLookup(tab, NONE)
end
datatype SystemCommand =
SC_SIZE | SC_MOVE | SC_MINIMIZE | SC_MAXIMIZE | SC_NEXTWINDOW | SC_PREVWINDOW |
SC_CLOSE | SC_VSCROLL | SC_HSCROLL | SC_MOUSEMENU | SC_KEYMENU | SC_ARRANGE |
SC_RESTORE | SC_TASKLIST | SC_SCREENSAVE | SC_HOTKEY | SC_DEFAULT |
SC_MONITORPOWER | SC_CONTEXTHELP | SC_SEPARATOR
local
val tab = [
(SC_SIZE, 0xF000),
(SC_MOVE, 0xF010),
(SC_MINIMIZE, 0xF020),
(SC_MAXIMIZE, 0xF030),
(SC_NEXTWINDOW, 0xF040),
(SC_PREVWINDOW, 0xF050),
(SC_CLOSE, 0xF060),
(SC_VSCROLL, 0xF070),
(SC_HSCROLL, 0xF080),
(SC_MOUSEMENU, 0xF090),
(SC_KEYMENU, 0xF100),
(SC_ARRANGE, 0xF110),
(SC_RESTORE, 0xF120),
(SC_TASKLIST, 0xF130),
(SC_SCREENSAVE, 0xF140),
(SC_HOTKEY, 0xF150),
(SC_DEFAULT, 0xF160),
(SC_MONITORPOWER, 0xF170),
(SC_CONTEXTHELP, 0xF180)]
in
val (fromSysCommand, toSysCommand) = tableLookup(tab, NONE)
end
datatype EMCharFromPos =
EMcfpEdit of POINT
| EMcfpRichEdit of POINT
| EMcfpUnknown of SysWord.word
datatype WMPrintOption = datatype WMPrintOption
(* Parameters to EM_SETMARGINS. *)
datatype MarginSettings =
UseFontInfo | Margins of {left: int option, right: int option }
datatype MouseKeyFlags = datatype MouseKeyFlags
datatype MDITileFlags = datatype MDITileFlags
(* TODO: Perhaps use a record for this. It's always possible to use