Results 1 to 7 of 7

Thread: Cancel TBGL_Window-closebutton?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    Cancel TBGL_Window-closebutton?

    Is it possible to avoid closing the TBGL-Window via the System-Window-Close-Button ("X", up-right, red mostly if you point it)

    I want to ask my user, if he wants to save on exit ("Yes|No|Cancel")
    - but in case he closes the window using the system-close-button, i can only offer "Yes|No" currently
    (in some "lost-on-screen, small" msgbox that can be easily overseen because it has no parent...)
    since the window is closed and resources (as Fonts & Textures) are released already.

    Can i trap this?

    From visual basic i know there will be raised an event

    simplified example:

    Sub myWindow_Close(ByRef Cancel As Boolean)
    
      ' if the user sets: 
      Cancel = TRUE 
      ' within this sub then
      ' window won't close
    
    End Sub
    
    can we bind something as this:

    TBGL_BindWindowEvent( hWnd, %TBGL_OnWindowClose, "myWindow_Close")
    
    ???
    Last edited by ReneMiner; 30-11-2015 at 14:34.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Usually the way to prevent closing in User Interface scripts (and standard Windows) is to use this method:
    http://www.thinbasic.com/community/s...0172#post70172

    I do not know in TBGL Windows.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Rene,

    I think the easiest approach would be to eliminate the close box, if you don't want it.

    Instead of:
    %TBGL_WS_WINDOWED | %TBGL_WS_CLOSEBOX | %TBGL_WS_DONTKEEPASPECTRATIO
    
    ...use just:
    %TBGL_WS_WINDOWED | %TBGL_WS_DONTKEEPASPECTRATIO
    
    Another alternative would be embedding the TBGL into ThinBASIC dialog - then you can handle all events you need.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Binding the close event is technically possible. I am just scratching my head whether to go this route or not.
    I would not like to end up duplicating the UI stuff we already have in... UI module. Let me think about it!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    TBGL works windowed too - not limited to fullscreen only.
    So we should be able to react if the render-surface is about to disappear and to make sure the user really wants this before all resources are destroyed - or should we just rigorous create them again?

    I would not like have to port all stuff to a canvas - to rewrite all the input and to enlarge the final bundle about the size of UI-module for just this - since it's my intention not have to Uses "UI" nor Callbacks and the reason to create own controls only using TBGL_Rect & TBGL_PrintFont2d. Later I will add rendering quads and some simple to use texture-handling (mostly loading of many different file-formats) for some textured controls. Then the re-creation could become a little more effort.
    Still there's no window but just the small, easy to oversee msgbox that keeps the script running.

    I try to avoid to Declare external Subs & Functions as much as possible- so I'm already really happy about TBGL_PushLogicOp.

    But in case there were a possibility to use some win32-function that allows to cancel the window closing then i would prefer it over Uses "UI".
    I think there are missing some Forum-sections as beta-testing and support

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I think Petr was referring not to transform into a Canvass (too much work) but to have a TBGL control over a standard UI Window (TBGL_BindCanvas) in order to let the Window to handle non TBGL events in a callback.
    The rest would be handled as usual in TBGL.

    An example in C:\thinBasic\SampleScripts\TBGL\EntityBased\TBGL_Control_Targeting_GettingInfo.tbasic

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Eros got it exactly as I mentioned - on the other side I understand Rene's avoidance of multi-module scripts.
    I will have a look during weekend, I think I should be able to achieve what is needed


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •