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)
Just want to set the text of window [message #58657] Mon, 11 July 2022 03:14 Go to next message
mrk10000 is currently offline  mrk10000
Messages: 7
Registered: April 2022
Promising Member
Why i cannot just set the windows text, it throws an exception, i have tried TopWindow->GetTitle, i look for examples but there is not one having child calling parent GetTitle or SetTitle

String tmp(this->GetTopWindow()->GetTitle().ToString() );
LOG(tmp);

The current layout was added to a parent TabCtrl with .Add
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: 1091
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

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 Mar 29 11:13:27 CET 2024

Total time taken to generate the page: 0.01836 seconds