Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Dialog As B4XDialog
    Private Ch As CheckBox
End Sub
Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")  'has button1    
End Sub
Sub Button1_Click
    Dialog.Initialize(Root)
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 500dip, 500dip)
    p.LoadLayout("MyDialog3")   'has your checkbox
    p.SetColorAndBorder(xui.Color_Cyan, 6dip, xui.Color_Black, 10dip)
    Dim rs As ResumableSub = Dialog.ShowCustom(p, "OK", "", "CANCEL")
    
    Ch.Color = xui.Color_White
    Ch.Checked =False ' user cannot change it. If it is set to false it stays false even if user clicks it
    Ch.Enabled =False
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log(Ch.Checked)
    End If
End Sub