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 get and set window placement information?
How to get and set window placement information? [message #14656] Thu, 06 March 2008 11:20 Go to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

How do I get and set TopWindow placement information? I'm attempting to save and then on next program launch restore the window position and normal / minimize / maximize / fullscreen status of the window. The flags are clearly available from TopWindow::IsMinimized() etc. but the position acquired with GetRect() simply returns the current size even if the window is maximized.

Are there member functions for setting and getting the "normal" (i.e. not minimized or maximized) window rect?

// Tom
Re: How to get and set window placement information? [message #14657 is a reply to message #14656] Thu, 06 March 2008 11:29 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
See TopWindow::SerializePlacement().
Re: How to get and set window placement information? [message #14658 is a reply to message #14657] Thu, 06 March 2008 11:56 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mrjt wrote on Thu, 06 March 2008 12:29

See TopWindow::SerializePlacement().


Thanks, but unfortunately the TopWindow::SerializePlacement() appears to use the SetRect/GetRect in the standard way and is not able to store the "normal" i.e. restored rect size if the window is maximized or minimized when saving data through SerializePlacement(). You can see this if you try to normalize = restore the window after loading a maximized window placement using SerializePlacement().

So, the question remains: Are there member functions for setting and getting the "normal" (i.e. not minimized or maximized) window rect?

// Tom
Re: How to get and set window placement information? [message #14659 is a reply to message #14658] Thu, 06 March 2008 12:30 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I see, I'd never noticed that before. It seems that Upp doesn't retain this information, rather it is done by the operating system.

But you can add the functionality easily enough:
class CtrlLibTest : public TopWindow {
public:
    typedef CtrlLibTest CLASSNAME;
    Rect normal;
    
    CtrlLibTest()
    {
        SetRect(0, 0, 308, 344);
        CenterScreen();
        normal = GetRect();
       	Sizeable().MaximizeBox(true).MinimizeBox(true);
       
       	FileIn in(GetDataFile("window.pos"));
       	if (in.IsOpen()) {
       		in % normal;
       		SetRect(normal);
       		SerializePlacement(in, true);
       	}
    }

    virtual void Layout() {
     	if (!IsMaximized() && !IsMinimized() && IsShown())
     		normal = GetRect();
    }

    virtual void Close()
    {
       	FileOut out(GetDataFile("window.pos"));
       	if (out.IsOpen()) {
       		out % normal;
       		SerializePlacement(out);   
       	}
       	TopWindow::Close();     
    }
};

[Updated on: Thu, 06 March 2008 12:31]

Report message to a moderator

Re: How to get and set window placement information? [message #14660 is a reply to message #14659] Thu, 06 March 2008 14:42 Go to previous message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Thanks, James! I only added another && !IsFullScreen() to the Layout() function to take care of that scenario too. Now it should work all the way. However, I would like to see the following additions made to the TopWindow class, but I guess it's up to Mirek to decide, right?

Anyway:

private:
Rect normalrect;

public:
Rect &GetNormalWindowRect(){ return normalrect; }

void SetNormalWindowRect(Rect &rect){ 
	normalrect=rect; 
	if (!IsMaximized() && !IsMinimized() && !IsFullScreen() && IsShown()) SetRect(rect);
}

virtual void Layout(){ 
	// or where ever the following belongs so that it 
	// gets properly executed even when the virtual Layout() 
	// function gets overridden in an inherited class
	...
	if (!IsMaximized() && !IsMinimized() && !IsFullScreen() && IsShown()) normalrect = GetRect();
	...
}


// Tom
Previous Topic: Toggling between FullScreen and not
Next Topic: Transparent TopWindow
Goto Forum:
  


Current Time: Thu Apr 18 17:41:30 CEST 2024

Total time taken to generate the page: 0.02211 seconds