Jump to content

This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.

How to create a OK|CANCEL messagebox?

2 replies to this topic


  • Full Members
  • 407 posts

Posted 25 September 2001 - 08:38

Can somebody help me creating a messagebox with OK and CANCEL buttons?
SprinfBox supports WinMessageBox API, but I am pretty unfamiliar with this. So I need to know,
- which values I have to define,
- is there a windows h file to be included,
- how to design the SprintfBox parameters?

I tried to use OK|CANCEL as first param, but it is the same result as YES|NO|CANCEL, which I do not want ..

if possible, how do I define an icon besides the two buttons?

any help is appreciated


  • Members
  • 4 posts

Posted 25 September 2001 - 21:12


I had the same problem until I figured it out how to get OK|CANCEL button on the message box. I guess this is a bug in IS 5.x.
In the SprintfBox function you need to use YES for first parameter to get OK|CANCEL. I needed Yes and No buttons once, but I couldn't get them since :).
So use something like this:

nReturn = SprintfBox(YES, szTitle, szFormat, arg1);

This SprintfBox will put up OK|CANCEL buttons. If nReturn = 1, then the user hit OK, if it is 2, then the user hit Cancel.


  • Members
  • 6 posts

Posted 22 March 2002 - 12:51

The documentation for Sprintfbox is incorrect (even in Installshield Developer).  You need to use the MB_* values specified in Winuser.h

MB_OK                           0
MB_OKCANCEL                 1
MB_YESNOCANCEL            3
MB_YESNO                      4
MB_RETRYCANCEL            5

You also shouldn't need to define them, but if you do....

#define MB_OK                           0x00000000L
#define MB_OKCANCEL                 0x00000001L
#define MB_ABORTRETRYIGNORE    0x00000002L
#define MB_YESNOCANCEL            0x00000003L
#define MB_YESNO                      0x00000004L
#define MB_RETRYCANCEL            0x00000005L

Lastly the reason why YES gave you the OK|CANCEL box is because it is defined as having 1 as it value....which is the same as the MB_OKCANCEL style.

nReturn = SprintfBox(MB_YESNO, szTitle, szFormat [, arg1]);

HTH, sorry it took so long, but I only just found this post!!