I have a question about gadgets that contain other gadgets, like the PanelGadget.
I use AddGadgetItem to add a new panel to a PanelGadget. Then I add other gadgets to it. At some point, I want to remove the panel by using RemoveGadgetItem. Do I have to first remove each of the gadgets added to this panel? Or does removing the panel automatically remove the contained gadgets?
I know that visually there is no need to remove the contained gadgets. But I want to know if that leaves behind unnecessary stuff.
Thank you,
Robert
Add and Remove containers
-
- User
- Posts: 71
- Joined: Thu May 02, 2019 3:57 am
- Location: USA
- Contact:
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: Add and Remove containers
I tested it with WinSpy.exe. After the removal also the sub-gadgets of PureBasic will be removed.
According to the memory, the handles are also released.
According to the memory, the handles are also released.
-
- User
- Posts: 71
- Joined: Thu May 02, 2019 3:57 am
- Location: USA
- Contact:
Re: Add and Remove containers
Thank you for your reply.
There is however a problem I noticed. If a subgadget has been bound to an event handling callback procedure which is shared with other subgadgets from another container (like a "Help" button that shows the same text from any panel), then you MUST unbind the subgadgets before removing their container. Otherwise, the callback may be triggered unexpectedly.
Maybe these are things that should be added to the PB documentation.
Robert
There is however a problem I noticed. If a subgadget has been bound to an event handling callback procedure which is shared with other subgadgets from another container (like a "Help" button that shows the same text from any panel), then you MUST unbind the subgadgets before removing their container. Otherwise, the callback may be triggered unexpectedly.
Maybe these are things that should be added to the PB documentation.
Robert
Re: Add and Remove containers
I think I've experienced this before too, although I never formally tested or reported it.RobertRioja wrote:There is however a problem I noticed. If a subgadget has been bound to an event handling callback procedure which is shared with other subgadgets from another container (like a "Help" button that shows the same text from any panel), then you MUST unbind the subgadgets before removing their container. Otherwise, the callback may be triggered unexpectedly.
Maybe it should be a Bug Report or Feature Request to immediately unbind callbacks upon freeing.
Or, maybe it's already doing that, but there are already calls in the queue that happen right after the gadget is released? Hmm...
-
- User
- Posts: 71
- Joined: Thu May 02, 2019 3:57 am
- Location: USA
- Contact:
Re: Add and Remove containers
I tested it and found that it is definitely a problem. Bogus events pop up. So you really should unbind before removing. I will post it as a bug.
Robert
Robert