al_win_*_window_callback suggestion
Erin Maus

Hey,

I'm trying to embed an Allegro display into my application so I can make a scene editor in C# with Windows Forms. There's only one small problem: the callback method used in al_win_add_window_callback or al_win_remove_window_callback doesn't let me return an LRESULT... Which means I can't suppress some events (namely WM_MOUSEACTIVATE).

There is an easy fix, though!

The callback method should be declared as so:

bool (*callback)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *)

When the callback returns true, return the LRESULT (which hopefully was assigned to by the callback) instead of TRUE as is done here:

   for (i = 0; i < _al_vector_size(&win_display->msg_callbacks); ++i) {
      ALLEGRO_DISPLAY_WIN_CALLBACK *ptr = _al_vector_ref(&win_display->msg_callbacks, i);
      if ((ptr->proc)(d, message, wParam, lParam, ptr->userdata))
         return TRUE;
   }

(This is in the window_callback method defined in wwindow.c; I would give line numbers but my copy of Allegro is out of date right now).

This is necessary for a multitude of WM_* messages. WM_MOUSEACTIVATE, for example, expects a special return value. Right now, MA_ACTIVATE is always returned.

I can submit a patch very soon if this API change is acceptable. I don't know if anyone else other than me uses this method, anyway :P.

edit: I've attached a patch that should provide the extra functionality. Everything works fine on my end (including ex_menu).

Matthew Leverton

The person (me) who added this callback functionality barely knows the first thing about Windows programming. The only reason it's set up that way is that it was all that was needed to get menus working.

You should submit a documentation patch as well, although you may want to wait for consensus before doing that.

Thread #613870. Printed from Allegro.cc