SFML community forums

Help => Window => Topic started by: reDo on June 05, 2011, 11:32:01 am

Title: Wrong size of window
Post by: reDo on June 05, 2011, 11:32:01 am
I used this command, but it creates windows with 111 and 200
Code: [Select]
sf::RenderWindow App(sf::VideoMode(100, 200, 32), "Eye");
Where can be problem?
(http://i53.tinypic.com/anzbpy.jpg)
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 11:51:02 am
How do you know that the width is 111?
Title: Wrong size of window
Post by: reDo on June 05, 2011, 12:17:55 pm
Because I measured it, here is example to show, what am I doing wrong please?
Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>


int main()
{
    sf::RenderWindow App(sf::VideoMode(100, 200, 32), "Eye");

    while (App.IsOpened())
    {

        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

        App.Clear(sf::Color(64,64,64));

        App.Draw(sf::Shape::Circle(100, 10, 5, sf::Color(128,255,0)));

        App.Display();
        sf::Sleep(0.025f);
    }


    return EXIT_SUCCESS;
}

(http://i54.tinypic.com/21eda9x.jpg)
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 12:33:01 pm
There's nothing wrong with your code, actually.
Title: Wrong size of window
Post by: reDo on June 05, 2011, 12:56:19 pm
but why has the windows width 111 and no 100 like I want?
Title: Wrong size of window
Post by: Groogy on June 05, 2011, 01:07:37 pm
Are you counting the borders too?
Title: Wrong size of window
Post by: reDo on June 05, 2011, 01:14:40 pm
no, you can see the problem picture, there I draw circle on x 100 but it is not on good position
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 01:36:11 pm
Quote
but why has the windows width 111 and no 100 like I want?

I don't know.
Title: Wrong size of window
Post by: reDo on June 05, 2011, 01:39:35 pm
I thought someone will know when here are more experienced users :( and you are SFML developer.
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 01:45:58 pm
I'm sorry but this is really strange. It's a very basic thing, and nobody had experienced this bug before you.

What happens if you use a different size? Is the real size always greater by 11 pixels? What is your OS? Do you use SFML 1.6?
Title: Wrong size of window
Post by: reDo on June 05, 2011, 02:02:34 pm
OS: Windows XP SP3, SFML 1.6, CodeBlocks - MinGW,  
window x 110, real x 111
window x 20,real x 111
y works good (I tried it with 20 and it works fine), it looks like some limit or something
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 02:06:27 pm
Quote
window x 20,real x 111

Width is always 111 ?!
Title: Wrong size of window
Post by: reDo on June 05, 2011, 02:49:22 pm
window x 120, real 120 so I think only when window width is equal or less than 111
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 03:30:05 pm
Oh, ok I see. That's the minimum window width that the OS allows, so that the icon and buttons can fit in the title bar.
Title: Wrong size of window
Post by: reDo on June 05, 2011, 04:26:05 pm
So I cannot do  anything with it? because I want window's width 100 pixels
Title: Wrong size of window
Post by: Laurent on June 05, 2011, 04:42:41 pm
I think there's nothing you can do, nobody can create a smaller window.

You can try to remove the maximize and minimize buttons (if you want a 100 pixels wide window you probably don't want users to be able to resize it anyway, right?), and maybe the OS will allow the window to be smaller.
Title: Wrong size of window
Post by: reDo on June 05, 2011, 05:39:24 pm
Yes, you are right, thanks for all
Title: Wrong size of window
Post by: Hiura on June 05, 2011, 06:06:30 pm
Remove the border ? (sf::Style::None)
Title: Wrong size of window
Post by: reDo on June 05, 2011, 07:54:35 pm
Yes, I did it and it works, only difference is I used 0 instead of None, thanks Laurent and Hiura a little bit too  :)
Title: Wrong size of window
Post by: Hiura on June 05, 2011, 08:08:58 pm
Well, 0 might work now but
- this is not guaranteed in the future (if Laurent change the order of the enum for example);
- None is much more readable/meaningful/...
 :wink:
Title: Wrong size of window
Post by: reDo on June 05, 2011, 08:38:42 pm
Yes, you are right so I use None like you mentioned :D