How to center a window when showing it | C++ #8388
-
I'm trying to center a window when showing it,
But on Windows, calling size() on a window before it's displayed always returns 800*600, not its actual size. Calling size() on the window after it's displayed and centering it doesn't look pretty. Is there any other way to center a window? I will be grateful for help. P.S I apologize for my auto-English. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I am not sure but maybe you can just do something like window.set_size({800, 600}) // if you want it to have constant size, just change to its actual size Or window.show(); Ping me if you need any help |
Beta Was this translation helpful? Give feedback.
I am not sure but maybe you can just do something like
window.set_size({800, 600}) // if you want it to have constant size, just change to its actual size
CenterPosition(window);
window.show();
Or
window.show();
std::thread(&window {
std::this_thread::sleep_for(std::chrono::milliseconds(50)); // Just waiting the window to be opened
CenterPosition(window); // then only center it
}).detach();
Ping me if you need any help