Page 1 of 1
[Solved] overlapping gadgets
Posted: Mon Aug 05, 2024 8:43 pm
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!
Re: overlapping gadgets
Posted: Tue Aug 06, 2024 12:32 am
by mk-soft
Purebasic does not support overlapping gadgets.
It is also generally not good for the operation of the GUI if controls overlap.
Re: overlapping gadgets
Posted: Tue Aug 06, 2024 3:00 am
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
Re: overlapping gadgets
Posted: Tue Aug 06, 2024 2:19 pm
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.
Re: overlapping gadgets
Posted: Tue Aug 06, 2024 4:01 pm
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