This example shows how to use fl_file_chooser function.
1 #pragma package ".." 2 3 #include "chfltk.h" 4 #include <stdio.h> 5 #include <stdlib.h> 6 7 void select_cb(Fl_Widget *g, void *v) { 8 const char *name; 9 name = fl_file_chooser("Select file", "*.i", "ala.i"); 10 } 11 12 int main(int argc, char *argv[]) 13 { 14 Fl_Window *window = new Fl_Window(300, 180); 15 Fl_Button *box = new Fl_Button(20, 40, 260, 100, "Select file"); 16 box->box(FL_UP_BOX); 17 box->callback((ChFl_Callback)select_cb, (void*)0); 18 box->labelsize((uchar)36); 19 box->labelfont((uchar)(FL_BOLD+FL_ITALIC)); 20 window->end(); 21 window->show(argc, argv); 22 Fl::run(); 23 exit(1); 24 return 0; 25 }
Code description
- 17
- Overloaded methods need explicit casting of parameters
- 18
- Type uchar is defined by FLTK to unsigned char. See also the * comment above about overloaded methods
- 22
- Start FLTK event loop
- 23
- This shouldn't be necessary if future releases of ChFLTK but at the moment one needs to call exit() to terminate application smoothly