1(*
2    Copyright (c) 2001-7, 2015
3        David C.J. Matthews
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License version 2.1 as published by the Free Software Foundation.
8    
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13    
14    You should have received a copy of the GNU Lesser General Public
15    License along with this library; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17*)
18
19signature MESSAGE =
20sig
21    datatype ControlType =
22          ODT_BUTTON
23        | ODT_COMBOBOX
24        | ODT_LISTBOX
25        | ODT_MENU
26        | ODT_STATIC
27    datatype ImageType =
28          IMAGE_BITMAP
29        | IMAGE_CURSOR
30        | IMAGE_ENHMETAFILE
31        | IMAGE_ICON
32
33    type HGDIOBJ and HWND and HMENU and HICON and HINSTANCE and HDC
34    and HFONT and HRGN and HDROP
35    type RECT =  { left: int, top: int, right: int, bottom: int }
36    type POINT = { x: int, y: int }
37
38    datatype HitTest =
39        HTBORDER
40    |   HTBOTTOM
41    |   HTBOTTOMLEFT
42    |   HTBOTTOMRIGHT
43    |   HTCAPTION
44    |   HTCLIENT
45    |   HTCLOSE
46    |   HTERROR
47    |   HTGROWBOX
48    |   HTHELP
49    |   HTHSCROLL
50    |   HTLEFT
51    |   HTMENU
52    |   HTMAXBUTTON
53    |   HTMINBUTTON
54    |   HTNOWHERE
55    |   HTREDUCE
56    |   HTRIGHT
57    |   HTSIZE
58    |   HTSYSMENU
59    |   HTTOP
60    |   HTTOPLEFT
61    |   HTTOPRIGHT
62    |   HTTRANSPARENT
63    |   HTVSCROLL
64    |   HTZOOM
65
66    datatype LRESULT =
67        LRESINT of int
68    |   LRESHANDLE of HGDIOBJ
69
70    type KeyData
71    type windowFlags and findReplaceFlags
72    datatype ScrollDirection =
73          SB_BOTTOM
74        | SB_ENDSCROLL
75        | SB_LEFT
76        | SB_LINEDOWN
77        | SB_LINELEFT
78        | SB_LINERIGHT
79        | SB_LINEUP
80        | SB_PAGEDOWN
81        | SB_PAGELEFT
82        | SB_PAGERIGHT
83        | SB_PAGEUP
84        | SB_RIGHT
85        | SB_THUMBPOSITION
86        | SB_THUMBTRACK
87        | SB_TOP
88
89    type WindowPositionStyle
90    
91    datatype MouseKeyFlags = MK_LBUTTON | MK_RBUTTON | MK_SHIFT | MK_CONTROL | MK_MBUTTON
92
93    type ClipboardFormat and ClassType 
94
95    datatype MarginSettings = 
96        UseFontInfo | Margins of {left: int option, right: int option }
97
98    datatype MDITileFlags = MDITILE_VERTICAL | MDITILE_HORIZONTAL | MDITILE_SKIPDISABLED
99
100    datatype EMCharFromPos =
101        EMcfpEdit of POINT
102    |   EMcfpRichEdit of POINT
103    |   EMcfpUnknown of SysWord.word
104
105    datatype SystemCommand =
106        SC_ARRANGE
107    |   SC_CLOSE
108    |   SC_CONTEXTHELP
109    |   SC_DEFAULT
110    |   SC_HOTKEY
111    |   SC_HSCROLL
112    |   SC_KEYMENU
113    |   SC_MAXIMIZE
114    |   SC_MINIMIZE
115    |   SC_MONITORPOWER
116    |   SC_MOUSEMENU
117    |   SC_MOVE
118    |   SC_NEXTWINDOW
119    |   SC_PREVWINDOW
120    |   SC_RESTORE
121    |   SC_SCREENSAVE
122    |   SC_SEPARATOR
123    |   SC_SIZE
124    |   SC_TASKLIST
125    |   SC_VSCROLL
126
127    datatype WMActivateOptions = WA_ACTIVE | WA_CLICKACTIVE | WA_INACTIVE
128
129    datatype
130      WMPrintOption =
131          PRF_CHECKVISIBLE
132        | PRF_CHILDREN
133        | PRF_CLIENT
134        | PRF_ERASEBKGND
135        | PRF_NONCLIENT
136        | PRF_OWNED
137
138    datatype WMSizeOptions =
139        SIZE_MAXHIDE | SIZE_MAXIMIZED | SIZE_MAXSHOW | SIZE_MINIMIZED | SIZE_RESTORED
140    datatype HelpHandle = MenuHandle of HMENU | WindowHandle of HWND
141     
142    (* Passed in the lpParam argument of a WM_NOTIFY message.
143       TODO: Many of these have additional information. *)
144    datatype Notification =
145        NM_OUTOFMEMORY
146    |   NM_CLICK
147    |   NM_DBLCLK
148    |   NM_RETURN
149    |   NM_RCLICK
150    |   NM_RDBLCLK
151    |   NM_SETFOCUS
152    |   NM_KILLFOCUS
153    |   NM_CUSTOMDRAW
154    |   NM_HOVER
155    |   NM_NCHITTEST
156    |   NM_KEYDOWN
157    |   NM_RELEASEDCAPTURE
158    |   NM_SETCURSOR
159    |   NM_CHAR
160    |   NM_TOOLTIPSCREATED
161    |   NM_LDOWN
162    |   NM_RDOWN
163    |   NM_THEMECHANGED
164    |   LVN_ITEMCHANGING
165    |   LVN_ITEMCHANGED
166    |   LVN_INSERTITEM
167    |   LVN_DELETEITEM
168    |   LVN_DELETEALLITEMS
169    |   LVN_BEGINLABELEDIT
170    |   LVN_ENDLABELEDIT
171    |   LVN_COLUMNCLICK
172    |   LVN_BEGINDRAG
173    |   LVN_BEGINRDRAG
174    |   LVN_GETDISPINFO
175    |   LVN_SETDISPINFO
176    |   LVN_KEYDOWN
177    |   LVN_GETINFOTIP
178    |   HDN_ITEMCHANGING
179    |   HDN_ITEMCHANGED
180    |   HDN_ITEMCLICK
181    |   HDN_ITEMDBLCLICK
182    |   HDN_DIVIDERDBLCLICK
183    |   HDN_BEGINTRACK
184    |   HDN_ENDTRACK
185    |   HDN_TRACK
186    |   HDN_ENDDRAG
187    |   HDN_BEGINDRAG
188    |   HDN_GETDISPINFO
189    |   TVN_SELCHANGING
190    |   TVN_SELCHANGED
191    |   TVN_GETDISPINFO
192    |   TVN_SETDISPINFO
193    |   TVN_ITEMEXPANDING
194    |   TVN_ITEMEXPANDED
195    |   TVN_BEGINDRAG
196    |   TVN_BEGINRDRAG
197    |   TVN_DELETEITEM
198    |   TVN_BEGINLABELEDIT
199    |   TVN_ENDLABELEDIT
200    |   TVN_KEYDOWN
201    |   TVN_GETINFOTIP
202    |   TVN_SINGLEEXPAND
203    |   TTN_GETDISPINFO of string ref
204    |   TTN_SHOW
205    |   TTN_POP
206    |   TCN_KEYDOWN
207    |   TCN_SELCHANGE
208    |   TCN_SELCHANGING
209    |   TBN_GETBUTTONINFO
210    |   TBN_BEGINDRAG
211    |   TBN_ENDDRAG
212    |   TBN_BEGINADJUST
213    |   TBN_ENDADJUST
214    |   TBN_RESET
215    |   TBN_QUERYINSERT
216    |   TBN_QUERYDELETE
217    |   TBN_TOOLBARCHANGE
218    |   TBN_CUSTHELP
219    |   TBN_DROPDOWN
220    |   TBN_HOTITEMCHANGE
221    |   TBN_DRAGOUT
222    |   TBN_DELETINGBUTTON
223    |   TBN_GETDISPINFO
224    |   TBN_GETINFOTIP
225    |   UDN_DELTAPOS
226    |   RBN_GETOBJECT
227    |   RBN_LAYOUTCHANGED
228    |   RBN_AUTOSIZE
229    |   RBN_BEGINDRAG
230    |   RBN_ENDDRAG
231    |   RBN_DELETINGBAND
232    |   RBN_DELETEDBAND
233    |   RBN_CHILDSIZE
234    |   CBEN_GETDISPINFO
235    |   CBEN_DRAGBEGIN
236    |   IPN_FIELDCHANGED
237    |   SBN_SIMPLEMODECHANGE
238    |   PGN_SCROLL
239    |   PGN_CALCSIZE
240    |   NM_OTHER of int (* Catch-all for other cases. *)
241
242    datatype Message     =
243        WM_NULL
244
245    |   WM_ACTIVATE of {active: WMActivateOptions, minimize: bool }
246              (* Indicates a change in activation state *)
247
248    |   WM_ACTIVATEAPP of {active: bool, threadid: int  } 
249      (* Notifies applications when a new task activates *)
250
251    |   WM_ASKCBFORMATNAME of { length: int, formatName: string ref} 
252      (* Retrieves the name of the clipboard format *)
253
254    |   WM_CANCELJOURNAL  
255      (* Notifies application when user cancels journaling *)
256
257    |   WM_CANCELMODE 
258      (* Notifies a Window to cancel internal modes *)
259
260    |   WM_CHANGECBCHAIN of { removed: HWND, next: HWND  }  
261      (* Notifies clipboard viewer of removal from chain *)
262
263    |   WM_CHAR of {charCode: char, data: KeyData }                     
264      (* Indicates the user pressed a character key *)
265
266    |   WM_CHARTOITEM of {key: int, caretpos: int, listbox: HWND  }
267      (* Provides list-box keystrokes to owner Window *)
268
269    |   WM_CHILDACTIVATE  
270      (* Notifies a child Window of activation *)
271
272    (* This is WM_USER+1.  It's only used in a GetFont dialogue box.
273    |   WM_CHOOSEFONT_GETLOGFONT of LOGFONT ref *)
274      (* Retrieves LOGFONT structure for Font dialog box *)
275
276    |   WM_CLEAR
277      (* Clears an edit control *)
278
279    |   WM_CLOSE      
280      (* System Close menu command was chosen *)
281
282    |   WM_COMMAND of {notifyCode: int, wId: int, control: HWND }
283      (* Specifies a command message *)
284
285    |   WM_COMPAREITEM of (* Determines position of combo- or list-box item *)
286        {
287            controlid: int, ctlType: ControlType, ctlID: int, hItem: HWND,
288            itemID1: int, itemData1: SysWord.word, itemID2: int, itemData2: SysWord.word                                        
289        }
290
291    |   WM_COPY (* Copies a selection to the clipboard *)
292
293    |   WM_CREATE of
294        { instance: HINSTANCE, creation: Foreign.Memory.voidStar, menu: HMENU, parent: HWND, cy: int, cx: int,
295          y: int, x: int, style: windowFlags, name: string, (* The class may be a string or an atom. *)
296          class: ClassType, extendedstyle: int }
297      (* Indicates a Window is being created *)
298
299    |   WM_CTLCOLORBTN of { displaycontext: HDC, button: HWND }
300      (* Button is about to be drawn *)
301
302    |   WM_CTLCOLORDLG of { displaycontext: HDC, dialogbox: HWND  }
303      (* Dialog box is about to be drawn *)
304
305    |   WM_CTLCOLOREDIT of {  displaycontext: HDC, editcontrol: HWND  }
306      (* Control is about to be drawn *)
307
308    |   WM_CTLCOLORLISTBOX of { displaycontext: HDC, listbox: HWND   }
309      (* List box is about to be drawn *)
310
311    |   WM_CTLCOLORMSGBOX of { displaycontext: HDC, messagebox: HWND  }
312      (* Message box is about to be drawn *)
313
314    |   WM_CTLCOLORSCROLLBAR of { displaycontext: HDC, scrollbar: HWND  }
315      (* Indicates scroll bar is about to be drawn *)
316
317    |   WM_CTLCOLORSTATIC of { displaycontext: HDC, staticcontrol: HWND }
318      (* Control is about to be drawn *)
319      (* Note the return value is an HBRUSH *)
320
321    |   WM_CUT
322      (* Deletes a selection and copies it to the clipboard *)
323
324    |   WM_DEADCHAR of { charCode: char, data: KeyData }
325      (* Indicates the user pressed a dead key *)
326
327    |   WM_DELETEITEM of { senderId: int, ctlType: ControlType, ctlID: int, itemID: int, item: HWND, itemData: int }
328      (* Indicates owner-draw item or control was altered *)
329
330    |   WM_DESTROY    
331      (* Indicates Window is about to be destroyed *)
332
333    |   WM_DESTROYCLIPBOARD   
334      (* Notifies owner that the clipboard was emptied *)
335
336    |   WM_DEVMODECHANGE of { devicename: string }   
337      (* Indicates the device-mode settings have changed *)
338
339    |   WM_DRAWCLIPBOARD  
340      (* Indicates the clipboard's contents have changed *) 
341
342    |   WM_DRAWITEM of
343            { senderId: int, ctlType: ControlType, ctlID: int, itemID: int, itemAction: int,
344              itemState: int, hItem: HWND , hDC: HDC, rcItem: RECT, itemData: int }   
345      (* Indicates owner-draw control/menu needs redrawing *) 
346
347    |   WM_DROPFILES of { hDrop: HDROP } 
348      (* Indicates that a file has been dropped *)
349
350    |   WM_ENABLE of { enabled: bool }
351      (* Indicates a Window's enable state is changing *)
352
353    |   WM_ENDSESSION of { endsession: bool }
354      (* Indicates whether the Windows session is ending *)
355
356    |   WM_ENTERIDLE of { flag: int, window: HWND }
357      (* Indicates a modal dialog box or menu is idle *)
358
359    |   WM_ENTERMENULOOP of { istrack: bool }
360      (* Indicates entry into menu modal loop *)
361
362    |   WM_EXITMENULOOP of { istrack: bool }
363      (* Indicates exit from menu modal loop *)
364
365    |   WM_ERASEBKGND of { devicecontext: HDC }
366      (* Indicates a Window's background need erasing *)
367
368    |   WM_FONTCHANGE
369      (* Indicates a change in the font-resource pool *)
370
371    |   WM_GETDLGCODE
372      (* Allows dialog procedure to process control input
373         TODO: This has parameters! *)
374
375    |   WM_GETFONT    
376      (* Retrieves the font that a control is using *)
377
378    |   WM_GETHOTKEY
379      (* Gets the virtual-key code of a Window's hot key *) 
380
381    |   WM_GETMINMAXINFO of
382         { maxSize: POINT ref, maxPosition: POINT ref,
383           minTrackSize: POINT ref, maxTrackSize: POINT ref }
384      (* Gets minimum and maximum sizing information *)
385
386    |   WM_GETTEXT of { length: int, text: string ref  } 
387      (* Gets the text that corresponds to a Window *)
388
389    |   WM_GETTEXTLENGTH  
390      (* Gets length of text associated with a Window *)
391
392    |   WM_HOTKEY of { id: int }
393      (* Hot key has been detected *)
394
395    |   WM_HSCROLL of { value: ScrollDirection, position: int, scrollbar: HWND  }    
396      (* Indicates a click in a horizontal scroll bar *)
397
398    |   WM_HSCROLLCLIPBOARD of { viewer: HWND, code: int, position: int  }    
399      (* Prompts owner to scroll clipboard contents *)
400
401    |   WM_ICONERASEBKGND of { devicecontext: HDC }
402      (* Notifies minimized Window to fill icon background *)
403
404    |   WM_INITDIALOG of { dialog: HWND, initdata: int  }
405      (* Initializes a dialog box *)
406
407    |   WM_INITMENU of { menu: HMENU }   
408      (* Indicates a menu is about to become active *)
409
410    |   WM_INITMENUPOPUP of { menupopup: HMENU, itemposition: int, isSystemMenu: bool  }
411      (* Indicates a pop-up menu is being created *)
412
413    |   WM_KEYDOWN of { virtualKey: int, data: KeyData  }   
414      (* Indicates a nonsystem key was pressed *)
415
416    |   WM_KEYUP of { virtualKey: int, data: KeyData  } 
417      (* Indicates a nonsystem key was released *)
418
419    |   WM_KILLFOCUS of { receivefocus: HWND }
420      (* Indicates the Window is losing keyboard focus *)
421
422    |   WM_LBUTTONDBLCLK of { keyflags: MouseKeyFlags list, x: int, y: int  }
423      (* Indicates double-click of left button *) 
424
425    |   WM_LBUTTONDOWN of { keyflags: MouseKeyFlags list, x: int, y: int  }
426      (* Indicates when left mouse button is pressed *)
427
428    |   WM_LBUTTONUP of { keyflags: MouseKeyFlags list, x: int, y: int  }
429      (* Indicates when left mouse button is released *)
430
431    |   WM_MBUTTONDBLCLK of { keyflags: MouseKeyFlags list, x: int, y: int  }
432      (* Indicates double-click of middle mouse button *)
433
434    |   WM_MBUTTONDOWN of { keyflags: MouseKeyFlags list, x: int, y: int  }
435      (* Indicates when middle mouse button is pressed *)
436
437    |   WM_MBUTTONUP of { keyflags: MouseKeyFlags list, x: int, y: int  }
438      (* Indicates when middle mouse button is released *)
439  
440    |   WM_MDICASCADE of { skipDisabled: bool  } 
441      (* Arranges MDI child Windows in cascade format *)
442
443    |   WM_MDICREATE of
444        { class: ClassType, title: string, instance: HINSTANCE, x: int, y: int,
445          cx: int, cy: int, style: int, cdata: int }  
446      (* Prompts MDI client to create a child Window *) 
447
448    |   WM_MDIDESTROY of { child: HWND  }    
449      (* Closes an MDI child Window *) 
450
451    |   WM_MDIGETACTIVE
452      (* Retrieves data about the active MDI child Window *) 
453
454    |   WM_MDIICONARRANGE 
455      (* Arranges minimized MDI child Windows *) 
456
457    |   WM_MDIMAXIMIZE of {  child: HWND  }   
458      (* Maximizes an MDI child Window *) 
459
460    |   WM_MDINEXT of { child: HWND, flagnext: bool  }
461      (* Activates the next MDI child Window *) 
462
463    |   WM_MDIREFRESHMENU
464      (* Refreshes an MDI frame Window's menu *) 
465
466    |   WM_MDIRESTORE of {  child: HWND  }
467      (* Prompts MDI client to restore a child Window *) 
468
469    |   WM_MDISETMENU  of { frameMenu: HMENU, windowMenu: HMENU  } 
470      (* Replaces an MDI frame Window's menu *) 
471
472    |   WM_MDITILE of { tilingflag: MDITileFlags list }
473      (* Arranges MDI child Windows in tiled format *) 
474
475    |   WM_MEASUREITEM of
476        { senderId: int, ctlType: ControlType, ctlID: int, itemID: int, itemWidth: int ref, itemHeight: int ref, itemData: int }  
477      (* Requests dimensions of owner-draw control or item *)
478
479    |   WM_MENUCHAR of { ch: char, menuflag: MenuBase.MenuFlag, menu: HMENU }  
480      (* Indicates an unknown menu mnemonic was pressed *)
481
482    |   WM_MENUSELECT of { menuitem: int, menuflags: MenuBase.MenuFlag list, menu: HMENU  }
483      (* Indicates that the user selected a menu item *)
484
485    |   WM_MOUSEACTIVATE of { parent: HWND, hitTest: HitTest, message: int }
486      (* Indicates a mouse click in an inactive Window *) 
487
488    |   WM_MOUSEMOVE of { keyflags: MouseKeyFlags list, x: int, y: int }  
489      (* Indicates mouse-cursor movement *)
490
491    |   WM_MOUSEHOVER of { keyflags: MouseKeyFlags list, x: int, y: int }
492        (* Indicates the mouse hovering in the client area *)
493    
494    |   WM_MOUSELEAVE
495        (* Indicates the mouse leaving the client area *)
496
497    |   WM_MOVE of { x: int, y: int  }  
498      (* Indicates a Window's position has changed *)
499
500    |   WM_NCACTIVATE of { active: bool }
501      (* Changes the active state of nonclient area *)
502
503    |   WM_NCCALCSIZE of
504        { validarea: bool, newrect: RECT ref, oldrect: RECT, oldclientarea: RECT,
505          hwnd: HWND, insertAfter: HWND, x: int, y: int, cx: int, cy: int, style: WindowPositionStyle list}
506      (* Calculates the size of a Window's client area *)
507
508    |   WM_NCCREATE of
509        { instance: HINSTANCE, creation: Foreign.Memory.voidStar, menu: HMENU, parent: HWND, cy: int, cx: int,
510          y: int, x: int, style: windowFlags, name: string, class: ClassType, extendedstyle: int } 
511      (* Indicates a Window's nonclient area being created *)
512
513    |   WM_NCDESTROY  
514      (* Indicates Window's nonclient area being destroyed *)
515
516    |   WM_NCHITTEST of { x: int, y: int  } 
517      (* Indicates mouse-cursor movement *)
518
519    |   WM_NCLBUTTONDBLCLK of { hitTest: HitTest, x: int, y: int  }    
520      (* Indicates nonclient left button double-click *)
521
522    |   WM_NCLBUTTONDOWN  of { hitTest: HitTest, x: int, y: int  } 
523      (* Indicates left button pressed in nonclient area *)
524
525    |   WM_NCLBUTTONUP of { hitTest: HitTest, x: int, y: int  }    
526      (* Indicates left button released in nonclient area *)
527
528    |   WM_NCMBUTTONDBLCLK of { hitTest: HitTest, x: int, y: int  }    
529      (* Indicates nonclient middle button double-click *)
530
531    |   WM_NCMBUTTONDOWN of { hitTest: HitTest, x: int, y: int  }  
532      (* Indicates middle button pressed in nonclient area *)
533
534    |   WM_NCMBUTTONUP of { hitTest: HitTest, x: int, y: int  }    
535      (* Indicates middle button released in nonclient area *)
536
537    |   WM_NCMOUSEMOVE of { hitTest: HitTest, x: int, y: int  }    
538      (* Indicates mouse-cursor movement in nonclient area *)
539
540    |   WM_NCMOUSEHOVER of { hitTest: HitTest, x: int, y: int  }
541        (* Indicates the mouse hovering in the nonclient area *)
542    
543    |   WM_NCMOUSELEAVE
544        (* Indicates the mouse leaving the nonclient area *)
545
546    |   WM_NCPAINT of { region: HRGN  }  
547      (* Indicates a Window's frame needs painting *)
548
549    |   WM_NCRBUTTONDBLCLK of { hitTest: HitTest, x: int, y: int  }    
550      (* Indicates nonclient right button double-click *)
551
552    |   WM_NCRBUTTONDOWN of { hitTest: HitTest, x: int, y: int  }  
553      (* Indicates right button pressed in nonclient area *)
554
555    |   WM_NCRBUTTONUP of { hitTest: HitTest, x: int, y: int  }    
556      (* Indicates right button released in nonclient area *)
557
558    |   WM_NEXTDLGCTL of { control: int, handleflag: bool  } 
559      (* Sets focus to different dialog box control *) 
560
561    |   WM_PAINT  
562      (* Indicates a Window's client area need painting *)
563
564    |   WM_PAINTCLIPBOARD of { clipboard: HWND }
565      (* Prompts owner to display clipboard contents *)
566
567    |   WM_PAINTICON
568      (* Icon is about to be painted *) 
569
570    |   WM_PALETTECHANGED of { palChg: HWND  }   
571      (* Indicates the focus-Window realized its palette *)
572
573    |   WM_PALETTEISCHANGING of { realize: HWND  }   
574      (* Informs Windows that palette is changing *) 
575
576    |   WM_PARENTNOTIFY of { eventflag: int, idchild: int, value: int }  
577      (* Notifies parent of child-Window activity *) 
578
579    |   WM_PASTE  
580      (* Inserts clipboard data into an edit control *)
581
582    |   WM_POWER of { powerevent: int  } 
583      (* Indicates the system is entering suspended mode *)
584
585    |   WM_QUERYDRAGICON  
586      (* Requests a cursor handle for a minimized Window *)
587
588    |   WM_QUERYENDSESSION of { source: int  }
589      (* Requests that the Windows session be ended *) 
590
591    |   WM_QUERYNEWPALETTE
592      (* Allows a Window to realize its logical palette *) 
593
594    |   WM_QUERYOPEN
595      (* Requests that a minimized Window be restored *) 
596
597    |   WM_QUEUESYNC
598      (* Delimits CBT messages *) 
599
600    |   WM_QUIT of { exitcode: int  }    
601      (* Requests that an application be terminated *)
602
603    |   WM_RBUTTONDBLCLK of { keyflags: MouseKeyFlags list, x: int, y: int  }    
604      (* Indicates double-click of right mouse button *)
605
606    |   WM_RBUTTONDOWN of { keyflags: MouseKeyFlags list, x: int, y: int  }  
607      (* Indicates when right mouse button is pressed *)
608
609    |   WM_RBUTTONUP of { keyflags: MouseKeyFlags list, x: int, y: int  }
610      (* Indicates when right mouse button is released *) 
611
612    |   WM_RENDERALLFORMATS   
613      (* Notifies owner to render all clipboard formats *) 
614
615    |   WM_RENDERFORMAT of { format: ClipboardFormat  }  
616      (* Notifies owner to render clipboard data *) 
617
618    |   WM_SETCURSOR of { cursorwindow: HWND, hitTest: HitTest, mousemessage: int }
619      (* Prompts a Window to set the cursor shape *) 
620
621    |   WM_SETFOCUS of { losing: HWND  }
622
623    |   WM_SETFONT of {font: HFONT, redrawflag: bool  } 
624
625    |   WM_SETHOTKEY of { virtualKey: int  } 
626
627    |   WM_SETREDRAW of { redrawflag: bool  }
628
629    |   WM_SETTEXT of { text: string  }  
630
631    |   WM_SHOWWINDOW of { showflag: bool, statusflag: int  } 
632
633    |   WM_SIZE of { flag: WMSizeOptions, width: int, height: int  }   
634
635    |   WM_SIZECLIPBOARD of { viewer: HWND}
636
637    |   WM_SYSCHAR of { charCode: char, data: KeyData  }
638
639    |   WM_SYSCOLORCHANGE
640
641    |   WM_SYSCOMMAND of { commandvalue: SystemCommand, sysBits: int, p: POINT }
642
643    |   WM_SYSDEADCHAR of { charCode: char, data: KeyData  }
644
645    |   WM_SYSKEYDOWN of { virtualKey: int, data: KeyData  }
646
647    |   WM_SYSKEYUP of { virtualKey: int, data: KeyData  }
648
649    |   WM_TIMECHANGE 
650      (* Indicates the system time has been set *)
651
652    |   WM_TIMER of { timerid: int  }
653
654    |   WM_UNDO   
655
656    |   WM_SYSTEM_OTHER of { uMsg: int, wParam: SysWord.word, lParam: SysWord.word }
657    |   WM_USER of { uMsg: int, wParam: SysWord.word, lParam: SysWord.word }
658    |   WM_APP of { uMsg: int, wParam: SysWord.word, lParam: SysWord.word }
659    |   WM_REGISTERED of { uMsg: int, wParam: SysWord.word, lParam: SysWord.word }
660
661    |   WM_VKEYTOITEM of { virtualKey: int,
662                         caretpos: int,
663                         listbox: HWND  }
664
665    |   WM_VSCROLL of { value: ScrollDirection,
666                      position: int,
667                      scrollbar: HWND  }
668
669    |   WM_VSCROLLCLIPBOARD of { viewer: HWND,
670                               code: int,
671                               position: int  }
672
673    |   WM_WINDOWPOSCHANGED of
674            { hwnd: HWND, front: HWND, x: int, y: int, width: int, height: int, flags: WindowPositionStyle list }
675
676    |   WM_WINDOWPOSCHANGING of
677            {
678                hwnd: HWND, front: HWND ref, x: int ref, y: int ref,
679                width: int ref, height: int ref, flags: WindowPositionStyle list ref
680            }
681
682    |   WM_NOTIFY of {from: HWND, idCtrl: int, idFrom: int, notification: Notification }
683
684    |   WM_CAPTURECHANGED of { newCapture: HWND }
685
686    |   WM_ENTERSIZEMOVE
687
688    |   WM_EXITSIZEMOVE
689
690    |   WM_PRINT of {hdc: HDC, flags: WMPrintOption list }
691
692    |   WM_PRINTCLIENT of {hdc: HDC, flags: WMPrintOption list }
693
694    |   WM_HELP of { ctrlId: int, itemHandle: HelpHandle, contextId: int, mousePos: POINT }
695
696    |   WM_GETICON of { big: bool }
697
698    |   WM_SETICON of { big: bool, icon: HICON }
699
700    |   WM_CONTEXTMENU of { hwnd: HWND, xPos: int, yPos: int }
701
702    |   WM_DISPLAYCHANGE of { bitsPerPixel: int, xScreen: int, yScreen: int }
703
704    |   EM_CANUNDO
705
706    |   EM_CHARFROMPOS of EMCharFromPos
707
708    |   EM_EMPTYUNDOBUFFER
709
710    |   EM_FMTLINES of {addEOL: bool}
711
712    |   EM_GETFIRSTVISIBLELINE
713
714    |   EM_GETLIMITTEXT
715
716    |   EM_GETLINE of { lineNo: int, size: int, result: string ref }
717
718    |   EM_GETLINECOUNT
719
720    |   EM_GETMARGINS
721
722    |   EM_GETMODIFY
723
724    |   EM_GETPASSWORDCHAR
725
726    |   EM_GETRECT of {rect: RECT ref}
727
728    |   EM_GETSEL of {startPos: int ref, endPos: int ref}
729
730    |   EM_GETTHUMB
731
732    |   EM_LIMITTEXT of {limit: int}
733
734    |   EM_LINEFROMCHAR of {index: int}
735
736    |   EM_LINEINDEX of {line: int}
737
738    |   EM_LINELENGTH of {index: int}
739
740    |   EM_LINESCROLL of {xScroll: int, yScroll: int}
741
742    |   EM_POSFROMCHAR of {index: int}
743
744    |   EM_REPLACESEL of {canUndo: bool, text: string}
745
746    |   EM_SCROLL of {action: ScrollDirection}
747
748    |   EM_SCROLLCARET
749
750    |   EM_SETMARGINS of {margins: MarginSettings}
751
752    |   EM_SETMODIFY of { modified: bool }
753
754    |   EM_SETPASSWORDCHAR of { ch: char }
755
756    |   EM_SETREADONLY of { readOnly: bool }
757
758    |   EM_SETRECT of {rect: RECT}
759
760    |   EM_SETRECTNP of {rect: RECT}
761
762    |   EM_SETSEL of {startPos: int, endPos: int}
763
764    |   EM_SETTABSTOPS of {tabs: IntVector.vector}
765
766    |   EM_UNDO
767
768    |   BM_CLICK
769
770    |   BM_GETCHECK
771
772    |   BM_GETIMAGE of {imageType: ImageType}
773
774    |   BM_GETSTATE
775
776    |   BM_SETCHECK of {state: int}
777
778    |   BM_SETIMAGE of {image: HGDIOBJ, imageType: ImageType}
779
780    |   BM_SETSTATE of {highlight: bool }
781
782    |   BM_SETSTYLE of {redraw: bool, style: windowFlags}
783
784    |   CB_GETEDITSEL of {startPos: int ref, endPos: int ref}
785
786    |   CB_LIMITTEXT of {limit: int}
787
788    |   CB_SETEDITSEL of {startPos: int, endPos: int}
789
790    |   CB_ADDSTRING of { text: string }
791
792    |   CB_DELETESTRING of { index: int }
793
794    |   CB_GETCOUNT
795
796    |   CB_GETCURSEL
797
798    |   CB_DIR of { attrs: ComboBase.CBDirAttr list, fileSpec: string }
799
800    |   CB_GETLBTEXT of { index: int, length: int, text: string ref }
801
802    |   CB_GETLBTEXTLEN of { index: int }
803
804    |   CB_INSERTSTRING of { index: int, text: string }
805
806    |   CB_RESETCONTENT
807
808    |   CB_FINDSTRING of { indexStart: int, text: string }
809
810    |   CB_SELECTSTRING of { indexStart: int, text: string }
811
812    |   CB_SETCURSEL of { index: int }
813
814    |   CB_SHOWDROPDOWN of { show: bool }
815
816    |   CB_GETITEMDATA of { index: int }
817
818    |   CB_SETITEMDATA of { index: int, data: int }
819
820    |   CB_GETDROPPEDCONTROLRECT of { rect: RECT ref }
821
822    |   CB_SETITEMHEIGHT of { index: int, height: int }
823
824    |   CB_GETITEMHEIGHT of { index: int }
825
826    |   CB_SETEXTENDEDUI of { extended: bool }
827
828    |   CB_GETEXTENDEDUI
829
830    |   CB_GETDROPPEDSTATE
831
832    |   CB_FINDSTRINGEXACT of { indexStart: int, text: string }
833
834    |   CB_SETLOCALE of { locale: int }
835
836    |   CB_GETLOCALE
837
838    |   CB_GETTOPINDEX
839
840    |   CB_SETTOPINDEX of { index: int }
841
842    |   CB_GETHORIZONTALEXTENT
843
844    |   CB_SETHORIZONTALEXTENT of { extent: int }
845
846    |   CB_GETDROPPEDWIDTH
847
848    |   CB_SETDROPPEDWIDTH of { width: int }
849
850    |   CB_INITSTORAGE of { items: int, bytes: int }
851
852    |   LB_ADDSTRING of { text: string }
853
854    |   LB_INSERTSTRING of { index: int, text: string }
855
856    |   LB_DELETESTRING of { index: int }
857
858    |   LB_SELITEMRANGEEX of { first: int, last: int }
859
860    |   LB_RESETCONTENT
861
862    |   LB_SETSEL of { select: bool, index: int }
863
864    |   LB_SETCURSEL of { index: int }
865
866    |   LB_GETSEL of { index: int }
867
868    |   LB_GETCURSEL
869
870    |   LB_GETTEXT of { index: int, length: int, text: string ref }
871
872    |   LB_GETTEXTLEN of { index: int }
873
874    |   LB_GETCOUNT
875
876    |   LB_SELECTSTRING of { indexStart: int, text: string }
877
878    |   LB_DIR of { attrs: ComboBase.CBDirAttr list, fileSpec: string }
879
880    |   LB_GETTOPINDEX
881
882    |   LB_FINDSTRING of { indexStart: int, text: string }
883
884    |   LB_GETSELCOUNT
885
886    |   LB_GETSELITEMS of { items: IntArray.array }
887
888    |   LB_SETTABSTOPS of { tabs: IntVector.vector }
889
890    |   LB_GETHORIZONTALEXTENT
891
892    |   LB_SETHORIZONTALEXTENT of { extent: int }
893
894    |   LB_SETCOLUMNWIDTH of { column: int }
895
896    |   LB_ADDFILE of { fileName: string }
897
898    |   LB_SETTOPINDEX of { index: int }
899
900    |   LB_GETITEMRECT of { rect: RECT ref, index: int }
901
902    |   LB_GETITEMDATA of { index: int }
903
904    |   LB_SETITEMDATA of { index: int, data: int }
905
906    |   LB_SELITEMRANGE of { select: bool, first: int, last: int }
907
908    |   LB_SETANCHORINDEX of { index: int }
909
910    |   LB_GETANCHORINDEX
911
912    |   LB_SETCARETINDEX of { index: int, scroll: bool }
913
914    |   LB_GETCARETINDEX
915
916    |   LB_SETITEMHEIGHT of { index: int, height: int }
917
918    |   LB_GETITEMHEIGHT of { index: int }
919
920    |   LB_FINDSTRINGEXACT of { indexStart: int, text: string }
921
922    |   LB_SETLOCALE of { locale: int } (* Should be an abstract type? *)
923
924    |   LB_GETLOCALE (* Result will be the type used above. *)
925
926    |   LB_SETCOUNT of { items: int }
927
928    |   LB_INITSTORAGE of { items: int, bytes: int }
929
930    |   LB_ITEMFROMPOINT of { point: POINT }
931
932    |   STM_GETICON
933
934    |   STM_GETIMAGE of {imageType: ImageType}
935
936    |   STM_SETICON of {icon: HICON}
937
938    |   STM_SETIMAGE of {image: HGDIOBJ, imageType: ImageType}
939
940    |   SBM_SETPOS of { pos: int, redraw: bool }
941
942    |   SBM_GETPOS
943
944    |   SBM_SETRANGE of { minPos: int, maxPos: int }
945
946    |   SBM_SETRANGEREDRAW of { minPos: int, maxPos: int }
947
948    |   SBM_GETRANGE of { minPos: int ref, maxPos: int ref }
949
950    |   SBM_ENABLE_ARROWS of ScrollBase.enableArrows
951
952    |   SBM_SETSCROLLINFO of
953            { info: ScrollBase.SCROLLINFO, options: ScrollBase.ScrollInfoOption list }
954
955    |   SBM_GETSCROLLINFO of
956            { info: ScrollBase.SCROLLINFO ref, options: ScrollBase.ScrollInfoOption list }
957
958    |   FINDMSGSTRING of
959        { flags: findReplaceFlags, findWhat: string, replaceWith: string }
960
961
962    type MSG = {
963        msg: Message,
964        hwnd: HWND,
965        time: Time.time,
966        pt: {x: int, y: int}
967        }
968
969    val GetInputState: unit -> bool
970    val GetMessage: HWND option * int * int -> MSG
971    val GetMessagePos: unit -> POINT
972    val GetMessageTime: unit -> Time.time
973
974    datatype
975      QueueStatus =
976          QS_ALLPOSTMESSAGE
977        |   QS_HOTKEY
978        |   QS_KEY
979        |   QS_MOUSEBUTTON
980        |   QS_MOUSEMOVE
981        |   QS_PAINT
982        |   QS_POSTMESSAGE
983        |   QS_SENDMESSAGE
984        |   QS_TIMER
985    val QS_ALLEVENTS: QueueStatus list
986    val QS_ALLINPUT: QueueStatus list
987    val QS_INPUT: QueueStatus list
988    val QS_MOUSE: QueueStatus list
989    val GetQueueStatus: QueueStatus list -> QueueStatus list
990
991    val InSendMessage: unit -> bool
992
993    datatype PeekMessageOptions = PM_NOREMOVE | PM_REMOVE
994    val PeekMessage: HWND option * int * int * PeekMessageOptions -> MSG option
995    val PostQuitMessage: int -> unit
996    val RegisterWindowMessage: string -> int
997    val RunApplication: unit -> int
998    val SendMessage: HWND * Message -> LRESULT
999    val PostMessage: HWND * Message -> unit
1000    val HWND_BROADCAST: HWND
1001    val WaitMessage: unit -> bool
1002
1003    (* These last few are just used internally. *)
1004    val subclass:
1005       HWND * (HWND * Message * 'a -> LRESULT * 'a) * 'a ->
1006          (HWND * Message -> LRESULT)
1007
1008    val setCallback: (HWND * Message * 'a -> LRESULT * 'a) * 'a -> unit
1009    val addModelessDialogue: HWND * (unit->unit) option -> unit
1010    val removeCallback: HWND -> unit
1011    (*val updateWindowHandle: HWND -> unit*)
1012    val compileMessage: Message -> int * SysWord.word * SysWord.word * (unit->unit)
1013    val decompileMessage: int * SysWord.word * SysWord.word -> Message
1014    val messageReturnFromParams:
1015        Message * SysWord.word * SysWord.word * SysWord.word -> LRESULT
1016    val updateParamsFromMessage: Message * SysWord.word * SysWord.word -> unit
1017    val LPMSG: MSG Foreign.conversion
1018    val mainWinProc: (HWND * int * SysWord.word * SysWord.word -> SysWord.word) Foreign.closure
1019end;
1020