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 » TabCtrl » TabCtrl related question
TabCtrl related question [message #55110] Sun, 11 October 2020 18:04 Go to next message
sinpeople is currently offline  sinpeople
Messages: 29
Registered: October 2020
Location: Singapore
Promising Member

Hi folks,

I have developed a dialog-based application which works ok.

Now I want to extend the program into multiple instances under a TabCtrl. Basically, I need to downgrade the <TopWindow> main window to some low level one, such that it can be added to a TabCtrl.

How I can do that? I searched "TabCtrl" in the code coming from the installation package. The 2x examples are both having different layout for the tabbed window. My case is much simpler. I want to chain multiple instance of a window layout to TabCtrl. But I don't know what I should do to achieve this.

The code of my current dialog program is the following:

class MainWindow : public WithMainWindowLayout<TopWindow>, public CallbackQueue, public Reader::Notify, public Writer::Notify, public RpcCmder::Notify
{
public: //thread GUI
	MainWindow(int nPort);
	
public: //thread Worker
	virtual void OnReplyRead(int nData, int x2, String s) {Request(&MainWindow::SaveReadResult,nData,x2,s);}
	virtual void OnReplyWrite(int nData, int x2, String s) {Request(&MainWindow::SaveWriteResult,nData,x2,s);}
	virtual void OnReplyRpcCmd(int nData, int x2, String s) {Request(&MainWindow::SaveRpcCmdResult,nData,x2,s);}

private:
	void ReadSensors() {reader.Request(&Reader::ReadSensors);}
	void WriteCtrl(int nData) {writer.Request(&Writer::WriteCtrl, nData);}
	void RpcCmd(UrrRequest r) {rpcCmder.Request(&RpcCmder::RpcCmd, r);}
	void SaveReadResult(int nData, int x2, String s);
	void SaveWriteResult(int nData, int x2, String s);
	void SaveRpcCmdResult(int nData, int x2, String s);
	
	void SpawnTasks();
	void AddDataToAlgoQueue(String strTimeStamp, int nData);
	void AddDataToLoggerQueue(String strTimeStamp, int nData);
	
	void DoTasksAndStatistics();
	
}


Thank you very much!


Best Regards
David
Re: TabCtrl related question [message #55124 is a reply to message #55110] Mon, 12 October 2020 23:21 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
you can replace TopWindow with ParentCtrl,
class MainWindow : public WithMainWindowLayout<ParentCtrl>, public CallbackQueue, public Reader::Notify, public Writer::Notify, public RpcCmder::Notify

then

	TabDlg dlg;
	MainWindow tab[5];
	
	for(int i = 0; i < 5; i++)
	    dlg(tab[i], String("Tab")<<i);

        dlg .OKCancel()
	   .Title("Tab dialog");
	dlg.Run();





regards
omari.
Re: TabCtrl related question [message #55136 is a reply to message #55124] Tue, 13 October 2020 14:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
omari wrote on Mon, 12 October 2020 23:21
you can replace TopWindow with ParentCtrl,
class MainWindow : public WithMainWindowLayout<ParentCtrl>, public CallbackQueue, public Reader::Notify, public Writer::Notify, public RpcCmder::Notify

then

	TabDlg dlg;
	MainWindow tab[5];
	
	for(int i = 0; i < 5; i++)
	    dlg(tab[i], String("Tab")<<i);

        dlg .OKCancel()
	   .Title("Tab dialog");
	dlg.Run();





I believe it should work with TopWindow too... (thats just BTW, ParentCtrl is the correct approach)
Re: TabCtrl related question [message #55137 is a reply to message #55110] Tue, 13 October 2020 14:27 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sinpeople wrote on Sun, 11 October 2020 18:04
Hi folks,

I have developed a dialog-based application which works ok.

Now I want to extend the program into multiple instances under a TabCtrl. Basically, I need to downgrade the <TopWindow> main window to some low level one, such that it can be added to a TabCtrl.

How I can do that? I searched "TabCtrl" in the code coming from the installation package. The 2x examples are both having different layout for the tabbed window. My case is much simpler. I want to chain multiple instance of a window layout to TabCtrl. But I don't know what I should do to achieve this.

The code of my current dialog program is the following:

class MainWindow : public WithMainWindowLayout<TopWindow>, public CallbackQueue, public Reader::Notify, public Writer::Notify, public RpcCmder::Notify
{
public: //thread GUI
	MainWindow(int nPort);
	
public: //thread Worker
	virtual void OnReplyRead(int nData, int x2, String s) {Request(&MainWindow::SaveReadResult,nData,x2,s);}
	virtual void OnReplyWrite(int nData, int x2, String s) {Request(&MainWindow::SaveWriteResult,nData,x2,s);}
	virtual void OnReplyRpcCmd(int nData, int x2, String s) {Request(&MainWindow::SaveRpcCmdResult,nData,x2,s);}

private:
	void ReadSensors() {reader.Request(&Reader::ReadSensors);}
	void WriteCtrl(int nData) {writer.Request(&Writer::WriteCtrl, nData);}
	void RpcCmd(UrrRequest r) {rpcCmder.Request(&RpcCmder::RpcCmd, r);}
	void SaveReadResult(int nData, int x2, String s);
	void SaveWriteResult(int nData, int x2, String s);
	void SaveRpcCmdResult(int nData, int x2, String s);
	
	void SpawnTasks();
	void AddDataToAlgoQueue(String strTimeStamp, int nData);
	void AddDataToLoggerQueue(String strTimeStamp, int nData);
	
	void DoTasksAndStatistics();
	
}


Thank you very much!


Best Regards
David


I might be wrong in understanding the issue, but maybe you should have

Array<MainWindow> tab;

somewhere. Then use tab.Add() to create the widgets that you put into TabCtrl.

Mirek
Previous Topic: How do I change TabCtrl tab size
Next Topic: [PROPOSAL] Adding GetCtrlGroup() method to TabBarCtrl.
Goto Forum:
  


Current Time: Fri Mar 29 15:58:58 CET 2024

Total time taken to generate the page: 0.01973 seconds