[Solved] overlapping gadgets

Everything else that doesn't fall into one of the other PB categories.
k3pto
User
User
Posts: 87
Joined: Sat Jan 17, 2015 5:24 pm

[Solved] overlapping gadgets

Post by k3pto »

My application has gadgets (editor and text) which overlap. Is there a way to dynamically control which gadget is on top?

Thank you all for your responses. I will look at each one and give them a try to see which works best for me.

Thanks again to BarryG. That solution was easy and works quite nicely!
Last edited by k3pto on Sat Aug 10, 2024 12:57 am, edited 2 times in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6312
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: overlapping gadgets

Post by mk-soft »

Purebasic does not support overlapping gadgets.
It is also generally not good for the operation of the GUI if controls overlap.
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
BarryG
Addict
Addict
Posts: 4218
Joined: Thu Apr 18, 2019 8:17 am

Re: overlapping gadgets

Post by BarryG »

Not officially supported, but it can be done on Windows. Here's an example for k3pto:

Code: Select all

Procedure GadgetAlwaysOnBottom(gad)
  id=GadgetID(gad)
  SetWindowLongPtr_(id,#GWL_STYLE,GetWindowLongPtr_(id,#GWL_STYLE)|#WS_CLIPSIBLINGS)
  SetWindowPos_(id,#HWND_BOTTOM,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE)
EndProcedure

OpenWindow(0,640,480,270,120,"Gadget overlap example")

EditorGadget(1,10,10,200,80)
SetGadgetText(1,"EditorGadget")

TextGadget(2,70,40,180,70,"TextGadget",#PB_Text_Border)

GadgetAlwaysOnBottom(1) ; Change this to 1 or 2 to choose which goes on bottom.

SetActiveGadget(1)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Re: overlapping gadgets

Post by ebs »

This might be too simplistic, but on the few occasions where I needed to do this, I made one of the two gadgets visible and the other invisible.

Having only one of the overlapping gadgets visible at a time didn't seem to cause any GUI problems, at least none that I could see.
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: overlapping gadgets

Post by PBJim »

ebs wrote: Tue Aug 06, 2024 2:19 pm This might be too simplistic, but on the few occasions where I needed to do this, I made one of the two gadgets visible and the other invisible. Having only one of the overlapping gadgets visible at a time didn't seem to cause any GUI problems, at least none that I could see.
Agreed ebs, I have done likewise and concluded that the Windows GUI is not averse to it. In fact, it isn't always necessary to be concerned with their visibility — as the below TextGadget already located within the area of the ListIconGadget shows. Even the Freegadget can be omitted and it still works.

Code: Select all

SearchListWindow = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 771, 410, "List of widgets", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

List_Icon_0 = ListIconGadget(#PB_Any, 0, 0, 771, 410, "Widget code", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)

; Status located within area of ListIconGadget
status = TextGadget(#PB_Any, 322, 190, 200, 40, "Building list, please wait...")

AddGadgetColumn(List_Icon_0, 1, "Description", 275)
AddGadgetColumn(List_Icon_0, 2, "Group", 50)
AddGadgetColumn(List_Icon_0, 3, "Unit", 50)
AddGadgetColumn(List_Icon_0, 4, "List description", 275)

AddGadgetItem(List_Icon_0, -1, "Column 1" + #LF$ + "Column 2" + #LF$ + "Col 3" + #LF$ + "Col 4" + #LF$ + "Column 5")

Delay(3000) ; ----- Build item list here

; Free the waiting message
FreeGadget(status)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply