QB64 Phoenix Edition
Add buttons to _MESSAGEBOX function? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Add buttons to _MESSAGEBOX function? (/showthread.php?tid=2679)



Add buttons to _MESSAGEBOX function? - tothebin - 05-11-2024

The _MESSAGEBOX function has been a major improvement for me. Is there any way to add or change the default buttons? Being able to have buttons such as [Help] or [Quit] would be extremely useful. With the right buttons some of my utility programs wouldn't need any other type of GUI.


RE: Add buttons to _MESSAGEBOX function? - ahenry3068 - 05-11-2024

You can make it return a 0 or 1 and get  Yes / No buttons with the following syntax.


        KillIt% = _MessageBox("FILE EXISTS", Z_File$ + " Exists\nOverwrite?", "yesno", "question", 0)
        If KillIt% = 1 Then
            Kill (Z_File$)
        Else
            Z_File$ = _InputBox$("NEW FILE NAME", "Enter ZCM File Name", Z_File$)
            If Z_File$ = "" Then System
            GoTo StartZWrite
        End If

I too would like the option for more buttons.   But you can do a lot with just a Yes/No option.


RE: Add buttons to _MESSAGEBOX function? - bplus - 05-11-2024

+1 yes you can do allot with yes/no/cancel, cancel is 3rd option the one you never see in opinion polls ;-))

message box 1 do you want help? if yes then message box 2 offer help...

welcome @ahenry3068


RE: Add buttons to _MESSAGEBOX function? - Kernelpanic - 05-11-2024

Code: (Select All)

 KillIt% = _MessageBox("FILE EXISTS", Z_File$ + " Exists\nOverwrite?", "yesno", "question", 0)
The "\n" is a C/C++ control character and does not work in Basic.

All three options are better than just yes/no.
Code: (Select All)

KillIt% = _MessageBox("FILE EXISTS", Z_File$ + "Exist -- Overwrite?", "yesnocancel", "question", 2)
If KillIt% = 1 Then
  Kill (Z_File$)
Else
  Z_File$ = _InputBox$("NEW FILE NAME", "Enter ZCM File Name", Z_File$)
  If Z_File$ = "" Then System
  GoTo StartZWrite
End If

StartZWrite:
Print "Ende"



RE: Add buttons to _MESSAGEBOX function? - SpriggsySpriggs - 05-11-2024

You can try doing a TaskDialog. They are far more powerful than a standard MessageBox. However, they require a great deal of work. Here is a post I had submitted to the old forum website a long time ago.
https://qb64forum.alephc.xyz/index.php?topic=4032.msg133688#msg133688

However, be aware that the recent updates to Phoenix have broken a lot of older code I have written as they have changed the backend of some things. You will most likely need to do a lot of work to make it compatible with the recent versions.