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 » TopWindow&PopUp, TrayIcon » how to communicate between windows?
Re: how to communicate between windows? [message #29617 is a reply to message #29615] Thu, 04 November 2010 08:33 Go to previous messageGo to previous message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hello Bonami,

Here is your example, modified to notify other window about a event. I've used PostCallback to do that, no MT Smile

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class B : public TopWindow
{
	public:
	B()
	{
		SetRect(220, 10, 200, 200);
		Add(l.VCenterPos(30).HCenterPos(180));
		l.SetText("Test");
	}
	Label l;
	void ShowMessage(const String& msg)
	{
		l.SetText(msg);
	}
};

class A : public TopWindow
{
  typedef A CLASSNAME;
  public:
  A()
  {
    SetRect(10, 10, 200, 200);
    ButA.SetLabel("Button A");
    ButB.SetLabel("Button B");
    Add(ButA.LeftPos(5, 80).TopPos(5, 25)); 
    Add(ButB.LeftPos(5, 80).TopPos(35, 25));
    ButA <<= THISBACK(Button_A);
    ButB <<= THISBACK(Button_B);
  }
  B b;
  void shown() { b.OpenMain(); }
  Button ButA;
  Button ButB;
  void Button_A()
  {
	b.PostCallback(callback1(&b, &B::ShowMessage, "Button A pressed"));
  }
  void Button_B()
  {
  	b.PostCallback(callback1(&b, &B::ShowMessage, "Button B pressed"));   
  }
};

GUI_APP_MAIN
{
  A a;
  a.OpenMain();
  a.shown();
  Ctrl::EventLoop();
}


Andrei
 
Read Message icon1.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Crash on ToolTip painting
Next Topic: TrayIcon Tool tips text lenght limited
Goto Forum:
  


Current Time: Thu May 16 19:53:12 CEST 2024

Total time taken to generate the page: 0.04267 seconds