Home » Community » Newbie corner » Top starting position of GUI changes.
Top starting position of GUI changes. [message #33125] |
Sat, 09 July 2011 02:06  |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
I have several U++ apps that a user can drag the GUI and the next time it is opened that is where it will be.
Works OK on WinXP and Ubuntu.
On Win Vista and W7 the top position creeps down.
Attached is a package that shows this behavior.
I put a break point at line 80 to see what is being saved.
Just opening the app and clicking File=>Save>exit it creeps down as it is displayed lower each time:
48
55
63
72
83
etc.
The left position seem OK it is just the top position that creeps down.
This is with U++ 3627 and earlier builds have the same problem.
I have tried this app (the .exe) on several different computers with Vista and W7 and all have shown this.
Even hard coding the top position the GUI is displayed lower than it should be.
|
|
|
Re: Top starting position of GUI changes. [message #33130 is a reply to message #33125] |
Sat, 09 July 2011 13:14   |
|
Hi Neil!
The problem is that you use different coordinates when saving the positions then when setting it. GetRect() in you exit function returns absolute position in pixels, while TopPosZ() and LeftPosZ() work with "zoomed coordinates".
The solution you probably want is to use the "non-Z" functions: LeftPos(leftP, 280).TopPos(topP, 135);
Best regards,
Honza
PS: #include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <time.h>
#include <iostream>
#include <fstream>
using namespace std;
using namespace std; These includes at the beginning of your files are useless, and especially the windows.h kind of scared me - it obviously fails to compile on non-windows sytems
|
|
|
|
Re: Top starting position of GUI changes. [message #33146 is a reply to message #33145] |
Mon, 11 July 2011 08:00   |
|
nlneilson wrote on Mon, 11 July 2011 07:01 | What advantage is there with "LeftPos(..." over "SetRect(..."?
|
None Actually, in this case I would use SetRect. The *Pos() functions are useful when you want some advanced positioning made easy, imagine that you want to put widget in the bottom, horizontally centered. That would require quite some arithmetic using SetRect, while HCenterPos(width).BotomPos() will calculate it for you. Also, when positioning Ctrls, these functions are usually a must, because they ensure proper behavior when the window is resized.
Honza
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 04:33:19 CEST 2025
Total time taken to generate the page: 0.01054 seconds
|