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 » U++ Widgets - General questions or Mixed problems » Size of TopWindow is different then the size I set for it
Re: Size of TopWindow is different then the size I set for it [message #48339 is a reply to message #48330] Sat, 24 June 2017 15:23 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
rafiwui wrote on Fri, 23 June 2017 15:58
When I wanted to add some buttons to a window I encountered a problem:
They were not fully visible. I added them depending on the size returned by TopWindow::GetSize() so I thought they should fit.
Can someone tell me why the TopWIndow is not in the size I gave him?

Here is an example code snippet that should produce the problem properly:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

GUI_APP_MAIN
{
	TopWindow app;
	app.SetRect(0, 0, 500, 200);
	
	Button button1;
	// Button 1 should be centered and with a bit of space on both sides and a bit of space to
	// the top
	button1.SetLabel("Test Button 1").LeftPosZ(10, 480).TopPosZ(10, 80);
	
	Button button2;
	// Button 2 should be centered and with a bit of space on both sides and a bit of space to
	// the bottom. This time the size is measured from the size of the TopWindow and not
	// hardcoded
	button2.SetLabel("Test Button 2").LeftPosZ(10, app.GetSize().cx - 20).TopPosZ(110, 80);
	
	app.Add(button1);
	app.Add(button2);
	
	app.Run();
}


And to be safe I added an image how the window looks when you run the code.


It is because you are using LeftPosZ/TopPosZ - these zoom coordinates based on differences in font size. Use LeftPos / TopPos.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to blur a Ctrl
Next Topic: preferred way to get event "sender" control?
Goto Forum:
  


Current Time: Mon May 13 20:28:09 CEST 2024

Total time taken to generate the page: 0.02099 seconds