Hi,
I am developing a solution with Servoy 4.0.1 and have found a problem with the getScreenHeight() method.
Basically I am using this method in my solutions start up method, the content of which is shown below:
globals.screen_width = application.getScreenWidth();
globals.screen_height = application.getScreenHeight();
var window_x = (globals.screen_width - globals.window_width) / 2;
var window_y = (globals.screen_height - globals.window_height) / 2;
application.setWindowSize(globals.window_width, globals.window_height);
application.setWindowLocation(window_x, window_y);
There are four globals used in this code:
screen_width & screen_height are used to get the screen dimensions (this is done in the first 2 lines of code).
window_width & window_height are used to store the required dimensions of the client window. These are set to 1100(w) and 800(h). These values are not changed at anytime. They are simply used to set the window size at start up.
The problem I have with this is that the application.getScreenHeight() call seems to return the screen width instead of the screen height. I first realised that something was wrong when I started the solution, only to find that the client window was not positioned as specified in the code above.
Basically the x position of the window (left to right) was fine. There were the same sized gaps on either side of the window, which is what the code above is set up to do.
However, the y position of the window (top to bottom) was totally wrong. There was a huge gap between the top of the screen and the top of the window, and the bottom of the window was completely off the screen.
This made me think that the value being returned by the application.getScreenHeight() was incorrect. I therefore set up a couple of fields in the solutions navigator, to show the returned values. Basically, both methods (getScreenWidth() & getScreenHeight()) return the same value. That value is the screens width. I have also changed the resolution of my machine and have seen those changes appear in the fields mentioned above. This confirms that both fields return the same value, and that value is actually the screens width.
The screen shot below shows the two fields that set up in the navigator. They display the two global screen size values returned in the method above. The height field is showing the screen_height value returned by the getScreenHeight() method.
Craig
[attachment=0]wrong_height_returned.jpg[/attachment]