Apr 20, 2017 Replies: 8 There are many libraries that update and modify MsgBox and all interesting, but no one meets my needs. So I created someone I did. I hope someone else might be useful. It's not a library. Only snippets of code. Does not require any additional library. You can include on your sources or you can wrap them into Class. MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int The parameters are the same as MsgBox2 MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int GraficStyle 0 = Trapeze 1 = Ellisse 2 = Fringe Attachments messageBox.zip messageBox.zip 8.5 KB · Views: 1,316 Last edited: Oct 23, 2017 Click to expand...
There are many libraries that update and modify MsgBox and all interesting, but no one meets my needs. So I created someone I did. I hope someone else might be useful. It's not a library. Only snippets of code. Does not require any additional library. You can include on your sources or you can wrap them into Class. MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int The parameters are the same as MsgBox2 MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int GraficStyle 0 = Trapeze 1 = Ellisse 2 = Fringe
Star-Dust Expert Licensed User Longtime User May 2, 2017 #2 UPDATE: Created MsgBox class and variation management screen orientation Use: Code: Copy Dim MsBox As SDMsgBox MsBox.Initialize(Activity) If MsBox.MsgBox4("Message","MsgBox4 - Style 0","Yes","","No",0)=DialogResponse.POSITIVE Then ToastMessageShow("YES",False) Else ToastMessageShow("No",False) End If Method MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int GraficStyle 0 = Trapeze; 1 = Ellisse; 2 = Fringe Proprietes Response As int ' as DialogResponse Last edited: May 2, 2017
UPDATE: Created MsgBox class and variation management screen orientation Use: Code: Copy Dim MsBox As SDMsgBox MsBox.Initialize(Activity) If MsBox.MsgBox4("Message","MsgBox4 - Style 0","Yes","","No",0)=DialogResponse.POSITIVE Then ToastMessageShow("YES",False) Else ToastMessageShow("No",False) End If Method MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int GraficStyle 0 = Trapeze; 1 = Ellisse; 2 = Fringe Proprietes Response As int ' as DialogResponse
jnjft Member Licensed User Longtime User Dec 4, 2017 #3 Hello Star-Dust! Thanks a lot for the MsgBox-enhancements! I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again. What could be wrong? Thanks for your effort
Hello Star-Dust! Thanks a lot for the MsgBox-enhancements! I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again. What could be wrong? Thanks for your effort
Star-Dust Expert Licensed User Longtime User Dec 5, 2017 #4 jnjft said: Hello Star-Dust! Thanks a lot for the MsgBox-enhancements! I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again. What could be wrong? Thanks for your effort Click to expand... The screen is darkened, giving the impression that the activity is paused. It's just a trick. I open a transparent gray panel under the box. See the code below. Code: Copy Sub MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int Dim P, Box As Panel '... '... P.Initialize("PanelMsgBox3") P.Color=Colors.ARGB(210,10,10,10) When you click on a button the panelle is removed, as in the code you see below Code: Copy Do While Box.Tag="" DoEvents DoEvents If P.Width<>GetDeviceLayoutValues.Width Then Activity.Width=GetDeviceLayoutValues.Width Activity.Height=GetDeviceLayoutValues.Height P.Width=GetDeviceLayoutValues.Width P.Height=GetDeviceLayoutValues.Height Box.Left=P.Width/2-180dip Box.Top=P.Height/2-150dip End If Loop Ret=Box.Tag P.RemoveView ' PANEL GRAY REMOVED Return Ret If you have not modified the code it should work. In any case, I suggest changing the code to no longer use the modal MsgBox, but the event one This would avoid creating problems with the DoEvents. For example, removing the block that I pasted on and modifying the click event of the three options (Yes, Cancel, No) Code: Copy Sub BMsgBox3_Click Dim B As Button = Sender Dim P As Panel = B.Parent P.Tag=B.Tag P.RemoveView ' Remove Panel Gray End Sub With these changes you can use the MessageBox also with the Wait For Regard
jnjft said: Hello Star-Dust! Thanks a lot for the MsgBox-enhancements! I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again. What could be wrong? Thanks for your effort Click to expand... The screen is darkened, giving the impression that the activity is paused. It's just a trick. I open a transparent gray panel under the box. See the code below. Code: Copy Sub MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int Dim P, Box As Panel '... '... P.Initialize("PanelMsgBox3") P.Color=Colors.ARGB(210,10,10,10) When you click on a button the panelle is removed, as in the code you see below Code: Copy Do While Box.Tag="" DoEvents DoEvents If P.Width<>GetDeviceLayoutValues.Width Then Activity.Width=GetDeviceLayoutValues.Width Activity.Height=GetDeviceLayoutValues.Height P.Width=GetDeviceLayoutValues.Width P.Height=GetDeviceLayoutValues.Height Box.Left=P.Width/2-180dip Box.Top=P.Height/2-150dip End If Loop Ret=Box.Tag P.RemoveView ' PANEL GRAY REMOVED Return Ret If you have not modified the code it should work. In any case, I suggest changing the code to no longer use the modal MsgBox, but the event one This would avoid creating problems with the DoEvents. For example, removing the block that I pasted on and modifying the click event of the three options (Yes, Cancel, No) Code: Copy Sub BMsgBox3_Click Dim B As Button = Sender Dim P As Panel = B.Parent P.Tag=B.Tag P.RemoveView ' Remove Panel Gray End Sub With these changes you can use the MessageBox also with the Wait For Regard
jnjft Member Licensed User Longtime User Dec 5, 2017 #5 Thanks for the reply! I didn't change the code and I understand what you mean - alas, P.RemoveView doesn't remove the gray panel at my place. I've come so far with logs: - The loop Do While Box.Tag = "" is exited and Ret gets the contents of Box.Tag, but the next statement (P.RemoveView) fails - When I touch the gray panel actively I enter PanelMsgBox3_Touch, and the code there does exactly what I want - remove the panel. Although it only contains the two statements Code: Copy Sub PanelMsgBox3_Touch (Action As Int, X As Float, Y As Float) Dim P as Panel = Sender P.RemoveView
Thanks for the reply! I didn't change the code and I understand what you mean - alas, P.RemoveView doesn't remove the gray panel at my place. I've come so far with logs: - The loop Do While Box.Tag = "" is exited and Ret gets the contents of Box.Tag, but the next statement (P.RemoveView) fails - When I touch the gray panel actively I enter PanelMsgBox3_Touch, and the code there does exactly what I want - remove the panel. Although it only contains the two statements Code: Copy Sub PanelMsgBox3_Touch (Action As Int, X As Float, Y As Float) Dim P as Panel = Sender P.RemoveView
jnjft Member Licensed User Longtime User Dec 8, 2017 #6 Is there a possibility to simulate the panel touch event? I had no success with calling PanelMsgBox3_Touch(0, 10, 10). Regards Johann
Is there a possibility to simulate the panel touch event? I had no success with calling PanelMsgBox3_Touch(0, 10, 10). Regards Johann
tagwato Member Licensed User Longtime User Apr 8, 2023 #8 Star-Dust said: (...) In any case, I suggest changing the code to no longer use the modal MsgBox, but the event one This would avoid creating problems with the DoEvents. For example, removing the block that I pasted on and modifying the click event of the three options (Yes, Cancel, No) (...) With these changes you can use the MessageBox also with the Wait For Regard Click to expand... Hi, @Star-Dust , I liked very much your approach to create message-boxes "dynamically", and I'd like to use it with the Async/Wait For mechanism. But I didn't understand what event/response/sub to wait for. Could you please elaborate your previous reply demonstrating: - how to create/call the MsgBox3 object so that it is compatible with an assynchronous usage - how to wait for the response/choice the user has selected. The doubt is how to change this: B4X: Copy Dim I As Int = MsgBox4("Message","MsgBox4 - Style 2","Yes","Cancel","No",1) If I=DialogResponse.POSITIVE Then (...) to an implementation like this: B4X: Copy MsgBox4("Message","MsgBox4 - Style 2","Yes","Cancel","No",1) Wait For(<<something>>) Complete (I As Int) If I=DialogResponse.POSITIVE Then (...) What is the <<something>> we should wait for? Besides that, any other ajustments needed in the code?
Star-Dust said: (...) In any case, I suggest changing the code to no longer use the modal MsgBox, but the event one This would avoid creating problems with the DoEvents. For example, removing the block that I pasted on and modifying the click event of the three options (Yes, Cancel, No) (...) With these changes you can use the MessageBox also with the Wait For Regard Click to expand... Hi, @Star-Dust , I liked very much your approach to create message-boxes "dynamically", and I'd like to use it with the Async/Wait For mechanism. But I didn't understand what event/response/sub to wait for. Could you please elaborate your previous reply demonstrating: - how to create/call the MsgBox3 object so that it is compatible with an assynchronous usage - how to wait for the response/choice the user has selected. The doubt is how to change this: B4X: Copy Dim I As Int = MsgBox4("Message","MsgBox4 - Style 2","Yes","Cancel","No",1) If I=DialogResponse.POSITIVE Then (...) to an implementation like this: B4X: Copy MsgBox4("Message","MsgBox4 - Style 2","Yes","Cancel","No",1) Wait For(<<something>>) Complete (I As Int) If I=DialogResponse.POSITIVE Then (...) What is the <<something>> we should wait for? Besides that, any other ajustments needed in the code?
tagwato Member Licensed User Longtime User Apr 8, 2023 #9 tagwato said: What is the <<something>> we should wait for? Besides that, any other ajustments needed in the code? Click to expand... Never mind, I think I have found a solution. Changed the signature of the MsgBox3 and MsgBox4 subs, so that they are now "ResumableSub". And using them like this: B4X: Copy Dim rs As ResumableSub = MsgBox3("Message","MsgBox3","Yes","Cancel","No") Wait For(rs) Complete (I As Int) If I=DialogResponse.POSITIVE Then (...) The full adjusted project is attached, if anyone is interested. Attachments Home-made-MsgBoxes-using-Wait-For.zip Home-made-MsgBoxes-using-Wait-For.zip 7.9 KB · Views: 523 Last edited: Apr 25, 2023
tagwato said: What is the <<something>> we should wait for? Besides that, any other ajustments needed in the code? Click to expand... Never mind, I think I have found a solution. Changed the signature of the MsgBox3 and MsgBox4 subs, so that they are now "ResumableSub". And using them like this: B4X: Copy Dim rs As ResumableSub = MsgBox3("Message","MsgBox3","Yes","Cancel","No") Wait For(rs) Complete (I As Int) If I=DialogResponse.POSITIVE Then (...) The full adjusted project is attached, if anyone is interested.