Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Deleting Ctrl from within itself
Re: Deleting Ctrl from within itself [message #52101 is a reply to message #52074] Fri, 19 July 2019 15:27 Go to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
- use Array
- key trick to situations like this is to use PostCallback to get "on top" of stack

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyApp : TopWindow {
	Array<Ctrl> ctrl;
	
	MyApp() {
		auto& b = ctrl.Create<Button>();
		Add(b.TopPos(10).LeftPos(10, 100));
		b.SetLabel("Close me!");
		b << [&] {
			PostCallback([=] { ctrl.Remove(0); });
		};
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}
 
Read Message
Read Message
Previous Topic: Problem with ScrollBar and multiple controls
Next Topic: Taking snapshot of GLCtrl no longer works
Goto Forum:
  


Current Time: Wed Jun 18 15:35:25 CEST 2025

Total time taken to generate the page: 0.05194 seconds