Close parent window

Everything else that doesn't fall into one of the other PB categories.
User_Russian
Addict
Addict
Posts: 1543
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Close parent window

Post by User_Russian »

Why does the close window with ID 1 when the close window with ID 0?

Code: Select all

If OpenWindow(0, 0, 0, 400, 100, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindow(1, 200, 200, 200, 200,"",#PB_Window_MinimizeGadget, WindowID(0))
  AddWindowTimer(0, 123, 2500)
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Timer And EventTimer() = 123
      CloseWindow(0)
      Debug IsWindow(0)
      Debug IsWindow(1)
    EndIf    
    
  Until Event = #PB_Event_CloseWindow
EndIf

// Moved from "Bugs - Windows" to "General Discussion" (Kiffi)
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Close parent window

Post by mk-soft »

Because Window 1 is a child of Window 0.
When Window 0 is closed, all child objects are also closed.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User_Russian
Addict
Addict
Posts: 1543
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Close parent window

Post by User_Russian »

Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Close parent window

Post by Little John »

By definition, a child window is one that is dependent on a parent window and is closed when the parent window closes.
Fred cannot write everything about computer programming in the PB help.
User_Russian
Addict
Addict
Posts: 1543
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Close parent window

Post by User_Russian »

In PB doesn't have a cross-platform method to unbind a window from its parent window.
It is necessary that the window with ID 1 does not close.
AZJIO
Addict
Addict
Posts: 2191
Joined: Sun May 14, 2017 1:48 am

Re: Close parent window

Post by AZJIO »

put it away

Code: Select all

WindowID(0)
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Close parent window

Post by Little John »

User_Russian wrote: Thu Aug 03, 2023 10:27 am In PB doesn't have a cross-platform method to unbind a window from its parent window.
If you want such a method, you can make a feature request for it.
But asking for a change of the current correct behaviour when a parent window closes doesn't make sense. And it's not a bug anyway.
AZJIO
Addict
Addict
Posts: 2191
Joined: Sun May 14, 2017 1:48 am

Re: Close parent window

Post by AZJIO »

SetParent_() ?
set the parent window for the child window before closing the main window
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Close parent window

Post by jacdelad »

AZJIO wrote: Thu Aug 03, 2023 5:43 pm SetParent_() ?
set the parent window for the child window before closing the main window
...only on Windows.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Close parent window

Post by mk-soft »

Solution:
A little trick to prevent several windows from the same programme from being displayed in the taskbar.

Code: Select all

;-TOP by mk-soft

If OpenWindow(0, -1, -1, 0, 0, "WindowDoEvents", #PB_Window_BorderLess)
  If OpenWindow(1, 0, 0, 400, 100, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered, WindowID(0))
    OpenWindow(2, 200, 200, 200, 200,"",#PB_Window_MinimizeGadget, WindowID(0))
    AddWindowTimer(0, 123, 2500)
    
    Repeat
      Event = WaitWindowEvent()
      
      If Event = #PB_Event_Timer And EventTimer() = 123
        CloseWindow(1)
        RemoveWindowTimer(0, 123)
        Debug IsWindow(1)
        Debug IsWindow(2)
      EndIf    
      
    Until Event = #PB_Event_CloseWindow
  EndIf
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User_Russian
Addict
Addict
Posts: 1543
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Close parent window

Post by User_Russian »

AZJIO wrote: Thu Aug 03, 2023 5:43 pm SetParent_() ?
set the parent window for the child window before closing the main window
This does not work.

Code: Select all

If OpenWindow(0, 0, 0, 400, 100, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindow(1, 200, 200, 200, 200,"",#PB_Window_MinimizeGadget, WindowID(0))
  AddWindowTimer(0, 123, 2500)
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Timer And EventTimer() = 123
      ;SetParent_(WindowID(1), 0)
      SetParent_(WindowID(1), GetDesktopWindow_())
      CloseWindow(0)
      Debug IsWindow(0)
      Debug IsWindow(1)
    EndIf    
    
  Until Event = #PB_Event_CloseWindow
EndIf
Post Reply