To show a message with MessageBox

Discussions related to Visual Prolog
Posts: 3
Joined: 17 May 2020 6:12

To show a message with MessageBox

Unread post by alonso »

Good afternoon.
I hope someone help me.
I am working with GUI--> MessageBox

How can i show a short message on the screen, with the reply or the button you clicked as a message?
What can i do with the variable "_answer".
Thank you for reading.

onMensajesMessagebox1 : window::menuItemListener.
onMensajesMessagebox1(_Source, _MenuTag) :-
_answer = messageBox("Message Title", "This is a Message", 3, 2, 1, 0).
%What Next
Harrison Pratt
VIP Member
Posts: 326
Joined: 5 Nov 2000 0:01

Re: To show a message with MessageBox

Unread post by Harrison Pratt »

The return value is the button number (1...N) you clicked. You may use it to control subsequent program flow:

Code: Select all

        ButtonNumClicked =             vpiCommonDialogs::messageBox("Message Title", "This is a Message", vpiDomains::mesbox_iconError,                 vpiDomains::mesbox_buttonsokcancel, vpiDomains::mesbox_defaultfirst,                 vpiDomains::mesbox_suspendapplication),         stdio::write("\n You clicked button "),         if ButtonNumClicked = 1 then             stdio::write("[OK]")         else             stdio::write("[Cancel]")         end if.
In this case, pressing the [Esc] key or closing the dialog by clicking the title bar [X] returns '2'. You can omit the vpiDomains:: qualification if vpiDomains is listed in the open statement of the .pro file.

It is better code style to use the mesbox_XXX constants rather than the integers so you can easy see what your intent was for the code after a month or two. :wink:
Post Reply