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 top and left position of top window
How to get top and left position of top window [message #31868] Fri, 01 April 2011 22:57 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
When debugging a watch set for "rect" gets this but I am not able to set a variable with this.

Same with Top and Left.

Get errors they are private/protected or whatever.

When a user moves the window to his preferred position I would like to save this to a config file.

Neil
Re: How to get top and left position of top window [message #31873 is a reply to message #31868] Sun, 03 April 2011 17:10 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

nlneilson wrote on Fri, 01 April 2011 22:57

When debugging a watch set for "rect" gets this but I am not able to set a variable with this.

Same with Top and Left.

Get errors they are private/protected or whatever.

When a user moves the window to his preferred position I would like to save this to a config file.

Neil

Hi Neil,

Do you mean GetRect()? Smile

Also, if you are interested in storing window placement, you might want to look at TopWindow::SerializePlacement(Stream& s,bool reminimize). It is aimed to binary serialization, but even if you use some other form (cfg file, XML,...) it should give you some inspiration.

Best regards,
Honza
Re: How to get top and left position of top window [message #31874 is a reply to message #31868] Sun, 03 April 2011 18:14 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Honza

It took me about 6 hour tinkering to find something.

I had to do a a search with Windows file explorer for "rect" (not case sensitive) and search each file with Notepad++ and finally found "GetRect().left;" and ended with this:
		int leftP = GetRect().left;
		int topP = GetRect().top;

Then it was a simple and straight forward implementation.

I have three computers I use to test with and all have a dual boot with Ubuntu so the Upp window was in 6 slightly different positions. I don't release as finished something like that.

I don't know anything about "TopWindow::SerializePlacement".
When this is explained with a simple example in the Help docs I may try it.

Upp is a great project but there should be documentation for all of the functions/capabilities.

If it was not for the help on this forum, for someone like myself, Upp would not be a viable option.

Thanks

Neil

[Updated on: Sun, 03 April 2011 18:21]

Report message to a moderator

Re: How to get top and left position of top window [message #31875 is a reply to message #31874] Sun, 03 April 2011 19:29 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
This is one of four Upp apps.
The first time it is run the Upp window can be moved to any position. Clicking File->"Save > Exit" will save the window position (and ~10 other setting).

Neil
  • Attachment: GeoCalc.exe
    (Size: 1.25MB, Downloaded 359 times)
Re: How to get top and left position of top window [message #31886 is a reply to message #31874] Mon, 04 April 2011 18:29 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

nlneilson wrote on Sun, 03 April 2011 18:14

I had to do a a search with Windows file explorer for "rect" (not case sensitive) and search each file with Notepad++ and finally found "GetRect().left;" and ended with this:
		int leftP = GetRect().left;
		int topP = GetRect().top;

Then it was a simple and straight forward implementation.
Why don't you use theide search functions? E.g. Ctrl+Shift+F for search in files. Also, searching help or this webpage (via the google search box on the left, below menu) is a good idea. Reading Ctrl reference (which you should read just after reading TopWindow reference, since TopWindow inherites from Ctrl) would give you the answer in 15 minutes top.

nlneilson wrote on Sun, 03 April 2011 18:14

I have three computers I use to test with and all have a dual boot with Ubuntu so the Upp window was in 6 slightly different positions. I don't release as finished something like that.

I don't fully understand this... Do you mean that each computer and each OS gives different placement? With default setting or with the position taken from the stored configuration? Also, why do you think it is wrong? There is a lot of factors that influence this: window manager settings, gnome/windows panel width, monitor size etc... If you wish to achieve the same position on all systems (which is IMHO the least important part of design), you can use fixed window size and call CenterScreen() method.


nlneilson wrote on Sun, 03 April 2011 18:14

I don't know anything about "TopWindow::SerializePlacement".
When this is explained with a simple example in the Help docs I may try it.
It IS documented. The description is in the first place where you should look for such function: in the TopWindow reference. There is also an article on saving configuration and even more info can be found on the forum. We all know that U++ documentation is not 100%, but this is not the case. TopWindow, Ctrl and other parts of CtrlCore are very well documented.

Honza
Re: How to get top and left position of top window [message #31893 is a reply to message #31886] Mon, 04 April 2011 22:30 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
dolik.rce wrote on Mon, 04 April 2011 18:29



1. I don't fully understand this... Do you mean that each computer and each OS gives different placement?

2. Why don't you use theide search functions? E.g. Ctrl+Shift+F for search in files. Also, searching help or this webpage (via the google search box on the left, below menu) is a good idea. Reading Ctrl reference (which you should read just after reading TopWindow reference, since TopWindow inherites from Ctrl) would give you the answer in 15 minutes top.

3. It IS documented. The description is in the first place where you should look for such function: in the TopWindow reference. There is also an article on saving configuration and even more info can be found on the forum. We all know that U++ documentation is not 100%, but this is not the case. TopWindow, Ctrl and other parts of CtrlCore are very well documented.

Honza


1. Yes that is exactly what I mean, the Upp window is in different locations relative to my Java display app it interacts with for all 6. See the attached image. Now a user can drag the Upp app window to wherever they prefer and with "Save > Exit" the Upp app will open in that location.

2. Ctrl+Shift+F, Ctrl+f or clicking Edit->Find and Replace->Find only searches the file in the editor.
Also the only thing from debug was "rect".

Some of the time I don't have access to the web other than when I go into Mojave and hook up to the wireless at McDonalds, much slower than my connection on Oxnard.

3. I will check out the documentation mentioned in 2. and 3..
Perhaps Documentation on how you get to the documentation as you mentioned in 2. and 3. would be of help to Newbies like myself.

Thanks for the help Honza, that should save me time in the future.

Neil
  • Attachment: UppLoc.jpg
    (Size: 32.10KB, Downloaded 351 times)
Re: How to get top and left position of top window [message #31895 is a reply to message #31873] Mon, 04 April 2011 23:13 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
dolik.rce wrote on Sun, 03 April 2011 17:10

Do you mean GetRect()? Smile


There are several threads on Upp/Python.
I am into Python, C/C++ (Upp) and Java so my head hurts sometime just keeping things straight.

One thing in Python is the Help is very good. Each function has a very simple example. Relating this to what would be useful in Upp for this problem could be:
int leftPosition = GetRect.left;

Assist->Search word in Help Topics->"GetRect"
will bring up enum PlacementConstants
First a person needs to know to search for "GetRect" rather than "rect".
Then for the enum GetRect.left rather than trying rect[0] or ???

Upp is very good but sometimes it is hard to find how to solve what should a simple problem.

Neil
Re: How to get top and left position of top window [message #31904 is a reply to message #31893] Tue, 05 April 2011 19:10 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

nlneilson wrote on Mon, 04 April 2011 22:30

1. Yes that is exactly what I mean, the Upp window is in different locations relative to my Java display app it interacts with for all 6. See the attached image. Now a user can drag the Upp app window to wherever they prefer and with "Save > Exit" the Upp app will open in that location.
I would consider this minor issue, especially since you have no guarantee that the Java window will always open at the same position... But anyway, if you insist on this, just use LoadFromFile and StoreToFile at the beginning and end of your code, respectively. Then override a Serialize method of your window with something like this:
void MyWindow::Serialize(Stream& s){
    SerializePlacement(s);         // This stores/loads the window state and position
    s % MyVariable1 % MyVariable2; // Variables to be stored/loaded
    s % MyVariable3;
}
This is just basic idea, you can find the details of the functions and concepts in the articles I linked in one of the previous posts.

nlneilson wrote on Mon, 04 April 2011 22:30

2. Ctrl+Shift+F, Ctrl+f or clicking Edit->Find and Replace->Find only searches the file in the editor.
Also the only thing from debug was "rect".

Some of the time I don't have access to the web other than when I go into Mojave and hook up to the wireless at McDonalds, much slower than my connection on Oxnard.
Oops, I meant Ctrl+H, sorry. All the important content from the webpage (excluding forum) is available within theide, so being off-line shouldn't be much of a problem...

nlneilson wrote on Mon, 04 April 2011 22:30

3. I will check out the documentation mentioned in 2. and 3..
Perhaps Documentation on how you get to the documentation as you mentioned in 2. and 3. would be of help to Newbies like myself.
Ctrl+F1 should search the word under cursor in the help. I understand that searching for something like "rect" does show a lot of results (you can jump between them using the green arrows next to the search box), most of them being useless. On the other hand, the method GetRect() is a basic thing, mentioned in the tutorials and of course also in the Ctrl reference (which everyone using U++ GUI should read, along with TopWindow reference and few others...).

Honza
Re: How to get top and left position of top window [message #31906 is a reply to message #31904] Tue, 05 April 2011 21:21 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
dolik.rce wrote on Tue, 05 April 2011 19:10

1. ... no guarantee that the Java window will always open at the same position...

2. All the important content from the webpage (excluding forum) is available within theide, so being off-line shouldn't be much of a problem...

3. (you can jump between them using the green arrows next to the search box)

4. the method GetRect() is a basic thing, mentioned in the tutorials and of course also in the Ctrl reference (which everyone using U++ GUI should read, along with TopWindow reference and few others...).


1. The Java window always opens in the top left corner. The different screen resolutions, the top task bar in Linux, etc. is what causes the shift. I didn't like or want a user to drag anything when the apps are started. Works fine now.

2. I noticed the help docs that are installed with Upp are very extensive now. That is a great help, I just need to get familiar with using it. Before it was very limited.
This is a very big improvement for someone getting started with Upp.

3. The green arrows are very handy.

4. That has been my problem in not spending enough time understanding "Ctrl reference, TopWindow reference and few others...". I just recently learned how to include bazaar in the options to choose when opening theIde. C:\upp\examples\Bombs\main.cpp has "Rect r = GetRect();" which didn't show how to get the left and top position. Other than that it is only found in bazaar and uppsrc. This is looking back as previously I was looking for "rect".

I appreciate the help, thanks Honza.

Neil
Previous Topic: Windows that cant leave Mainwindow
Next Topic: Restoring TrayIcon control
Goto Forum:
  


Current Time: Thu Mar 28 21:52:44 CET 2024

Total time taken to generate the page: 0.01158 seconds