Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Minimizing Window  (Read 5209 times)

0 Members and 1 Guest are viewing this topic.

Danetta

  • Newbie
  • *
  • Posts: 11
    • View Profile
Minimizing Window
« on: January 22, 2017, 12:16:57 pm »
Hello.

At first, I used default settings in sf::Style in sf::RenderWindows Create function.
Then I decide to create my one minimize and exit buttons, so I just used sf::Style::None.

I have issues with both of these approaches.

If I use standard windows settings, then I see an empty Window (after launching a program) with plain white color inside it for a half-second before all other objects are rendered.

If I use sf::Style::None instead, then, even if I do implement minimize and exit buttons by myself, then window somehow becomes unresponsible in terms of minimizing/restoring (but everything rendered just after starting, without empty white windows).
First, minimizing stops working when I click on taskbar. It works with standard settings, but doesn't with sf::Style::None, while the only thing I want to do is hiding default buttons and default window upper bar.
Also, if I minimize all active windows with "Win+D", then my application restoring automatically even when I restored another application, not mine.

What is the solution?

UPD:
Tried something with Winapi.
Creating sfml window with sf::Style::Default and then erased some flags like that:
sf::WindowHandle window_handle = window_render.getSystemHandle();
LONG lStyle = GetWindowLong(window_handle, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_SYSMENU);
SetWindowLongPtr(window_handle, GWL_STYLE, lStyle);
Also tried some other combinations, but with this one I managed to create a simple window with working minimize (unlike  sf::Style::None), but again with white empty space at launch (like sf::Style::Default).

Any advice would be appreciated.

UPD2: Well, after reading through WinApi documentation, I tried the following.
Created sfml window with sf::Style::None. Then added a minimize box to it via this code:
LONG lStyle = GetWindowLong(window_handle, GWL_STYLE);
lStyle |= (WS_MINIMIZEBOX);
SetWindowLongPtr(window_handle, GWL_STYLE, lStyle);
SetWindowPos(window_handle, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);

After that I still have no minimize box (because I have no caption and borders obviously), but minimizing via taskbar now works. I don't know if it is good solution and want some insight, but sfml probably need a way to handle this thing without requiring a user to write winapi code.
« Last Edit: January 22, 2017, 01:36:36 pm by Danetta »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Minimizing Window
« Reply #1 on: January 22, 2017, 01:43:26 pm »
If your only problem is a white screen for a second or two when starting up your application, then you could simply add a clear() & display() directly after the window creation and put the time consuming resource loading etc. afterwards.

Otherwise, you might be better off on StackOverflow or some other forum, if you only have issues with the WinAPI.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Danetta

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Minimizing Window
« Reply #2 on: January 22, 2017, 03:05:04 pm »
Otherwise, you might be better off on StackOverflow or some other forum, if you only have issues with the WinAPI.
Not only with WinAPI, because sf::Style::None not only removes style, but removes the functional of minimizing window via taskbar.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Minimizing Window
« Reply #3 on: January 22, 2017, 06:52:26 pm »
What I mean is, if you want to do some WinAPI magic or have some question about it, then it might be better to ask on a platform where you'll find more people with knowledge about it. Here on the SFML forum you won't find that many who can give you advice on this.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Danetta

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Minimizing Window
« Reply #4 on: January 22, 2017, 07:40:56 pm »
Well, I come to the conclusion that I need to use WinAPI because SFML provide sf::Style in a weird way. It's apparently not "sfml unrelated" question.

I don't really "want" or "need" to use WinAPI, I just don't know any other workaround for that thing with SFML which I mentioned.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Minimizing Window
« Reply #5 on: January 22, 2017, 07:51:28 pm »
We don't support minimizing or maximize a window programatically yet. As such there's no way around using custom hacks or add support for it and send in a PR. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/