1(*
2    Copyright (c) 2001-7
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 as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9    
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14    
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18*)
19
20(* Test routine for dialogue.  Tests various messages. *)
21
22fun dlgProc (h, Message.WM_INITDIALOG _, ()) = (Message.LRESINT 1, ())
23 |  dlgProc (h, Message.WM_COMMAND{notifyCode = 0, wId, ...}, ()) =
24        (if wId = MessageBox.IDOK orelse wId = MessageBox.IDCANCEL
25         then (Dialog.EndDialog(h, wId); Message.PostQuitMessage 0) else ();
26         (Message.LRESINT 1, ()))
27 |  dlgProc msg = ((*PolyML.print msg;*)(Message.LRESINT 0, ()));
28
29val dial = ref Base.hwndNull;
30
31local
32open Dialog Window.Style
33in
34val template =
35   {x = 0, y = 0, cx = 215, cy = 135, font = SOME (8, "MS Sans Serif"), menu = NONE,
36    class = NONE, style = flags[WS_POPUP, WS_CAPTION, WS_SYSMENU], title = "Dialogue",
37    extendedStyle = 0,
38    items =
39      [{x = 158, y = 7, cx = 50, cy = 14, id = 1, creationData = NONE, extendedStyle = 0,
40        class = DLG_BUTTON(flags[WS_CHILD, WS_VISIBLE, WS_TABSTOP]), title = DLG_TITLESTRING "OK"},
41       {x = 158, y = 24, cx = 50, cy = 14, id = 2,creationData = NONE, extendedStyle = 0,
42        class = DLG_BUTTON(flags[WS_CHILD, WS_VISIBLE, WS_TABSTOP]), title = DLG_TITLESTRING "Cancel"},
43       {x = 45, y = 67, cx = 48, cy = 61, id = 1003, title = DLG_TITLESTRING "",
44        creationData = NONE, extendedStyle = 0,
45        class = DLG_COMBOBOX(flags[WS_CHILD, WS_VISIBLE, WS_VSCROLL, WS_TABSTOP])},
46       {x = 23, y = 26, cx = 19, cy = 8, id = 65535, creationData = NONE, extendedStyle = 0,
47        class = DLG_STATIC(flags[WS_CHILD, WS_VISIBLE, WS_GROUP]), title = DLG_TITLESTRING "Static"},
48       {x = 64, y = 24, cx = 40, cy = 14, id = 1000, creationData = NONE, extendedStyle = 0,
49        class = DLG_EDIT(flags[WS_CHILD, WS_VISIBLE, WS_BORDER, WS_TABSTOP]), title = DLG_TITLESTRING ""},
50       {x = 14, y = 47, cx = 103, cy = 11, id = 1001, creationData = NONE, extendedStyle = 0,
51        class = DLG_SCROLLBAR(flags[WS_CHILD, WS_VISIBLE]), title = DLG_TITLESTRING ""},
52       {x = 136, y = 46, cx = 58, cy = 72, id = 1002, creationData = NONE, extendedStyle = 0,
53        class = DLG_LISTBOX (flags[WS_CHILD, WS_VISIBLE, WS_BORDER, WS_VSCROLL, WS_TABSTOP]),
54        title = DLG_TITLESTRING ""}]}
55fun makedial() =
56    CreateDialogIndirect(Globals.ApplicationInstance(), template,
57        Globals.MainWindow(), dlgProc, ());
58end;
59(*
60val hi = Resource.LoadLibrary "C:\\Source Files\\DialogueDLL\\Debug\\DialogueDLL.dll";
61     
62fun makedial() = Dialog.CreateDialog(hi, Resource.IdAsString "MYDIALOGUE", Globals.MainWindow(),
63    dlgProc, ());
64*)
65(* The dialogue has to be created by the thread that will handle its messages. *)
66fun runDialogue() =
67    (
68        dial := makedial();
69        Window.ShowWindow(!dial, Window.SW_SHOW);
70        Window.SetForegroundWindow (!dial);
71        Message.RunApplication();
72        ()
73    );
74
75Thread.Thread.fork(runDialogue, []);
76
77val combo = Dialog.GetDlgItem(!dial, 1003);
78val scroll = Dialog.GetDlgItem(!dial, 1001);
79val listbox = Dialog.GetDlgItem(!dial, 1002);
80
81val info = ref {minPos = 10, maxPos = 20, pageSize = 4, pos = 15, trackPos = 0};
82Message.SendMessage(scroll, Message.SBM_SETSCROLLINFO{info= !info, options=Scrollbar.SIF_ALL});
83Message.SendMessage(scroll, Message.SBM_GETSCROLLINFO{info=info, options=Scrollbar.SIF_ALL});
84!info;
85Message.SendMessage(combo, Message.CB_DIR{attrs = [], fileSpec ="C:\\*"});
86
87Message.SendMessage(combo, Message.CB_DIR{attrs = [], fileSpec ="C:\\*"});
88