Steven Blair
72537,2547

Win API Message Boxes

The included form and library demonstrate a simple means of encapsulating the Windows API
message boxes in an ObjectPAL method. Some of these boxes are not accessible directly from
ObjectPAL and provide a little more flexibility. Some of them are absurd and have no
realistic purpose but most are useful. The following information has been tested to some
extent. Nonetheless, I urge you to experiment on your own. To use the form, type the test
value in the field and click on the "BOX TEST" button.

The following method from WINAPI.LSL has a calling convention very similar to any of the
standard PFW message boxes. The difference is that the method name remains the same and
the box type is specified by the variable "boxType".

method APIMsgBox(text string, caption string, boxType smallInt)smallInt
var
   ParentWin   smallInt
endvar

parentWin = windowHandle()

return messageBox(parentWin, text, caption, boxType)

endmethod

The values for "boxType" are indicated below. The first button in the list is the default.

Value     Buttons
0         OK (also is the default with no value given)
1         OK, Cancel
2         Abort, Retry, Cancel
3         Yes, No, Cancel
4         Yes, No
5         Retry, Cancel
6         [BLANK]
7         [BLANK]
8         Abort, Retry
9         OK, Cancel, Abort, Retry, Ignore (1 + 2)
10        No, Cancel, Retry, Cancel, DONE=
11        OK, Cancel, Abort, Retry, Ignore, Yes, No, Cancel (1 + 2 + 3)
12        [BLANK]
13        [BLANK]
14        Cancel, Retry
15        [BLANK]

To these values can be added an icon identifier. The boxType values by themselves show a
box with no icon. The values to be added are as follows.

Value     Icon
16        Stop
32        Question
48        Exclamation
64        Information

To summarize, the call "APIMsgBox("Hi!", "Win API Box", 51)" would produce a message box
with the Exclamation icon and buttons for Yes, No and Cancel. The values labeled [BLANK]
produce a message box with no button and no way that I can determine to close them. They
should be avoided unless a closure means can be devised.

Result Values

The result of clicking on a button produces a smallInt value. Those values are listed
below.

Result    Button
1         OK
2         Cancel
3         Abort
4         Retry
5         Ignore
6         Yes
7         No

I hope that this might help for a particular situation. I'm sure that the method could be
made more sophisticated with a little work. If you come up with any useful improvements,
please let me know.
