COVERAGE SUMMARY
FILE SUMMARY
NameExecutedRoutines%ExecutedLines%Unexecuted
/home/matt/eu/rds/include/std/win32/msgbox.e010.00%0530.00%53
ROUTINE SUMMARY
RoutineExecutedLinesUnexecuted
message_box()0180.00%18
LINE COVERAGE DETAIL
#Executed
1
-- (c) Copyright - See License.txt
2
--
3
--****
4
-- == Windows Message Box
5
--
6
-- <>
7
--
8
namespace msgbox
9
10
include std/dll.e
11
include std/machine.e
12
13
without warning
14
15
--****
16
-- === Style Constants
17
--
18
-- Possible style values for message_box() style sequence
19
--
20
21
public constant
22
--** Abort, Retry, Ignore
230
MB_ABORTRETRYIGNORE = #02,
24
--** User must respond before doing something else
250
MB_APPLMODAL = #00,
260
MB_DEFAULT_DESKTOP_ONLY = #20000,
27
--** First button is default button
280
MB_DEFBUTTON1 = #00,
29
--** Second button is default button
300
MB_DEFBUTTON2 = #100,
31
--** Third button is default button
320
MB_DEFBUTTON3 = #200,
33
--** Fourth button is default button
340
MB_DEFBUTTON4 = #300,
35
--** Windows 95: Help button generates help event
360
MB_HELP = #4000,
370
MB_ICONASTERISK = #40,
380
MB_ICONERROR = #10,
39
--** Exclamation-point appears in the box
400
MB_ICONEXCLAMATION = #30,
41
--** A hand appears
420
MB_ICONHAND = MB_ICONERROR,
43
--** Lowercase letter i in a circle appears
440
MB_ICONINFORMATION = MB_ICONASTERISK,
45
--** A question-mark icon appears
460
MB_ICONQUESTION = #20,
470
MB_ICONSTOP = MB_ICONHAND,
480
MB_ICONWARNING = MB_ICONEXCLAMATION,
49
--** Message box contains one push button: OK
500
MB_OK = #00,
51
--** Message box contains OK and Cancel
520
MB_OKCANCEL = #01,
53
--** Message box contains Retry and Cancel
540
MB_RETRYCANCEL = #05,
55
--** Windows 95: The text is right-justified
560
MB_RIGHT = #80000,
57
--** Windows 95: For Hebrew and Arabic systems
580
MB_RTLREADING = #100000,
59
--** Windows NT: The caller is a service
600
MB_SERVICE_NOTIFICATION = #40000,
61
--** Message box becomes the foreground window
620
MB_SETFOREGROUND = #10000,
63
--** All applications suspended until user responds
640
MB_SYSTEMMODAL = #1000,
65
--** Similar to MB_APPLMODAL
660
MB_TASKMODAL = #2000,
67
--** Message box contains Yes and No
680
MB_YESNO = #04,
69
--** Message box contains Yes, No, and Cancel
700
MB_YESNOCANCEL = #03
71
72
--****
73
-- === Return Value Constants
74
--
75
-- possible values returned by MessageBox(). 0 means failure
76
77
public constant
78
--** Abort button was selected.
790
IDABORT = 3,
80
--** Cancel button was selected.
810
IDCANCEL = 2,
82
--** Ignore button was selected.
830
IDIGNORE = 5,
84
--** No button was selected.
850
IDNO = 7,
86
--** OK button was selected.
870
IDOK = 1,
88
--** Retry button was selected.
890
IDRETRY = 4,
90
--** Yes button was selected.
910
IDYES = 6
92
93
atom lib
94
integer msgbox_id, get_active_id
95
960
ifdef WIN32 then
97
lib = open_dll("user32.dll")
98
msgbox_id = define_c_func(lib, "MessageBoxA", {C_UINT, C_POINTER,
99
C_POINTER, C_UINT}, C_INT)
100
if msgbox_id = -1 then
101
puts(2, "couldn't find MessageBoxA\n")
102
abort(1)
103
end if
104
105
get_active_id = define_c_func(lib, "GetActiveWindow", {}, C_UINT)
106
if get_active_id = -1 then
107
puts(2, "couldn't find GetActiveWindow\n")
108
abort(1)
109
end if
110
end ifdef
111
112
--****
113
-- === Routines
114
--
115
116
--**
117
-- Displays a window with a title, message, buttons and an icon, usually known as a message box.
118
--
119
-- Parameters:
120
-- # ##text##: a sequence, the message to be displayed
121
-- # ##title##: a sequence, the title the box should have
122
-- # ##style##: an object which defines which,icon should be displayed, if any, and which buttons will be presented.
123
--
124
-- Returns:
125
-- An **integer**, the button which was clicked to close the message box, or 0 on failure.
126
--
127
-- Comments:
128
-- See [[:Style Constants]] above for a complete list of possible values for ##style## and
129
-- [[:Return Value Constants]] for the returned value. If ##style## is a sequence, its elements will be
130
-- or'ed together.
131
1320
133
integer or_style
134
atom text_ptr, title_ptr, ret
135
1360
text_ptr = allocate_string(text)
1370
if not text_ptr then
1380
return 0
139
end if
1400
title_ptr = allocate_string(title)
1410
if not title_ptr then
1420
free(text_ptr)
1430
return 0
144
end if
1450
if atom(style) then
1460
or_style = style
147
else
1480
or_style = 0
1490
for i = 1 to length(style) do
1500
or_style = or_bits(or_style, style[i])
1510
end for
152
end if
1530
ret = c_func(msgbox_id, {c_func(get_active_id, {}),
154
text_ptr, title_ptr, or_style})
1550
free(text_ptr)
1560
free(title_ptr)
157
1580
return ret
159
end function
160