Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Lock Window Resize C++ sfml?

Improve Article
Save Article
  • Last Updated : 02 Jan, 2023
Improve Article
Save Article

Multimedia components in computers can be easily interfaced using SFML (Simple and Fast Multimedia Library), a cross-platform library for software development. The software runs on Windows, Linux, Mac OS X, iOS, and Android operating systems. Video games and graphical programs can be developed quickly and easily with SFML’s set of tools. Among its features are graphics, audio, networking, and system functions. In addition, it provides classes for managing windows and for capturing user input. 

In order to prevent a window from being resized in SFML, you can use the sf::Window::setSize method to set the window’s size to a fixed value. 

Before using sf::Window::setSize:



// C++ Program To Lock Window Resize C++ sfml
#include <SFML/Window.hpp>
#include <iostream>
int main()
    // Create the window
    sf::Window window(sf::VideoMode(600, 600), "SFML WORK!");
    // Set the window's size to a fixed value (600 x 600)
    window.setSize(sf::Vector2u(600, 600));
    // Run the main loop
    while (window.isOpen()) {
        // Process events
        sf::Event event;
        while (window.pollEvent(event)) {
            // Close the window if requested
            if (event.type == sf::Event::Closed) {
        // Clear the window
        // Display the window's contents on the screen
    return 0;


Explanation: In this example, we create a window with a size of 600 x 600 pixels, and then use the setSize method to set the window’s size to the same value. This effectively prevents the user from resizing the window.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!