Make a window locked and not resizable ?

3 views
Skip to first unread message

Lucas Sanner

unread,
4:36 AM (4 hours ago) 4:36 AM
to fltk.general
Hi all,
I'm using the FLTK library for my project, and I want the main window to start locked at the maximized state.
But I also want to prevent the users to resize the window. So basically, the window has only 2 states: maximized or minimized.
I tried the size_range() method:

int main(int argc, char *argv[])
{
    Fl_Double_Window* win = new Fl_Double_Window(800, 400, "My Application");
    int screen_w = Fl::w();
    int screen_h = Fl::h();
    // Blocks the window's size to screen dimensions.
    win->size_range(0, 0, screen_w, screen_h);
    win->end();
    win->show();
    // Start the app maximized.
    win->maximize();
    // Make the app non resizable.
    win->resizable(nullptr);

    return Fl::run();
}


but the window is still resizable when the top border is double clicked or the resize button is clicked.
Is there any way to fix that without hijacking the window manager ?
note: I'm under Linux (Debian 13) with FLTK 1.4

Manolo

unread,
7:04 AM (1 hour ago) 7:04 AM
to fltk.general
this approach seems to make it:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main(int argc, char **argv) {
  int X,Y,W,H;
  Fl::screen_work_area(X,Y,W,H,0);
  Fl_Window *window = new Fl_Window(W, H);
  Fl_Box *box = new Fl_Box(20, 40, 300, 100, "Hello, World!");
  box->box(FL_UP_BOX);
  box->labelfont(FL_BOLD + FL_ITALIC);
  box->labelsize(36);
  window->end();
  window->show(argc, argv);
  return Fl::run();
}

Reply all
Reply to author
Forward
0 new messages