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  |
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  |
Oblivion
Messages: 1202 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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 11 July 2022 09:32] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:55:08 CEST 2025
Total time taken to generate the page: 0.00932 seconds
|