:ShowcaseMessage
  . Runs for every message the page sends (Message Received event of ShowcaseBrowser)
  If "[Exiting]" "=" "1"
    Return
  EndIf
  Math "[MsgCount]+1" "0" "[MsgCount]"
  If "[ShowcaseMsg]" "=" "exit"
    SetVar "[Exiting]" "1"
    Exit "" ""
    Return
  EndIf
  If "[ShowcaseMsg]" "=" "ready"
    SetVar "[PageReady]" "1"
    If "[CoverGone]" "<>" "1"
      BrowserV2PostMessage "ShowcaseBrowser" "hello|VisualNEO Win"
    EndIf
    If "[OnShowcase]" "=" "1"
      GoSub "RemoveCover"
    EndIf
    Return
  EndIf
  If "[ShowcaseMsg]" "=" "ping"
    BrowserV2PostMessage "ShowcaseBrowser" "toast:Hello from NeoScript at [Time]"
    Return
  EndIf
  If "[ShowcaseMsg]" "=" "random"
    Random "100" "[Rnd]"
    BrowserV2PostMessage "ShowcaseBrowser" "set:volume=[Rnd]"
    BrowserV2PostMessage "ShowcaseBrowser" "set:notify=1"
    Return
  EndIf
  If "[ShowcaseMsg]" "=" "about"
    ModernMessageBox "About this showcase" "Web Awesome and NexusUI controls running in a VisualNEO Win Modern Web Browser. Every control reports its value to NeoScript." "Information" "OK" "OK" "[AboutResult]" "Page to VNW: window.chrome.webview.postMessage. VNW to page: BrowserV2PostMessage. Controls can be set from NeoScript with set:<id>=<value>."
    Return
  EndIf
  . Anything else (ctl:<id>=<value>, text:...) is echoed back so the page can show the round trip
  BrowserV2PostMessage "ShowcaseBrowser" "vnw:#[MsgCount] [ShowcaseMsg]"
Return

:RemoveCover
  . Runs once, when the Showcase page is showing AND the page has loaded
  If "[CoverGone]" "=" "1"
    BrowserV2PostMessage "ShowcaseBrowser" "shown"
    Return
  EndIf
  SetVar "[CoverGone]" "1"
  . Give the browser time to paint at full size under the Cover
  Delay "700"
  HideObject "Cover" "None" "0"
  BrowserV2PostMessage "ShowcaseBrowser" "shown"
Return
