Hi all,

I'd like to handle non-fltk events (coming from MS Windows) inside my FLTK 
callbacks.

As far as I've understood:

1. I can't use Widget's handle() member function. It is passed *only* 
FLTK-specific events.

2. I can't create my own "run loop", like this:
    while (check ())
    {
        ...
        // process message here
        ...
    }
since either check() or wait() do the dispatching before I can manually handle 
the message.

3. I can only process custom events in callbacks registered with add_handler(), 
through the fl_msg variable (holding the last MSG received), is that right?

I'd like to know if there's another way to handle custom messages?




For information, I've a class managing a hardware device which send messages 
when something happened:

--------

const int my_hardware_event = ...;

class HardwareDevice
{
    HWND NotifyWnd; // Window to send the message to
    ...
    void OnDeviceNotification ()
    {
        // Notification from the hardware: send the my_hardware_event
        // message to the window identified by NotifyWnd, with
        // appropriate parameters
        ::PostMessage (NotifyWnd, my_hardware_event, wParam, lParam);
        // (This design is kinda weird, I think GUI windows shouldn't
        // be responsible to handle hardware messages, but that's not
        // my class and I can't modify it.)

    }
    ...
}

--------

I set NotifyWnd to be an FLTK window. When Windows receives the message posted 
by the hardware class, it dispatches it to FLTK's run() - or check() or wait().

Then, in my FLTK application:

--------

int MySystemEventCallback (int event)
{
    // Return 0 if this isn't our event, telling FLTK we don't want it
    if (my_system_event != fl_msg.message) return 0;

    // Otherwise, process the event and return 1
    ...
    return 1;
}

Fl::add_handler (my_system_event_callback);

--------
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to