Move a childwindow behind a parent window.

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Move a childwindow behind a parent window.

Post by blueznl »

The advantage of a child window is that it doesn't show up in the task bar, but still has the regular controls (maximize, minimize, full screen, resize etc).

However, it cannot be placed behind the parent window. It always floats above the parentwindow, it seems.

Is there a way to do that?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Move a childwindow behind a parent window.

Post by RASHAD »

Code: Select all

OpenWindow(0,0,0,800,600,"", #PB_Window_SystemMenu| #PB_Window_ScreenCentered)
OpenWindow(1,WindowX(0)-200,WindowY(0),400,300,"",#PB_Window_SystemMenu,WindowID(0))
ButtonGadget(0,10,10,80,24,"RUN")
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          run ! 1
          If run = 1
            SetWindowLongPtr_(WindowID(1), #GWLP_HWNDPARENT,GetDesktopWindow_())
            SetWindowLongPtr_(WindowID(0), #GWLP_HWNDPARENT,WindowID(1))
            BringWindowToTop_(WindowID(0))
          Else
            SetWindowLongPtr_(WindowID(0), #GWLP_HWNDPARENT,GetDesktopWindow_())
            SetWindowLongPtr_(WindowID(1), #GWLP_HWNDPARENT,WindowID(0))
            BringWindowToTop_(WindowID(1))
          EndIf
      EndSelect
  EndSelect
Until Quit = 1
Egypt my love
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Move a childwindow behind a parent window.

Post by blueznl »

RASHAD wrote: Sat Feb 04, 2023 8:47 pm

Code: Select all

...
That's one way to do it. I was wondering if we couldn't 'remove' the always-on-top effect of the child windows. I've seen other programs do it. My key reason for doing this is that I don't want to populate the taskbar with all my application windows.

It's not a biggy, but thanks for your example. I might fool around a bit more...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Move a childwindow behind a parent window.

Post by jacdelad »

Something like this (though it's not exactly a childwindow of the other window)?

Code: Select all

OpenWindow(0,0,0,800,600,"", #PB_Window_SystemMenu| #PB_Window_ScreenCentered|#PB_Window_Invisible)
OpenWindow(1,WindowX(0)-200,WindowY(0),400,300,"",#PB_Window_SystemMenu,WindowID(0))
OpenWindow(2,0,0,800,600,"", #PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ButtonGadget(0,10,10,80,24,"RUN")
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply