Best approach for placing a gadget above all other

Just starting out? Need help? Post your questions and find answers here.
User avatar
X0r
Enthusiast
Enthusiast
Posts: 138
Joined: Tue May 01, 2007 3:49 am
Location: Germany

Best approach for placing a gadget above all other

Post by X0r »

Hey guys,

I have a simple problem: in my current application, I want to pop up a container gadget with a notification (and a close button) above all other gadgets located on a specific window. What would be the best approach to do this? Additionally, applying transparency to the container gadget would be nice.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Best approach for placing a gadget above all other

Post by Danilo »

Use another borderless window and attach it to the parent window.
User avatar
X0r
Enthusiast
Enthusiast
Posts: 138
Joined: Tue May 01, 2007 3:49 am
Location: Germany

Re: Best approach for placing a gadget above all other

Post by X0r »

Simple and effective! Thanks!
User avatar
X0r
Enthusiast
Enthusiast
Posts: 138
Joined: Tue May 01, 2007 3:49 am
Location: Germany

Re: Best approach for placing a gadget above all other

Post by X0r »

Hello,

I have just implemented this method and I am using the move/resize event of the parent window in order move/resize the borderless window accordingly. However, I am experiencing a lag. Also, when clicking on the borderless window, the parent window loses its focus, which is not what I want.

Is there any other solution?
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Best approach for placing a gadget above all other

Post by IdeasVacuum »

Hi Xor - can you explain why the main window losing the focus is a problem? It's normal behaviour in MS Windows at least.

You could define your notifier window with a timer, such that there is nothing to click - that would prevent the notifier from 'taking' the focus. You could also, having detected that the notifier has the focus, immediately return focus to the main window.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Best approach for placing a gadget above all other

Post by Danilo »

If you need it for the Windows OS only, you could probably just add a child gadget (container for example) to the main window and set the z-order to topmost using SetWindowPos_().
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Best approach for placing a gadget above all other

Post by RASHAD »

Hi
For Windows

Code: Select all


flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Test",Flags)

ContainerGadget(0,-300,0,200,100 ,#PB_Container_Flat|#WS_CLIPSIBLINGS)
  TextGadget(1,10,10,100,26,"Please take care")
  ButtonGadget(2,10,60,60,26,"OK")
CloseGadgetList()

ListIconGadget(10,10,10,380,240,"Test",60, #PB_ListIcon_FullRowSelect |#WS_CLIPSIBLINGS)

ButtonGadget(20,10,260,60,26,"POP")
Repeat
           
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
      
      Case #PB_Event_Menu
          Select EventMenu()
           Case 1            
          EndSelect
      
      Case #PB_Event_Gadget
          Select EventGadget()
            Case 2
              ResizeGadget(0,-300,0,200,100)
            
            Case 20
              ResizeGadget(0,100,100,200,100)            
          EndSelect
  EndSelect 

Until Quit = 1
End
Egypt my love
User avatar
X0r
Enthusiast
Enthusiast
Posts: 138
Joined: Tue May 01, 2007 3:49 am
Location: Germany

Re: Best approach for placing a gadget above all other

Post by X0r »

Hi Xor - can you explain why the main window losing the focus is a problem? It's normal behaviour in MS Windows at least
Maybe I should provide a picture in order to make my goal clearer :D : https://2.bp.blogspot.com/-TBqSLm1Ky5Q/ ... _types.png

What I also want is to place a hyperlink as well as a button gadget on the notification container, and I definitely do not want the parent window to lose its focus. Apart from that, the lag issue is very annoying.

I will use the method suggested by Danilo and RASHAD, thanks.
User avatar
Caronte3D
Addict
Addict
Posts: 1055
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Best approach for placing a gadget above all other

Post by Caronte3D »

I use this approach (found somewhere on this forum) to be able to click through window and don't lose focus

Code: Select all

OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 300, 30, "depends...")

SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_(WindowID(0), 0, 150, #LWA_ALPHA)

StickyWindow(0, 1)

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EDIT: Found source post: viewtopic.php?p=521630#p521630
Post Reply