Android Code Snippet SD: MsgBox re-stylized

Discussion in 'Code Snippets' started by Star-Dust, Apr 20, 2017.

  1. Star-Dust

    Star-Dust Expert Licensed User

    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.png msgbox4.png msgbox5.png msgbox6.png


    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
     

    Attached Files:

    Last edited: Oct 23, 2017
  2. Star-Dust

    Star-Dust Expert Licensed User

    UPDATE:

    Created MsgBox class and variation management screen orientation

    Use:
    Code:
    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
    marcellissimo likes this.
  3. jnjft

    jnjft Member Licensed User

    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
     
  4. Star-Dust

    Star-Dust Expert Licensed User

    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:
    Sub MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As StringAs 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:
    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:
    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
     
  5. jnjft

    jnjft Member Licensed User

    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:
    Sub PanelMsgBox3_Touch (Action As Int, X As Float, Y As Float)
    Dim P as Panel = Sender
    P.RemoveView
     
  6. jnjft

    jnjft Member Licensed User

    Is there a possibility to simulate the panel touch event? I had no success with calling PanelMsgBox3_Touch(0, 10, 10).

    Regards
    Johann
     
  7. Star-Dust

    Star-Dust Expert Licensed User

    Make Public a Sub.
     
Loading...