cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ralphster
Level 6

Message box with a return code

Jump to solution

I need to display a message box message box with a prompt for the user to press a "Yes" button or a "No" button.

Can someone show me how this is done in InstallShield? Also how do I get the value passed back when the message box is closed?

Labels (1)
0 Kudos
(1) Solution

Try below

MessageBoxEx("Are you sure?","My message box header",MB_YESNO | MB_ICONEXCLAMATION );

View solution in original post

(4) Replies
Varaprasad
Level 7 Flexeran
Level 7 Flexeran

You can use InstallScript  AskYesNo method (returns value 1 when Yes button is clicked and 0 for No button).

OR

You can also use InstallScript MessageBox method with appropriate styles supported by Windows MessageBox API for type field using logical OR operator (|).

For example, to show Yes and No buttons with warning icon, you could use corresponding constants defined in msdn documentation of MessageBox API(https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox). You can also check same link for return values.

MB_YESNO 0x00000004L
MB_ICONWARNING 0x00000030L

MessageBox("Test", 0x00000004 | 0x00000030);

0 Kudos

Thank you Varaprasad. I would have used the AskYesNo message box style, but there is not a parameter to set the title in the header?

I am now using MessageBoxEx to display the Yes No message box. It works great, but I can't figure out how to also place an Icon in the message box. Can you tell me how to do that? I notice that the AskYesNo message box has a question mark icon in it. I would like a warning icon in the MessageBoxEx if possible. Anyway that you know that I can do that?

 

Example: MessageBoxEx works great, how do I place an Icon in it?

if(MessageBoxEx("Are you sure?","My message box header",,MB_YESNO) = YES) then
// Do something
endif;

 

I tried AskYesNo, but can't set the header title:

if(AskYesNo("Are you sure?",YES) = YES) then
// Do Something
endif;

0 Kudos

Also I tried using SetDialogTitle before calling the message boxes, but it does not work, because I don't have the id of the message box? So that did not work.

0 Kudos

Try below

MessageBoxEx("Are you sure?","My message box header",MB_YESNO | MB_ICONEXCLAMATION );