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 » Community » Newbie corner » Just want to set the text of window (Setting text to the parent window)
Re: Just want to set the text of window [message #58658 is a reply to message #58657] Mon, 11 July 2022 09:30 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1215
Registered: August 2007
Senior Contributor
Hello mrk10000, and welcome to the U++ forums!

The example below demonstrates the setting and getting of a window title. It should swap the button and window title.

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyApp : TopWindow {
	TabCtrl tabs;
	ParentCtrl pctrl;
	Button bt;
	MyApp()
	{
		Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 640, 480);
		Title("Window Title"); // Sets the window title.
		tabs.Add(pctrl.SizePos(), "Tab1");
		pctrl.Add(bt.SetLabel("Change Title (and button label)").HCenterPos(400).VCenterPos(100));
		Add(tabs.SizePos());
		bt << [=] {
			auto *w = GetTopWindow();
			if(w) {
				String s = w->GetTitle().ToString(); // Get top window's title
				w->Title(bt.GetLabel()); // set the top window's title
				bt.SetLabel(s); //swap the label with the current window title.
			}
		};
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}




Best regards,
Oblivion


[Updated on: Mon, 11 July 2022 09:32]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: Is there any way to tell TheIDE to store settings in user's personal directory?
Next Topic: Where to Download
Goto Forum:
  


Current Time: Fri Jul 18 08:17:20 CEST 2025

Total time taken to generate the page: 0.04071 seconds