locked
Direct Window0 Button click to open (same) Window1 .AddBrowser (not new Window1 ) ? RRS feed

  • Question

  • Hello & Thanks ;
    Direct Window0 Button click to Window1 .AddBrowser ? 

    In code below I dont want to keep opening a 'new window',
    instead have only 1 Browser Window1 visible at all times .
    How can I overlay Window1  OR  
    Delete Window1 Then create new instance of Window1 ? 

    Pls , need example code .

    Thanks for your Help..

    Initialise()
    While ("True")
      Program.Delay(20)
    EndWhile
    
    '============================================
    'SUBROUTINES
    '============================================
    Sub Initialise
      'Buttons
      buttonLabel[1] = "/ListenReadWatch.html"
      buttonLabel[2] = "/home?forum=smallbasi"
      buttonLabel[3] = "file:///C:/Users/"
      buttonLabel[4] = "www.google.com"
      numButton = Array.GetItemCount(buttonLabel)
      buttonWidth = 175
      For i = 1 To numButton
        button[i] = Controls.AddButton(buttonLabel[i],(buttonWidth+10)*(i-1),10)
        Controls.SetSize(button[i],buttonWidth,30)
      EndFor
      'Window size
      GraphicsWindow.Width = numButton*(buttonWidth+10)+10 ' + 160
      Controls.ButtonClicked = OnButtonClicked
    EndSub ' Initialized
    
    Sub OnButtonClicked
      '' * To open an url in browser:
      If (Controls.LastClickedButton = button[1]) Then
        url = "http://vmars.us/reads/ListenReadWatch.html"
        browser = LDControls.AddBrowser(800,600, url)
        
      ElseIf (Controls.LastClickedButton = button[2]) Then
        ' * To open an url in IE BrowserControl in GraphicsWindow:
        url = "https://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasic"
        browser = LDControls.AddBrowser(800,600, url)
        
      ElseIf (Controls.LastClickedButton = button[3]) Then
        ' * To open a local htm(l) file on your drive in IE BrowserControl in GW:
        url = "file:///C:/Users/vmars/Desktop/~reads/ListenReadWatch.html"
        browser = LDControls.AddBrowser(800,600, url)
        
      ElseIf (Controls.LastClickedButton = button[4]) Then
        browser = LDControls.AddBrowser(600, 600, "https://www.google.com")
      EndIf
    EndSub ' OnButtonClicked






    "All things in moderation, except for love and forgiveness."...vm

    Saturday, August 8, 2020 12:50 PM

Answers

  • You have to move those two lines to a position before the call to "initialise", or as the first lines in "initialise" as they are used in that subroutine.

    Jan [ WhTurner ] The Netherlands


    Sunday, August 9, 2020 9:00 AM
    Answerer
  • Hi vmars316.  In your code, following two lines never be executed, so both variables assumed as zero.  Then the button becomes invisible.

     buttonWidth = 50
     buttonHeight = 30
    

     

    Nonki Takahashi

    • Marked as answer by vmars316 Sunday, August 9, 2020 1:47 PM
    Sunday, August 9, 2020 3:12 AM

All replies

  • Hi vmars316, I wrote a sample HXT563 using only one Window.  Please check.

    Nonki Takahashi

    Saturday, August 8, 2020 4:26 PM
  • Hey Thanks Nonki  ;

    Thats Great new that we can have Buttons and Browser on same Window

    I am encouraged .

    Still I have one problem:

    1) I am unable to duplicate 'Buttons and Browser on same Window' in my code (1st below) . Pls , what are you doing in your code (2nd below) 'Buttons and Browser on same Window' that allows you to do that , where as my code can't .

    Thanks for your Help...

    ' One Window One Button
    Initialise()
    While ("True")
      Program.Delay(20)
    EndWhile
    
    buttonWidth = 50
    buttonHeight = 30
    
    Sub Initialise
    button1 = Controls.AddButton("BACK", 100, 2)
    Controls.SetSize(button1,buttonWidth , buttonHeight)
    'Controls.ButtonClicked = OnButtonClicked
    
    GraphicsWindow.ShowMessage("Controls.AddButtonr", "VM")
        Controls.Remove(browser)
        url = "https://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasic"
        browser = LDControls.AddBrowser(800,600, url)
        Controls.Move(browser, 0, 50)
    EndSub ' Initialize

    ' Controls.Remove/Move-HXT563.sb
    ' Sample using Controls.Remove and Controls.Move
    
    Initialise()
    While ("True")
      Program.Delay(20)
    EndWhile
    
    '============================================
    'SUBROUTINES
    '============================================
    Sub Initialise
      'Buttons
      buttonLabel[1] = "/ListenReadWatch.html"
      buttonLabel[2] = "/home?forum=smallbasi"
      buttonLabel[3] = "file:///C:/Users/"
      buttonLabel[4] = "www.google.com"
      numButton = Array.GetItemCount(buttonLabel)
      buttonWidth = 175
      For i = 1 To numButton
        button[i] = Controls.AddButton(buttonLabel[i],(buttonWidth+10)*(i-1),10)
        Controls.SetSize(button[i],buttonWidth,30)
      EndFor
      'Window size
    '  GraphicsWindow.Width = numButton*(buttonWidth+10)+10 ' + 160
      Controls.ButtonClicked = OnButtonClicked
    EndSub ' Initialized
    
    Sub OnButtonClicked
      '' * To open an url in browser:
      If browser <> "" Then
        Controls.Remove(browser)
      EndIf
      If (Controls.LastClickedButton = button[1]) Then
        Controls.Remove(browser)
        url = "http://vmars.us/reads/ListenReadWatch.html"
        browser = LDControls.AddBrowser(800,600, url)
        Controls.Move(browser, 0, 50)
    
      ElseIf (Controls.LastClickedButton = button[2]) Then
        ' * To open an url in IE BrowserControl in GraphicsWindow:
        Controls.Remove(browser)
        url = "https://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasic"
        browser = LDControls.AddBrowser(800,600, url)
        Controls.Move(browser, 0, 50)
    
      ElseIf (Controls.LastClickedButton = button[3]) Then
        ' * To open a local htm(l) file on your drive in IE BrowserControl in GW:
        Controls.Remove(browser)
        url = "file:///C:/Users/vmars/Desktop/~reads/ListenReadWatch.html"
        browser = LDControls.AddBrowser(800,600, url)
        Controls.Move(browser, 0, 50)
    
      ElseIf (Controls.LastClickedButton = button[4]) Then
        Controls.Remove(browser)
    '    browser = LDControls.AddBrowser(600, 600, "https://www.google.com")
      browser = FCControls.AddWebBrowser(600, 600)
      FCControls.SetUrlOfWebBrowser(browser,"https://www.google.com") 
    Controls.Move(browser, 0, 50)
      EndIf
    EndSub ' OnButtonClicked


    "All things in moderation, except for love and forgiveness."...vm

    Saturday, August 8, 2020 8:37 PM
  • Hi vmars316.  In your code, following two lines never be executed, so both variables assumed as zero.  Then the button becomes invisible.

     buttonWidth = 50
     buttonHeight = 30
    

     

    Nonki Takahashi

    • Marked as answer by vmars316 Sunday, August 9, 2020 1:47 PM
    Sunday, August 9, 2020 3:12 AM
  • You have to move those two lines to a position before the call to "initialise", or as the first lines in "initialise" as they are used in that subroutine.

    Jan [ WhTurner ] The Netherlands


    Sunday, August 9, 2020 9:00 AM
    Answerer
  • Ah perfect Thanks Nonki


    "All things in moderation, except for love and forgiveness."...vm

    Sunday, August 9, 2020 1:41 PM