



Event handling - perhaps my code could help?

  • Don Clugston
    Don Clugston

    I've just discovered Win32GUI, and am very, very impressed so far.

    However... your event handling is a weak point, and the syntax does look a bit messy. I may be able to help in this.

    In all C++ frameworks I've seen, message handling seems to be resticted by the limitations of member function pointers. It could be much easier if you had additional language support. Eg Borland's VCF uses __closure pointers, Microsoft's .NET uses delegates. Lots of people have tried to emulate this in C++, but usually the syntax is poor, the code is not portable, performance is terrible, and/or there are serious restictions on usage. After extensive research, I created an implementation which I believe has none of these problems. It's proved to be extremely popular:


    After a lot of research into a dozen compilers, I created a 'fastdelegate' library which converts any member function pointer/class pointer pair into a standard 'delegate', binary compatible with Borland's __closure pointers, optimally efficient, and with syntax almost identical to that proposed by Microsoft for C++/CLI delegates. It has been tested on every compiler I could get my hands on - VC6, VC7, VC7.1,  VC 2005 Beta, GCC(x86, SPARC), Borland 5.x, 6.x, DMC, Comeau, PGI, Intel(x86, Itanium), Metrowerks, and I am considering adding support for Codeplay.

    I'm about to improve the code to make it easy to implement dynamic, efficient Win32 message maps, among other things.

    Something like this could open up a lot of possibilities, for example, it would allow you to treat message map entries as a resource, and use RAII on them. Also it might even let you support VC6.

    You might like the code, you might hate it, but either way, I think there's a good chance you'll find the article interesting.

    Your framework just looks so good, I immediately wanted to see if I could contribute :-).


    • John Torjo
      John Torjo

      Hi Don,

      I've read your article, and it looks very nice.

      Why do you say the event handling looks a bit messy?
      I'm quite happy with it so far. I've used win32gui in real apps, and it's very fast.

      Anyway, if you want to help, ther are other areas in which there's help needed. If you (or somebody else) want to help , please contact me privately.