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 » Windows that cant leave Mainwindow
Windows that cant leave Mainwindow [message #30469] Mon, 03 January 2011 11:33 Go to next message
Jschn88 is currently offline  Jschn88
Messages: 2
Registered: January 2011
Junior Member
Hello Guys !

While doing my first steps in U++, i got a problem concerning the organisation of my windows.
I would be verry happy to get this:
There is a main window that gives me in any way the facility to open other Windows. Ok that still works.
But now i meet a problem:
The subwindows should only be moved arround in the mainwindow and are not allowed to leave it.
I can't find anything concerning this, maybe i read it but didn't get it right ^^.
I hope im right here with my problem Rolling Eyes
Thanks in advance !
Re: Windows that cant leave Mainwindow [message #30471 is a reply to message #30469] Mon, 03 January 2011 13:12 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Hi, Jschn88!
Very welcome to the forums!

I am guessing - Are your subwindows derived from TopWindow?
2nd guess, you wanted your "subwindows" to be parented by your main window?

Please post minimal code and or screenshots.
useful link

[Updated on: Mon, 03 January 2011 13:13]

Report message to a moderator

Re: Windows that cant leave Mainwindow [message #30472 is a reply to message #30469] Mon, 03 January 2011 13:31 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Jens!
Welcome to the U++ Wink

Jschn88 wrote on Mon, 03 January 2011 11:33


The subwindows should only be moved arround in the mainwindow and are not allowed to leave it.

If I understand right, you want something like this:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

class RestrictedTopWindow:public TopWindow{
	TopWindow* parent;
	typedef RestrictedTopWindow CLASSNAME;
public:
	RestrictedTopWindow(TopWindow* parent):parent(parent){
		SetTimeCallback(-50,THISBACK(CheckPos));
	}
	void CheckPos(){
		Rect allowed=parent->GetRect();
		Rect r=GetRect();
		if(!r.Contains(allowed)){
			SetRect(minmax(r.left,allowed.left,allowed.right-r.GetWidth()),
			        minmax(r.top,allowed.top,allowed.bottom-r.GetHeight()),
			        r.GetWidth(),r.GetHeight());
		}
	}
};

class App :public TopWindow {
	typedef App CLASSNAME;
public:
	RestrictedTopWindow rtw;
	App():rtw(this){
		Title("MainWindow");
	}
	void LeftUp(Point p,dword){
		rtw.SetRect(p.x,p.y,200,100);
		rtw.Title("Child window").Sizeable().Run();	
	}
};

GUI_APP_MAIN{
	App().Sizeable().Run();
}
This code is of course oversimplified and probably not very clever anyway, but it might give you some ideas to start with. The basic idea is that you derive your custom class from TopWindow (or some TopWindow-derived class) which checks periodically if its location is correct and reposition itself if necessary. Checking every 100ms is fine enough to go unnoticed for human eye Smile

I didn't find any better way to do it, but that doesn't mean that there is none Smile I think there is no callback or virtual method that is called upon repositioning of window, so unless I missed something this is out of scope. But there might a nicer way how to achieve what you want using Docking windows (have a look in bazaar and search here on the forum).

Best regards,
Honza

EDIT: Fixed an error in the code

[Updated on: Mon, 03 January 2011 14:43]

Report message to a moderator

Re: Windows that cant leave Mainwindow [message #30473 is a reply to message #30472] Mon, 03 January 2011 15:10 Go to previous messageGo to next message
Jschn88 is currently offline  Jschn88
Messages: 2
Registered: January 2011
Junior Member
Your idea is straightforward but sounds good ! I'll test it and see if it runs well.
Thanks a lot for your help Smile

Best regards
Jens

Re: Windows that cant leave Mainwindow [message #31776 is a reply to message #30473] Sat, 26 March 2011 09:52 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I think the best way to achieve this is to not use TopWindows at all. Just create a child control that looks like a window and is dragable around the client area. This will naturally restrict it to the window's area and allow you a lot more flexibility in how the system works.
Previous Topic: [FEATURE] Setting TopWindow to urgent/flashing state
Next Topic: How to get top and left position of top window
Goto Forum:
  


Current Time: Thu Mar 28 12:23:36 CET 2024

Total time taken to generate the page: 0.01317 seconds