locked
Hide TextWindow without exiting whole program RRS feed

  • Question

  • Suppose a programm like following sample:

    Text = "Some text to show in TW"
    ConOn = ""

    Controls.AddTextBox(10,10)
    Controls.SetTextBoxText("TextBox1",Text)
    Controls.AddButton("Show in TW",10,100)

    Controls.ButtonClicked = OnButtonClick

    Sub OnButtonClick
      If ConOn Then
        TextWindow.Hide()
        Controls.SetButtonCaption("Button1","Show TW")
        ConOn = ""
      Else
        TextWindow.WriteLine(Controls.GetTextBoxText("TextBox1"))
        Controls.SetButtonCaption("Button1","Hide TW")
        ConOn = "True"
      EndIf
    EndSub

    Sometimes one forgets to close TW by the GW-button and clicks 'Close' button on TW, which exits whole program. That's just annoying every time it happens.  So, is there a way to keep GraphicsWindow open and the program running, when TW ist closed or disable the Exit-Button on TW??

    I tried TextWindowPlus.CloseButtonEnabled = "False" from DataExt, but oddly this works only the first time TW is opened+closed, but then not more during the same runtime.

    Thanks

    Sunday, March 9, 2014 9:21 PM
    Answerer

Answers

  • Added a method to disable the X button on a window.

    My test code:

    TextWindow.Show()
    LDUtilities.ExitButtonMode(TextWindow.Title,"Disabled")
    Program.Delay(5000)
    LDUtilities.ExitButtonMode(TextWindow.Title,"Enabled")

    New version uploaded with this.

    Also added LDInline (+ sample LDInline.sb) which allows C# and VB code to be included in SB program (or files via File.ReadContents) - a sort of build-you-own extension functions and a bit more.  It is a bit advanced but provides lots of potential to do interesting things as well as a stepping stone from SB to C#.

    Sunday, March 9, 2014 11:06 PM

All replies

  • Added a method to disable the X button on a window.

    My test code:

    TextWindow.Show()
    LDUtilities.ExitButtonMode(TextWindow.Title,"Disabled")
    Program.Delay(5000)
    LDUtilities.ExitButtonMode(TextWindow.Title,"Enabled")

    New version uploaded with this.

    Also added LDInline (+ sample LDInline.sb) which allows C# and VB code to be included in SB program (or files via File.ReadContents) - a sort of build-you-own extension functions and a bit more.  It is a bit advanced but provides lots of potential to do interesting things as well as a stepping stone from SB to C#.

    Sunday, March 9, 2014 11:06 PM
  • You could hide the close button under the GW.

    If you do this the TW steals focus when TW.Hide() is used.

    Since SB has no native method to GetFocus I created a Sub called SecureFocus(). It creates a bit of flicker because it reinitialise the windows.

    IntialiseWindows()
    InitialiseOther()
    
    While "True"
      If buttonClicked Then
        toggleBtn = -toggleBtn    
        
        If toggleBtn = 1 Then      
          TextWindow.Hide()  '<<< TW steals focus
          Controls.SetButtonCaption(btn, "Show in TW")
        Else      
          SecureFocus()
          TextWindow.WriteLine(Controls.GetTextBoxText(txtBox))
          Controls.SetButtonCaption(btn, "Hide TW")
        EndIf
        
        buttonClicked = "False"
      EndIf  
      
      Program.Delay(20)
    EndWhile
    
    Sub IntialiseWindows
      TextWindow.Top = 10
      TextWindow.Left = 10  
      GraphicsWindow.Top = TextWindow.Top
      GraphicsWindow.Left = 500   
    EndSub
    
    Sub InitialiseOther
      toggleBtn = 1
      txt = "Hello" 
      
      Controls.ButtonClicked = OnButtonClick
      
      btn = Controls.AddButton("Show in TW", 10, 50)
      txtBox = Controls.AddTextBox(10, 10)
      Controls.SetTextBoxText(txtBox, txt)
      
      TextWindow.Hide()
    EndSub
    
    Sub OnButtonClick
      buttonClicked = "True"
    EndSub
    
    Sub SecureFocus  
      GraphicsWindow.Hide()
      IntialiseWindows()
      GraphicsWindow.Show()
    EndSub


    • Edited by Jibba j Monday, March 10, 2014 3:44 AM hide close under GW
    Monday, March 10, 2014 12:01 AM
  • Thanks LitDev & Jibba Jabba,

    @LitDev,

    ExitButtonMode works perfect for sample excerpt and full progs. Thanks a lot.

    LDInline seams so powerfull. First could'nt fullly understand what means 'SB & C#', but after running sample sight is clear. I see, it's similar to FCExtensions.Eval, that invokes vbc.exe (.NET2) on %TEMP%\????????.vb/.cmdline/.dll/.err/.out/.tmp, i could catch one time.

    Info: Users on 32-bit machines need to change 3 paths (lines 11-13) in sample "LDInline.sb" from "\Program Files (x86)\" to "\Program Files\"

    and folder where dll(s) will be created need write access. For me it did'nt work in %ProgramFiles%\MS\SB\Projects but fine in eg. %TEMP%, C:\Temp, etc.

    Gonna try to find a cheatsheet with dll-names and according functions and run some tests this evening.

    btw: here's german xml for LitDevDe_v1-0-0-101

    @Jibba Jabba,

    Had activated X-Mouse under suspect, after i read your comment about 'Focus', but it seems there's no unexpected hoovering effect from that. But code works and i'll have to follow how it works. The problem is when you look to see whats in the TW and move mouse on TW its on top again the next moment from X-Mouse, which does'nt prevent closing at least.

    Thanks guys


    Monday, March 10, 2014 7:09 PM
    Answerer
  • Thanks for De xml and pointers to my usual set of typos.
    Monday, March 10, 2014 7:39 PM
  • Hi PL

    It seems TW.Hide steals the focus so I put in the SecureFocus() sub GW.Hide which seems to steal it back.

    For a native solution to the mouse hover situation you maybe able to do something with the mouse methods. But this would exclude scrolling in TW. This could be contrary to the idea of windows since it's nice to have the mouse available all over the desktop at all times except for full screen modes.

    I reckon these are verbose native solutions but fun and good for learning I think. That's what I love about SB, it makes you do more featured stuff by having to code it.




    • Edited by Jibba j Monday, March 10, 2014 8:09 PM
    Monday, March 10, 2014 7:52 PM