hamed wrote:
> hi
> i try to use FLTK in DEV-C++ and when i used this source GCC compiler send an
> error.
>
> Source:
> int Fl_Window::handle(int e)
> {
> switch(e)
> {
> case FL_PUSH:
> exit(1);
> break;
> }
> exit(1) ;
> }
>
You are going to have to tell us what you are trying to achieve with
this, as I can't figure it out from looking at the code.
There are many things wrong with this - probably you need to get some
books on programming in C and C++, and also study the examples in the
/test folder of the fltk tarball.
Turning to your code, I am going to guess what it means, and try and
suggest the things that are wrong...
So, here's my guess: You have a window, and you want to add the ability
to close it by clicking on the window?
You can do that, but you will need to derive your own window class from
Fl_Window to do it. See the examples for how to do this.
You can not simply replace the handle method of an existing widget class
- that is what the compiler is trying to warn you about.
What do you think that exit() does? It seems there is no path through
your proposed handle method that does not call exit(), so what do you
expect it to do?
(Note: what it actually does is cause your program to terminate, so
since there is no path through that handle that does not exit(), any
event that happens will cause your program to terminate - if it were
compilable, that is.)
Your switch statement ought to have a default: case to catch all the
events that are not FL_PUSH (although the default case need no do
anything, it ought to be there.)
Your handle function ought to return a value - non-zero for the cases
you handle, 0 for the cases you do not handle. Maybe this is what you
think exit() does?
Anyway, Greg has some useful examples here you might get some tips from:
http://seriss.com/people/erco/fltk/
And some helpful getting started videos:
http://seriss.com/people/erco/fltk-videos/
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk